lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AAs7234jas72lda05laWgh1LziatUa+qSHd+6Jj+k_eO=@mail.gmail.com>
Date:	Wed, 01 Dec 2010 11:38:58 -0800
From:	Lorenzo Colitti <lorenzo@...gle.com>
To:	netdev@...r.kernel.org
Cc:	Lorenzo Colitti <lorenzo@...gle.com>,
	David Miller <davem@...emloft.net>
Subject: Re: [PATCH] ipv6: slightly simplify keeping IPv6 addresses on link down

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@...gle.com>

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6dfd5c5..23cc8e1 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2663,7 +2663,8 @@ static int addrconf_ifdown(struct net_device *dev, int how)
 {
 	struct net *net = dev_net(dev);
 	struct inet6_dev *idev;
-	struct inet6_ifaddr *ifa, *ifn;
+	struct inet6_ifaddr *ifa;
+	LIST_HEAD(keep_list);
 	int state;
 
 	ASSERT_RTNL();
@@ -2718,7 +2719,9 @@ static int addrconf_ifdown(struct net_device *dev, int how)
 	}
 #endif
 
-	list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) {
+	while (!list_empty(&idev->addr_list)) {
+		ifa = list_first_entry(&idev->addr_list,
+				       struct inet6_ifaddr, if_list);
 		addrconf_del_timer(ifa);
 
 		/* If just doing link down, and address is permanent
@@ -2726,13 +2729,15 @@ 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, don't do anything */
+			/* If it was tentative already, no need to notify */
 			if (ifa->flags & IFA_F_TENTATIVE)
 				continue;
 
@@ -2764,6 +2769,8 @@ 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 */
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ