public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipv6: slightly simplify keeping IPv6 addresses on link down
@ 2010-11-26 18:06 Lorenzo Colitti
  2010-12-01 19:01 ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Colitti @ 2010-11-26 18:06 UTC (permalink / raw)
  To: netdev

ipv6: slightly simplify keeping IPv6 addresses on link down

When link goes down, all statically-configured (i.e.,
permanent and not link-local) IPv6 addresses are kept on
the interface. Instead of moving addresses to a temporary
keep list and then splicing that back on to the interface
address list, use list_for_each_entry_safe and delete the
ones we don't want.

Tested by configuring two static addresses on an interface
and verifying that pings from the addresses keep working
when bringing link down and up again and when disabling and
re-enabling IPv6 on the interface.

Signed-off-by: Lorenzo Colitti <lorenzo@google.com>

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 23cc8e1..6dfd5c5 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2663,8 +2663,7 @@ static int addrconf_ifdown(struct net_device
*dev, int how)
 {
 	struct net *net = dev_net(dev);
 	struct inet6_dev *idev;
-	struct inet6_ifaddr *ifa;
-	LIST_HEAD(keep_list);
+	struct inet6_ifaddr *ifa, *ifn;
 	int state;

 	ASSERT_RTNL();
@@ -2719,9 +2718,7 @@ static int addrconf_ifdown(struct net_device
*dev, int how)
 	}
 #endif

-	while (!list_empty(&idev->addr_list)) {
-		ifa = list_first_entry(&idev->addr_list,
-				       struct inet6_ifaddr, if_list);
+	list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) {
 		addrconf_del_timer(ifa);

 		/* If just doing link down, and address is permanent
@@ -2729,15 +2726,13 @@ static int addrconf_ifdown(struct net_device
*dev, int how)
 		if (!how &&
 		    (ifa->flags&IFA_F_PERMANENT) &&
 		    !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {
-			list_move_tail(&ifa->if_list, &keep_list);
-
 			/* If not doing DAD on this address, just keep it. */
 			if ((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) ||
 			    idev->cnf.accept_dad <= 0 ||
 			    (ifa->flags & IFA_F_NODAD))
 				continue;

-			/* If it was tentative already, no need to notify */
+			/* If it was tentative already, no need to do anything */
 			if (ifa->flags & IFA_F_TENTATIVE)
 				continue;

@@ -2769,8 +2764,6 @@ static int addrconf_ifdown(struct net_device
*dev, int how)
 		}
 	}

-	list_splice(&keep_list, &idev->addr_list);
-
 	write_unlock_bh(&idev->lock);

 	/* Step 5: Discard multicast list */

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-12-10 23:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-26 18:06 [PATCH] ipv6: slightly simplify keeping IPv6 addresses on link down Lorenzo Colitti
2010-12-01 19:01 ` David Miller
2010-12-01 19:38   ` Lorenzo Colitti
2010-12-01 20:22     ` Stephen Hemminger
2010-12-01 20:52       ` Lorenzo Colitti
2010-12-01 21:04         ` Stephen Hemminger
2010-12-10 20:43           ` David Miller
2010-12-10 23:00             ` Lorenzo Colitti
2010-12-01 20:54       ` Lorenzo Colitti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox