Commit 84e8b803 authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

IPv6: addrconf notify when address is unavailable

My recent change in net-next to retain permanent addresses caused regression.
Device refcount would not go to zero when device was unregistered because
left over anycast reference would hold ipv6 dev reference which would hold
device references...

The correct procedure is to call notify chain when address is no longer
available for use.  When interface comes back DAD timer will notify
back that address is available.

Also, link local addresses should be purged when interface is brought
down. The address might be changed.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5b2a1953
...@@ -2649,11 +2649,11 @@ static int addrconf_ifdown(struct net_device *dev, int how) ...@@ -2649,11 +2649,11 @@ static int addrconf_ifdown(struct net_device *dev, int how)
write_lock_bh(&addrconf_hash_lock); write_lock_bh(&addrconf_hash_lock);
while ((ifa = *bifa) != NULL) { while ((ifa = *bifa) != NULL) {
if (ifa->idev == idev && if (ifa->idev == idev &&
(how || !(ifa->flags&IFA_F_PERMANENT))) { (how || !(ifa->flags&IFA_F_PERMANENT) ||
ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {
*bifa = ifa->lst_next; *bifa = ifa->lst_next;
ifa->lst_next = NULL; ifa->lst_next = NULL;
addrconf_del_timer(ifa); __in6_ifa_put(ifa);
in6_ifa_put(ifa);
continue; continue;
} }
bifa = &ifa->lst_next; bifa = &ifa->lst_next;
...@@ -2691,28 +2691,40 @@ static int addrconf_ifdown(struct net_device *dev, int how) ...@@ -2691,28 +2691,40 @@ static int addrconf_ifdown(struct net_device *dev, int how)
#endif #endif
bifa = &idev->addr_list; bifa = &idev->addr_list;
while ((ifa = *bifa) != NULL) { while ((ifa = *bifa) != NULL) {
if (how == 0 && (ifa->flags&IFA_F_PERMANENT)) { addrconf_del_timer(ifa);
/* Retain permanent address on admin down */
/* If just doing link down, and address is permanent
and not link-local, then retain it. */
if (how == 0 &&
(ifa->flags&IFA_F_PERMANENT) &&
!(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {
bifa = &ifa->if_next; bifa = &ifa->if_next;
/* Restart DAD if needed when link comes back up */ /* If not doing DAD on this address, just keep it. */
if ( !((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) || if ((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) ||
idev->cnf.accept_dad <= 0 || idev->cnf.accept_dad <= 0 ||
(ifa->flags & IFA_F_NODAD))) (ifa->flags & IFA_F_NODAD))
ifa->flags |= IFA_F_TENTATIVE; continue;
/* If it was tentative already, no need to notify */
if (ifa->flags & IFA_F_TENTATIVE)
continue;
/* Flag it for later restoration when link comes up */
ifa->flags |= IFA_F_TENTATIVE;
in6_ifa_hold(ifa);
} else { } else {
*bifa = ifa->if_next; *bifa = ifa->if_next;
ifa->if_next = NULL; ifa->if_next = NULL;
ifa->dead = 1; ifa->dead = 1;
write_unlock_bh(&idev->lock); }
write_unlock_bh(&idev->lock);
__ipv6_ifa_notify(RTM_DELADDR, ifa); __ipv6_ifa_notify(RTM_DELADDR, ifa);
atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa); atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
in6_ifa_put(ifa); in6_ifa_put(ifa);
write_lock_bh(&idev->lock); write_lock_bh(&idev->lock);
}
} }
write_unlock_bh(&idev->lock); write_unlock_bh(&idev->lock);
......
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