From 251c42ccf529c550d11d3390099fb672ed89a531 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 13 Jan 2004 00:36:35 -0800 Subject: [PATCH] [IPV6]: Notifier replay changes Change IPV6 to handle the new case where netdev events are replayed on registration: * change code ordering so address configuration is ready before registration (this was actually a bug in existing code) * take out code that capture's existing devices, this is now done in the replay * make notifier code local to addrconf.c so it can be have smaller scope --- include/net/addrconf.h | 4 ---- include/net/ipv6.h | 4 ---- net/ipv6/addrconf.c | 43 +++++++++++++--------------------------- net/ipv6/af_inet6.c | 2 -- net/ipv6/ipv6_sockglue.c | 18 ----------------- 5 files changed, 14 insertions(+), 57 deletions(-) diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 2537a6fc4bc08..54fd7773f5b15 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h @@ -50,10 +50,6 @@ struct prefix_info { extern void addrconf_init(void); extern void addrconf_cleanup(void); -extern int addrconf_notify(struct notifier_block *this, - unsigned long event, - void * data); - extern int addrconf_add_ifaddr(void *arg); extern int addrconf_del_ifaddr(void *arg); extern int addrconf_set_dstaddr(void *arg); diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 6ac444968292e..1ad89018e99b3 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -401,12 +401,8 @@ extern int ipv6_getsockopt(struct sock *sk, int level, extern void ipv6_packet_init(void); -extern void ipv6_netdev_notif_init(void); - extern void ipv6_packet_cleanup(void); -extern void ipv6_netdev_notif_cleanup(void); - extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len); extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port, u32 info, u8 *payload); diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 17e1346baaff9..b614c23b0e14c 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1858,8 +1858,8 @@ static void addrconf_ip6_tnl_config(struct net_device *dev) addrconf_add_mroute(dev); } -int addrconf_notify(struct notifier_block *this, unsigned long event, - void * data) +static int addrconf_notify(struct notifier_block *this, unsigned long event, + void * data) { struct net_device *dev = (struct net_device *) data; struct inet6_dev *idev = __in6_dev_get(dev); @@ -1931,6 +1931,14 @@ int addrconf_notify(struct notifier_block *this, unsigned long event, return NOTIFY_OK; } +/* + * addrconf module should be notified of a device going up + */ +static struct notifier_block ipv6_dev_notf = { + .notifier_call = addrconf_notify, + .priority = 0 +}; + static int addrconf_ifdown(struct net_device *dev, int how) { struct inet6_dev *idev; @@ -3179,9 +3187,7 @@ int unregister_inet6addr_notifier(struct notifier_block *nb) void __init addrconf_init(void) { -#ifdef MODULE - struct net_device *dev; -#endif + register_netdevice_notifier(&ipv6_dev_notf); #ifdef CONFIG_IPV6_PRIVACY md5_tfm = crypto_alloc_tfm("md5", 0); @@ -3190,30 +3196,6 @@ void __init addrconf_init(void) "failed to load transform for md5\n"); #endif -#ifdef MODULE - /* This takes sense only during module load. */ - rtnl_lock(); - for (dev = dev_base; dev; dev = dev->next) { - if (!(dev->flags&IFF_UP)) - continue; - - switch (dev->type) { - case ARPHRD_LOOPBACK: - init_loopback(dev); - break; - case ARPHRD_ETHER: - case ARPHRD_FDDI: - case ARPHRD_IEEE802_TR: - case ARPHRD_ARCNET: - addrconf_dev_config(dev); - break; - default:; - /* Ignore all other */ - } - } - rtnl_unlock(); -#endif - addrconf_verify(0); rtnetlink_links[PF_INET6] = inet6_rtnetlink_table; #ifdef CONFIG_SYSCTL @@ -3231,6 +3213,8 @@ void addrconf_cleanup(void) struct inet6_ifaddr *ifa; int i; + unregister_netdevice_notifier(&ipv6_dev_notf); + rtnetlink_links[PF_INET6] = NULL; #ifdef CONFIG_SYSCTL addrconf_sysctl_unregister(&ipv6_devconf_dflt); @@ -3284,3 +3268,4 @@ void addrconf_cleanup(void) #endif } #endif /* MODULE */ + diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index df60b4030a44d..6d450f2909e91 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -802,7 +802,6 @@ static int __init inet6_init(void) if (if6_proc_init()) goto proc_if6_fail; #endif - ipv6_netdev_notif_init(); ipv6_packet_init(); ip6_route_init(); ip6_flowlabel_init(); @@ -869,7 +868,6 @@ static void inet6_exit(void) #endif /* Cleanup code parts. */ sit_cleanup(); - ipv6_netdev_notif_cleanup(); ip6_flowlabel_cleanup(); addrconf_cleanup(); ip6_route_cleanup(); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 505abe0809de9..c9aa51f318b3e 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -62,14 +62,6 @@ static struct packet_type ipv6_packet_type = { .func = ipv6_rcv, }; -/* - * addrconf module should be notified of a device going up - */ -static struct notifier_block ipv6_dev_notf = { - .notifier_call = addrconf_notify, - .priority = 0 -}; - struct ip6_ra_chain *ip6_ra_chain; rwlock_t ip6_ra_lock = RW_LOCK_UNLOCKED; @@ -707,19 +699,9 @@ void __init ipv6_packet_init(void) dev_add_pack(&ipv6_packet_type); } -void __init ipv6_netdev_notif_init(void) -{ - register_netdevice_notifier(&ipv6_dev_notf); -} - #ifdef MODULE void ipv6_packet_cleanup(void) { dev_remove_pack(&ipv6_packet_type); } - -void ipv6_netdev_notif_cleanup(void) -{ - unregister_netdevice_notifier(&ipv6_dev_notf); -} #endif -- 2.53.0