[PATCH] IPv6: Fix incorrect disable_ipv6 behavior

Previous thread: [PATCH 13/13] forcedeth: version bump to 64 by Ayaz Abdulla on Thursday, March 5, 2009 - 11:02 am. (2 messages)

Next thread: [PATCH] macvlan: Support creating macvlans from macvlans by Eric W. Biederman on Thursday, March 5, 2009 - 4:12 pm. (16 messages)
From: Brian Haley
Date: Thursday, March 5, 2009 - 3:28 pm

It doesn't look like the disable_ipv6 devconf setting works
as described in ip-sysctl.txt.  I think it was originally
designed to only be set by addrconf_dad_failure(), but since
it's mode 0644 it can be controlled through sysctl -w.

Here's an example:

# sysctl -w net.ipv6.conf.eth0.disable_ipv6=1
net.ipv6.conf.eth0.disable_ipv6 = 1
# sysctl -w net.ipv6.conf.eth0.accept_dad=2
net.ipv6.conf.eth0.accept_dad = 2

# ifdown eth0
# ifup eth0

Mar  5 11:23:45 titan kernel: eth0: duplicate address detected!

# ip -6 a show dev eth0
5: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 fe80::21f:29ff:fe5a:ef04/64 scope link tentative
       valid_lft forever preferred_lft forever

The address didn't actually fail DAD, but since disable_ipv6
was set, addrconf_dad_timer() called addrconf_dad_failure()
before checking if it succeeded.

The following patch fixes the behavior.  The other option is
to make this value read-only, but disable_ipv6 can be useful.

---

Fix the behavior of allowing both sysctl and addrconf_dad_failure()
to set the disable_ipv6 parameter without any bad side-effects.
If DAD fails and accept_dad > 1, we will still set disable_ipv6=1,
but then instead of allowing an RA to add an address then
immediately fail DAD, we simply don't allow the address to be
added in the first place.  This also lets the user set this flag
and disable all IPv6 addresses on the interface, or on the entire
system.


Signed-off-by: Brian Haley <brian.haley@hp.com>
---
 Documentation/networking/ip-sysctl.txt |    4 +++-
 net/ipv6/addrconf.c                    |   21 ++++++++++++++-------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 7185e4c..ec5de02 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -1043,7 +1043,9 @@ max_addresses - INTEGER
 	Default: 16
 
 disable_ipv6 - BOOLEAN
-	Disable IPv6 ...
From: Brian Haley
Date: Friday, March 13, 2009 - 5:52 pm

So I haven't seen an Ack/Nack for this patch, and the patchwork queue has shrunk
to just a handful in the past few hours :)

-Brian
--

From: David Miller
Date: Friday, March 13, 2009 - 7:24 pm

From: Brian Haley <brian.haley@hp.com>

It's near the top of my queue, I'm just debating what tree
to stick it into.

Probably I'll put it into net-next-2.6
--

From: David Miller
Date: Wednesday, March 18, 2009 - 6:23 pm

From: Brian Haley <brian.haley@hp.com>

Applied to net-next-2.6, thanks!
--

Previous thread: [PATCH 13/13] forcedeth: version bump to 64 by Ayaz Abdulla on Thursday, March 5, 2009 - 11:02 am. (2 messages)

Next thread: [PATCH] macvlan: Support creating macvlans from macvlans by Eric W. Biederman on Thursday, March 5, 2009 - 4:12 pm. (16 messages)