Commit af80b973 authored by Michal Kubeček's avatar Michal Kube�ek Committed by Willy Tarreau

ipv6: don't call fib6_run_gc() until routing is ready

commit 2c861cc6 upstream.

When loading the ipv6 module, ndisc_init() is called before
ip6_route_init(). As the former registers a handler calling
fib6_run_gc(), this opens a window to run the garbage collector
before necessary data structures are initialized. If a network
device is initialized in this window, adding MAC address to it
triggers a NETDEV_CHANGEADDR event, leading to a crash in
fib6_clean_all().

Take the event handler registration out of ndisc_init() into a
separate function ndisc_late_init() and move it after
ip6_route_init().
Signed-off-by: default avatarMichal Kubecek <mkubecek@suse.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: <stable@vger.kernel.org> # 3.10.y
Signed-off-by: default avatarMike Manning <mmanning@brocade.com>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 349759be
...@@ -190,7 +190,9 @@ static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, cons ...@@ -190,7 +190,9 @@ static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, cons
} }
extern int ndisc_init(void); extern int ndisc_init(void);
extern int ndisc_late_init(void);
extern void ndisc_late_cleanup(void);
extern void ndisc_cleanup(void); extern void ndisc_cleanup(void);
extern int ndisc_rcv(struct sk_buff *skb); extern int ndisc_rcv(struct sk_buff *skb);
......
...@@ -900,6 +900,9 @@ static int __init inet6_init(void) ...@@ -900,6 +900,9 @@ static int __init inet6_init(void)
err = ip6_route_init(); err = ip6_route_init();
if (err) if (err)
goto ip6_route_fail; goto ip6_route_fail;
err = ndisc_late_init();
if (err)
goto ndisc_late_fail;
err = ip6_flowlabel_init(); err = ip6_flowlabel_init();
if (err) if (err)
goto ip6_flowlabel_fail; goto ip6_flowlabel_fail;
...@@ -960,6 +963,8 @@ static int __init inet6_init(void) ...@@ -960,6 +963,8 @@ static int __init inet6_init(void)
addrconf_fail: addrconf_fail:
ip6_flowlabel_cleanup(); ip6_flowlabel_cleanup();
ip6_flowlabel_fail: ip6_flowlabel_fail:
ndisc_late_cleanup();
ndisc_late_fail:
ip6_route_cleanup(); ip6_route_cleanup();
ip6_route_fail: ip6_route_fail:
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
...@@ -1020,6 +1025,7 @@ static void __exit inet6_exit(void) ...@@ -1020,6 +1025,7 @@ static void __exit inet6_exit(void)
ipv6_exthdrs_exit(); ipv6_exthdrs_exit();
addrconf_cleanup(); addrconf_cleanup();
ip6_flowlabel_cleanup(); ip6_flowlabel_cleanup();
ndisc_late_cleanup();
ip6_route_cleanup(); ip6_route_cleanup();
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
......
...@@ -1716,24 +1716,28 @@ int __init ndisc_init(void) ...@@ -1716,24 +1716,28 @@ int __init ndisc_init(void)
if (err) if (err)
goto out_unregister_pernet; goto out_unregister_pernet;
#endif #endif
err = register_netdevice_notifier(&ndisc_netdev_notifier);
if (err)
goto out_unregister_sysctl;
out: out:
return err; return err;
out_unregister_sysctl:
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
neigh_sysctl_unregister(&nd_tbl.parms);
out_unregister_pernet: out_unregister_pernet:
#endif
unregister_pernet_subsys(&ndisc_net_ops); unregister_pernet_subsys(&ndisc_net_ops);
goto out; goto out;
#endif
} }
void ndisc_cleanup(void) int __init ndisc_late_init(void)
{
return register_netdevice_notifier(&ndisc_netdev_notifier);
}
void ndisc_late_cleanup(void)
{ {
unregister_netdevice_notifier(&ndisc_netdev_notifier); unregister_netdevice_notifier(&ndisc_netdev_notifier);
}
void ndisc_cleanup(void)
{
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
neigh_sysctl_unregister(&nd_tbl.parms); neigh_sysctl_unregister(&nd_tbl.parms);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment