diff mbox

ipv6: why disable ipv6 on last address removal?

Message ID 20091208192046.GA5649@midget.suse.cz
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Jiri Bohac Dec. 8, 2009, 7:20 p.m. UTC
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:


Thanks,

Comments

David Miller Dec. 8, 2009, 8:56 p.m. UTC | #1
From: Jiri Bohac <jbohac@suse.cz>
Date: Tue, 8 Dec 2009 20:20:46 +0100

> Is there any reason why inet6_addr_del needs 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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Bohac Dec. 9, 2009, 7:18 a.m. UTC | #2
On Tue, Dec 08, 2009 at 12:56:11PM -0800, David Miller wrote:
> From: Jiri Bohac <jbohac@suse.cz>
> > Is there any reason why inet6_addr_del needs 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,
YOSHIFUJI Hideaki / 吉藤英明 Dec. 9, 2009, 7:39 a.m. UTC | #3
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

David Miller wrote:
> From: Jiri Bohac <jbohac@suse.cz>
> Date: Tue, 8 Dec 2009 20:20:46 +0100
> 
>> Is there any reason why inet6_addr_del needs 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.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 5, 2010, 6:44 a.m. UTC | #4
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Date: Wed, 09 Dec 2009 16:39:15 +0900

> 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.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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;
 		}
 	}