All of lore.kernel.org
 help / color / mirror / Atom feed
* ipv6: why disable ipv6 on last address removal?
@ 2009-12-08 19:20 Jiri Bohac
  2009-12-08 20:56 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Bohac @ 2009-12-08 19:20 UTC (permalink / raw)
  To: netdev; +Cc: Hideaki YOSHIFUJI

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:

--- 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;
 		}
 	}

Thanks,

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ


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

* Re: ipv6: why disable ipv6 on last address removal?
  2009-12-08 19:20 ipv6: why disable ipv6 on last address removal? Jiri Bohac
@ 2009-12-08 20:56 ` David Miller
  2009-12-09  7:18   ` Jiri Bohac
  2009-12-09  7:39   ` YOSHIFUJI Hideaki
  0 siblings, 2 replies; 7+ messages in thread
From: David Miller @ 2009-12-08 20:56 UTC (permalink / raw)
  To: jbohac; +Cc: netdev, yoshfuji

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.

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

* Re: ipv6: why disable ipv6 on last address removal?
  2009-12-08 20:56 ` David Miller
@ 2009-12-09  7:18   ` Jiri Bohac
  2009-12-09  7:39   ` YOSHIFUJI Hideaki
  1 sibling, 0 replies; 7+ messages in thread
From: Jiri Bohac @ 2009-12-09  7:18 UTC (permalink / raw)
  To: David Miller; +Cc: jbohac, netdev, yoshfuji

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,

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ


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

* Re: ipv6: why disable ipv6 on last address removal?
  2009-12-08 20:56 ` David Miller
  2009-12-09  7:18   ` Jiri Bohac
@ 2009-12-09  7:39   ` YOSHIFUJI Hideaki
  2010-01-05  6:44     ` David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: YOSHIFUJI Hideaki @ 2009-12-09  7:39 UTC (permalink / raw)
  To: David Miller; +Cc: jbohac, netdev

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.


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

* Re: ipv6: why disable ipv6 on last address removal?
  2009-12-09  7:39   ` YOSHIFUJI Hideaki
@ 2010-01-05  6:44     ` David Miller
  2010-02-16 15:28       ` Jiri Bohac
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2010-01-05  6:44 UTC (permalink / raw)
  To: yoshfuji; +Cc: jbohac, netdev

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.



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

* Re: ipv6: why disable ipv6 on last address removal?
  2010-01-05  6:44     ` David Miller
@ 2010-02-16 15:28       ` Jiri Bohac
  2011-01-23  9:47         ` Stephen Hemminger
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Bohac @ 2010-02-16 15:28 UTC (permalink / raw)
  To: David Miller; +Cc: yoshfuji, jbohac, netdev

On Mon, Jan 04, 2010 at 10:44:36PM -0800, David Miller wrote:
> 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.

Good, this was what my patch is doing. I still think this is as
simple as:

--- 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;
 		}
 	}

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,

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ


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

* Re: ipv6: why disable ipv6 on last address removal?
  2010-02-16 15:28       ` Jiri Bohac
@ 2011-01-23  9:47         ` Stephen Hemminger
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2011-01-23  9:47 UTC (permalink / raw)
  To: Jiri Bohac; +Cc: David Miller, yoshfuji, netdev

What about this? It will remove the address on ipv6 disable.

--- a/net/ipv6/addrconf.c	2011-01-23 20:30:25.897243002 +1100
+++ b/net/ipv6/addrconf.c	2011-01-23 20:30:41.161243002 +1100
@@ -4197,7 +4197,7 @@ static void dev_disable_change(struct in
 		return;
 
 	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);
 }


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

end of thread, other threads:[~2011-01-23  9:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-08 19:20 ipv6: why disable ipv6 on last address removal? Jiri Bohac
2009-12-08 20:56 ` David Miller
2009-12-09  7:18   ` Jiri Bohac
2009-12-09  7:39   ` YOSHIFUJI Hideaki
2010-01-05  6:44     ` David Miller
2010-02-16 15:28       ` Jiri Bohac
2011-01-23  9:47         ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.