Commit 251c42cc authored by Stephen Hemminger's avatar Stephen Hemminger

[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
parent 75bfe33f
...@@ -50,10 +50,6 @@ struct prefix_info { ...@@ -50,10 +50,6 @@ struct prefix_info {
extern void addrconf_init(void); extern void addrconf_init(void);
extern void addrconf_cleanup(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_add_ifaddr(void *arg);
extern int addrconf_del_ifaddr(void *arg); extern int addrconf_del_ifaddr(void *arg);
extern int addrconf_set_dstaddr(void *arg); extern int addrconf_set_dstaddr(void *arg);
......
...@@ -401,12 +401,8 @@ extern int ipv6_getsockopt(struct sock *sk, int level, ...@@ -401,12 +401,8 @@ extern int ipv6_getsockopt(struct sock *sk, int level,
extern void ipv6_packet_init(void); extern void ipv6_packet_init(void);
extern void ipv6_netdev_notif_init(void);
extern void ipv6_packet_cleanup(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 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, extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port,
u32 info, u8 *payload); u32 info, u8 *payload);
......
...@@ -1858,8 +1858,8 @@ static void addrconf_ip6_tnl_config(struct net_device *dev) ...@@ -1858,8 +1858,8 @@ static void addrconf_ip6_tnl_config(struct net_device *dev)
addrconf_add_mroute(dev); addrconf_add_mroute(dev);
} }
int addrconf_notify(struct notifier_block *this, unsigned long event, static int addrconf_notify(struct notifier_block *this, unsigned long event,
void * data) void * data)
{ {
struct net_device *dev = (struct net_device *) data; struct net_device *dev = (struct net_device *) data;
struct inet6_dev *idev = __in6_dev_get(dev); struct inet6_dev *idev = __in6_dev_get(dev);
...@@ -1931,6 +1931,14 @@ int addrconf_notify(struct notifier_block *this, unsigned long event, ...@@ -1931,6 +1931,14 @@ int addrconf_notify(struct notifier_block *this, unsigned long event,
return NOTIFY_OK; 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) static int addrconf_ifdown(struct net_device *dev, int how)
{ {
struct inet6_dev *idev; struct inet6_dev *idev;
...@@ -3179,9 +3187,7 @@ int unregister_inet6addr_notifier(struct notifier_block *nb) ...@@ -3179,9 +3187,7 @@ int unregister_inet6addr_notifier(struct notifier_block *nb)
void __init addrconf_init(void) void __init addrconf_init(void)
{ {
#ifdef MODULE register_netdevice_notifier(&ipv6_dev_notf);
struct net_device *dev;
#endif
#ifdef CONFIG_IPV6_PRIVACY #ifdef CONFIG_IPV6_PRIVACY
md5_tfm = crypto_alloc_tfm("md5", 0); md5_tfm = crypto_alloc_tfm("md5", 0);
...@@ -3190,30 +3196,6 @@ void __init addrconf_init(void) ...@@ -3190,30 +3196,6 @@ void __init addrconf_init(void)
"failed to load transform for md5\n"); "failed to load transform for md5\n");
#endif #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); addrconf_verify(0);
rtnetlink_links[PF_INET6] = inet6_rtnetlink_table; rtnetlink_links[PF_INET6] = inet6_rtnetlink_table;
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
...@@ -3231,6 +3213,8 @@ void addrconf_cleanup(void) ...@@ -3231,6 +3213,8 @@ void addrconf_cleanup(void)
struct inet6_ifaddr *ifa; struct inet6_ifaddr *ifa;
int i; int i;
unregister_netdevice_notifier(&ipv6_dev_notf);
rtnetlink_links[PF_INET6] = NULL; rtnetlink_links[PF_INET6] = NULL;
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
addrconf_sysctl_unregister(&ipv6_devconf_dflt); addrconf_sysctl_unregister(&ipv6_devconf_dflt);
...@@ -3284,3 +3268,4 @@ void addrconf_cleanup(void) ...@@ -3284,3 +3268,4 @@ void addrconf_cleanup(void)
#endif #endif
} }
#endif /* MODULE */ #endif /* MODULE */
...@@ -802,7 +802,6 @@ static int __init inet6_init(void) ...@@ -802,7 +802,6 @@ static int __init inet6_init(void)
if (if6_proc_init()) if (if6_proc_init())
goto proc_if6_fail; goto proc_if6_fail;
#endif #endif
ipv6_netdev_notif_init();
ipv6_packet_init(); ipv6_packet_init();
ip6_route_init(); ip6_route_init();
ip6_flowlabel_init(); ip6_flowlabel_init();
...@@ -869,7 +868,6 @@ static void inet6_exit(void) ...@@ -869,7 +868,6 @@ static void inet6_exit(void)
#endif #endif
/* Cleanup code parts. */ /* Cleanup code parts. */
sit_cleanup(); sit_cleanup();
ipv6_netdev_notif_cleanup();
ip6_flowlabel_cleanup(); ip6_flowlabel_cleanup();
addrconf_cleanup(); addrconf_cleanup();
ip6_route_cleanup(); ip6_route_cleanup();
......
...@@ -62,14 +62,6 @@ static struct packet_type ipv6_packet_type = { ...@@ -62,14 +62,6 @@ static struct packet_type ipv6_packet_type = {
.func = ipv6_rcv, .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; struct ip6_ra_chain *ip6_ra_chain;
rwlock_t ip6_ra_lock = RW_LOCK_UNLOCKED; rwlock_t ip6_ra_lock = RW_LOCK_UNLOCKED;
...@@ -707,19 +699,9 @@ void __init ipv6_packet_init(void) ...@@ -707,19 +699,9 @@ void __init ipv6_packet_init(void)
dev_add_pack(&ipv6_packet_type); dev_add_pack(&ipv6_packet_type);
} }
void __init ipv6_netdev_notif_init(void)
{
register_netdevice_notifier(&ipv6_dev_notf);
}
#ifdef MODULE #ifdef MODULE
void ipv6_packet_cleanup(void) void ipv6_packet_cleanup(void)
{ {
dev_remove_pack(&ipv6_packet_type); dev_remove_pack(&ipv6_packet_type);
} }
void ipv6_netdev_notif_cleanup(void)
{
unregister_netdevice_notifier(&ipv6_dev_notf);
}
#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