ipv6: why disable ipv6 on last address removal?
Subsystems (3)
Hi,
I came across a strange behaviour:
When the last IPv6 address of an interface is removed (using e.g. "ip -6 addr flush ethX"), inet6_addr_del() calls addrconf_ifdown(... , how=1).
This completely removes IPv6 from the interface. (The same thing is done e.g. on NETDEV_UNREGISTER). An ugly side effect of this is that it is no longer possible to set the interface IPv6 settings using sysctl. The only way to make the sysctl settings accessible again seems to be taking the interface down and up.
This is a nightmare for management scripts.
Most other actions, such as NETDEV_DOWN, call addrconf_ifdown(..., how=0), which keeps the sysctl settings available.
Is there any reason why inet6_addr_del needs to sets how=1 and disable IPv6 even more than "ifconfig down" does?
I quickly tested this patch and it did not seem to break anything:
net/ipv6/addrconf.c +1 -1
@@ -2185,7 +2185,7 @@ static int inet6_addr_del(struct net *net, int ifindex, struct in6_addr *pfx,disable IPv6 on this interface. */ if (idev->addr_list ==NULL ) -addrconf_ifdown (idev->dev,1 ); +addrconf_ifdown (idev->dev,0 );return 0 ; } }
Thanks,
Signature · 2 lines
Jiri Bohac <[email protected]> SUSE Labs, SUSE CZ
David Miller
maintainerFrom: Jiri Bohac <[email protected]>
Date: Tue, 8 Dec 2009 20:20:46 +0100
Quoted 2 lines
Is there any reason why
inet6_addr_delneeds to sets how=1 and disable IPv6 even more than "ifconfig down" does?
All I can say is that this behavior is definitely on purpose, although I don't exactly remember why.
And although it helps you, it could also break things for other people who expect the current behavior.
Some people definitely expect no IPV6 at all in any way shape or form if they have not assigned IPV6 addresses to an interface.
Quoted 9 lines · David Miller
From: Jiri Bohac <[email protected]>
Quoted 2 lines
Is there any reason why
inet6_addr_delneeds to sets how=1 and disable IPv6 even more than "ifconfig down" does?All I can say is that this behavior is definitely on purpose, although I don't exactly remember why.
Some people definitely expect no IPV6 at all in any way shape or form if they have not assigned IPV6 addresses to an interface.
Sure, even with how=0, IPv6 is about as much disabled as when the interface is down. The problem is that the current behaviour goes like this:
#1 modprobe driver_for_eth0
#2 sysctl net.ipv6.conf.tun0.aaaaaaa=b
#3 ip link set up dev eth0
#4 ip addr add xxx/yy dev eth0
#5 ip addr flush dev eth0
#6 ip link set down dev eth0
#7 ip link set up dev eth0
#5 turns IPv6 off even deeper that it was after #1, losing the settings made in #2.
To re-configure the settings from #2, you need to do:
#6, #7, [#6 again for some sysctl settings], #2
I think it would probably be ok for #5 to turn off IPv6 to the state you get with #6.
Thanks,
Signature · 2 lines
Jiri Bohac <[email protected]> SUSE Labs, SUSE CZ
Hello.
Well, AFAIK, it is basically ancient thing. Some (rather new) paramters are exactly related bringing up each interface.
Such parameters should be set _before_ it is brought up. For now, people can do this using the "default" value.
We might have rtnetlink interface for up/down interface, allowing userspace to send related parameters as well.
Regards,
--yoshfuji
Quoted 14 lines · David Miller
From: Jiri Bohac <[email protected]>
Date: Tue, 8 Dec 2009 20:20:46 +0100Quoted 2 lines
Is there any reason why
inet6_addr_delneeds to sets how=1 and disable IPv6 even more than "ifconfig down" does?All I can say is that this behavior is definitely on purpose, although I don't exactly remember why.
And although it helps you, it could also break things for other people who expect the current behavior.
Some people definitely expect no IPV6 at all in any way shape or form if they have not assigned IPV6 addresses to an interface.
David Miller
maintainerFrom: YOSHIFUJI Hideaki <[email protected]>
Date: Wed, 09 Dec 2009 16:39:15 +0900
Quoted 6 lines
Well, AFAIK, it is basically ancient thing. Some (rather new) paramters are exactly related bringing up each interface.
Such parameters should be set _before_ it is brought up. For now, people can do this using the "default" value.
I think we should retain inet6 device private structure after we allocate it the first time that an ipv6 action occurs for the device, exactly so that settings made earlier can be retained.
Quoted 7 lines · David Miller
From: YOSHIFUJI Hideaki <[email protected]>
Date: Wed, 09 Dec 2009 16:39:15 +0900Quoted 4 lines
Well, AFAIK, it is basically ancient thing. Some (rather new) paramters are exactly related bringing up each interface.
Quoted 7 lines
Quoted 2 lines
Such parameters should be set _before_ it is brought up. For now, people can do this using the "default" value.
I think we should retain inet6 device private structure after we allocate it the first time that an ipv6 action occurs for the device, exactly so that settings made earlier can be retained.
Good, this was what my patch is doing. I still think this is as simple as:
net/ipv6/addrconf.c +1 -1
@@ -2185,7 +2185,7 @@ static int inet6_addr_del(struct net *net, int ifindex, struct in6_addr *pfx,disable IPv6 on this interface. */ if (idev->addr_list ==NULL ) -addrconf_ifdown (idev->dev,1 ); +addrconf_ifdown (idev->dev,0 );return 0 ; } }
It does the same thing as NETDEV_DOWN down instead of the current NETDEV_UNREGISTER-like behaviour. Could this perhaps be tried in -next?
Thanks,
Signature · 2 lines
Jiri Bohac <[email protected]> SUSE Labs, SUSE CZ
What about this? It will remove the address on ipv6 disable.
net/ipv6/addrconf.c +1 -1
@@ -4197,7 +4197,7 @@ static void dev_disable_change(struct inreturn ;if (idev->cnf.disable_ipv6) -addrconf_notify (NULL ,NETDEV_DOWN , idev->dev); +addrconf_notify (NULL ,NETDEV_UNREGISTER , idev->dev);else addrconf_notify (NULL ,NETDEV_UP , idev->dev); }