Skip to contentSkip to conversation

: Do not set IF_READY if device is down

IPV6 Applied David Woodhouse 3 participants 4 messages Mar 27, 2007 – Mar 28, 2007 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 8 lines · Linux Kernel Mailing List
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c7ababbdc647e67e953d153ddf62cbdc9fe3297e
Commit:     c7ababbdc647e67e953d153ddf62cbdc9fe3297e
Parent:     16bec31db751030171b31d7767fa3a5bdbe980ea
Author:     Herbert Xu <[email protected]>
AuthorDate: Wed Mar 7 16:02:40 2007 -0800
Committer:  David S. Miller <[email protected]>
CommitDate: Wed Mar 7 16:08:12 2007 -0800
Quoted 8 lines

[IPV6]: Do not set IF_READY if device is down

Now that we add the IPv6 device at registration time we don't need to set IF_READY in ipv6_add_dev anymore because we will always get a NETDEV_UP event later on should the device ever become ready.

This commit seems to have broken NetworkManager, which removes the link-local IPv6 address from each wireless interface while it's only intending to use it for scanning, then adds it back when it actually wants to _use_ the interface in question.

After this commit, any IPv6 address added to an interface which had none will be marked as 'tentative', and will never become real.

A failing test looks like this....

+ ip -6 addr del fe80::203:ccff:fe3c:27d/64 dev eth0
+ ip -6 addr del 2001:8b0:10b:1:203:ccff:fe3c:27d/64 dev eth0
+ ip -6 addr list eth0
+ ip -6 addr add fe80::203:ccff:fe3c:27d/64 dev eth0
+ ip -6 addr list eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 fe80::203:ccff:fe3c:27d/64 scope link tentative
valid_lft forever preferred_lft forever
+ sleep 3
+ ip -6 addr list eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 fe80::203:ccff:fe3c:27d/64 scope link tentative
valid_lft forever preferred_lft forever

... while on a good kernel it looks like this...

+ ip -6 addr del fe80::203:ccff:fe3c:27d/64 dev eth0
+ ip -6 addr del 2001:8b0:10b:1:203:ccff:fe3c:27d/64 dev eth0
+ ip -6 addr list eth0
+ ip -6 addr add fe80::203:ccff:fe3c:27d/64 dev eth0
+ ip -6 addr list eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 fe80::203:ccff:fe3c:27d/64 scope link tentative
valid_lft forever preferred_lft forever
+ sleep 3
+ ip -6 addr list eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 2001:8b0:10b:1:203:ccff:fe3c:27d/64 scope global dynamic
valid_lft 298sec preferred_lft 118sec
inet6 fe80::203:ccff:fe3c:27d/64 scope link
valid_lft forever preferred_lft forever

If I add an extra IPv6 address before running the script on a 'bad' kernel, it behaves correctly. The problem only happens when you remove _all_ IPv6 addresses from an interface.

Answers of "don't do that then" should be accompanied with an alternative plan which allows NetworkManager to use a wireless device for scanning without actually having any other effect.

Signature · 1 line
dwmw2
#2 lore raw
Quoted 7 lines · David Woodhouse
Quoted 7 lines

[IPV6]: Do not set IF_READY if device is down

Now that we add the IPv6 device at registration time we don't need to set IF_READY in ipv6_add_dev anymore because we will always get a NETDEV_UP event later on should the device ever become ready.

Quoted 7 lines
Quoted 2 lines

This commit seems to have broken NetworkManager, which removes the link-local IPv6 address from each wireless interface while it's only intending to use it for scanning, then adds it back when it actually wants to _use_ the interface in question.

Sorry, that patch is indeed broken. We do need to set IF_READY in the case where all addresses were deleted (including the link-local) and then recreated. The IPv6 device will be destroyed and recreated too in that case.

[IPV6]: Set IF_READY if the device is up and has carrier

We still need to set the IF_READY flag in ipv6_add_dev for the case where all addresses (including the link-local) are deleted and then recreated. In that case the IPv6 device too will be destroyed and then recreated.

In order to prevent the original problem, we simply ensure that the device is up before setting IF_READY.

Cheers,

Signature · 5 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
net/ipv6/addrconf.c +3 -0
index 1b61699..7552663 100644
@@ -342,6 +342,9 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
 	}
 #endif
 
+	if (netif_running(dev) && netif_carrier_ok(dev))
+		ndev->if_flags |= IF_READY;
+
 	ipv6_mc_init_dev(ndev);
 	ndev->tstamp = jiffies;
 #ifdef CONFIG_SYSCTL
maintainer Applied
#3 lore raw

From: Herbert Xu <[email protected]>
Date: Wed, 28 Mar 2007 07:30:32 +1000

Quoted 28 lines · David Woodhouse
Quoted 7 lines
Quoted 7 lines

[IPV6]: Do not set IF_READY if device is down

Now that we add the IPv6 device at registration time we don't need to set IF_READY in ipv6_add_dev anymore because we will always get a NETDEV_UP event later on should the device ever become ready.

Quoted 7 lines
Quoted 2 lines

This commit seems to have broken NetworkManager, which removes the link-local IPv6 address from each wireless interface while it's only intending to use it for scanning, then adds it back when it actually wants to _use_ the interface in question.

Sorry, that patch is indeed broken. We do need to set IF_READY in the case where all addresses were deleted (including the link-local) and then recreated. The IPv6 device will be destroyed and recreated too in that case.

[IPV6]: Set IF_READY if the device is up and has carrier

We still need to set the IF_READY flag in ipv6_add_dev for the case where all addresses (including the link-local) are deleted and then recreated. In that case the IPv6 device too will be destroyed and then recreated.

Quoted 4 lines

In order to prevent the original problem, we simply ensure that the device is up before setting IF_READY.

Applied, thanks Herbert.

I'll make sure to push this to the relevant -stable places.

#4 lore raw
In reply to Herbert Xu
Quoted 4 lines · Herbert Xu

Sorry, that patch is indeed broken. We do need to set IF_READY in the case where all addresses were deleted (including the link-local) and then recreated. The IPv6 device will be destroyed and recreated too in that case.

Your new patch fixes the problem for me, at least with my test script. Thanks.

Signature · 1 line
dwmw2