IPv6 /127 address
Subsystems (3)
There is a new RFC out for supporting /127 addresses for router interconnect and point-to-point links.
Right now the kernel gets confused by the /127 and doesn't disable the anycast address. Any ideas?
http://tools.ietf.org/html/rfc6164
http://lists.debian.org/debian-ipv6/2011/05/msg00018.html
PATCH 1/1 Disable router anycast address for /127 prefixes
RFC 6164 requires that routers MUST disable Subnet-Router anycast for the prefix when /127 prefixes are used.
---
How about something like this?
net/ipv6/addrconf.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
net/ipv6/addrconf.c +4 -0
@@ -1470,6 +1470,8 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)static void addrconf_join_anycast (struct inet6_ifaddr *ifp) {struct in6_addr addr; +if (ifp->prefix_len ==127 )/* RFC 6164 */ +return ;ipv6_addr_prefix (&addr, &ifp->addr, ifp->prefix_len);if (ipv6_addr_any (&addr))return ;
@@ -1479,6 +1481,8 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)static void addrconf_leave_anycast (struct inet6_ifaddr *ifp) {struct in6_addr addr; +if (ifp->prefix_len ==127 )/* RFC 6164 */ +return ;ipv6_addr_prefix (&addr, &ifp->addr, ifp->prefix_len);if (ipv6_addr_any (&addr))return ;
Signature · 1 line
1.7.2.5
Re: [PATCH] Disable router anycast address for /127 prefixes
Quoted 7 lines · Bjørn Mork
RFC 6164 requires that routers MUST disable Subnet-Router anycast for the prefix when /127 prefixes are used.
Signed-off-by Bjørn Mork <[email protected]>---
net/ipv6/addrconf.c static void addrconf_join_anycast(struct inet6_ifaddr *ifp) · line 1488
Quoted 8 lines
net/ipv6/addrconf.c +2
-0@@ -1479,6 +1481,8 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)static void addrconf_leave_anycast (struct inet6_ifaddr *ifp) {struct in6_addr addr; +if (ifp->prefix_len ==127 )/* RFC 6164 */ +return ;ipv6_addr_prefix (&addr, &ifp->addr, ifp->prefix_len);if (ipv6_addr_any (&addr))return ;
I'm not sure you'd need this part as there shouldn't be a /127 in the list to remove.
-Brian
Re: [PATCH] Disable router anycast address for /127 prefixes
Quoted 7 lines · Brian Haley
Quoted 5 lines · Bjørn Mork
RFC 6164 requires that routers MUST disable Subnet-Router anycast for the prefix when /127 prefixes are used.
Signed-off-by Bjørn Mork <[email protected]>---
Quoted 11 lines
net/ipv6/addrconf.c static void addrconf_join_anycast(struct inet6_ifaddr *ifp) · line 1488
Quoted 9 lines
net/ipv6/addrconf.c +2
-0@@ -1479,6 +1481,8 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)static void addrconf_leave_anycast (struct inet6_ifaddr *ifp) {struct in6_addr addr; +if (ifp->prefix_len ==127 )/* RFC 6164 */ +return ;ipv6_addr_prefix (&addr, &ifp->addr, ifp->prefix_len);if (ipv6_addr_any (&addr))return ;I'm not sure you'd need this part as there shouldn't be a /127 in the list to remove.
I don't understand exactly what you mean here....
The addrconf_{join,leave}_anycast() functions are definitely called regardless of prefix length, including both 127 and 128. The latter is not a problem because it is handled by ipv6_addr_prefix(). But /127 prefixes are not handled according to RFC 6164.
Just to be sure I didn't miss something, I added a simple printk to the beginning of addrconf_{join,leave}_anycast():
printk(KERN_INFO "%s(): ifp->prefix_len=%d\n", __FUNCTION__, ifp->prefix_len);
and got this as expected after doing
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
[ 73.710174] addrconf_join_anycast(): ifp->prefix_len=128 [ 73.712879] addrconf_join_anycast(): ifp->prefix_len=64 [ 73.716799] addrconf_join_anycast(): ifp->prefix_len=64 [ 73.719798] addrconf_join_anycast(): ifp->prefix_len=64
Notice the /128 prefix, which is the loopback address.
Adding a new interface, and setting a /127 on it:
ifconfig dummy0 up
[ 134.434901] addrconf_join_anycast(): ifp->prefix_len=64
ip addr add 2001:db8:f00::3/127 dev dummy0
[ 198.292972] addrconf_join_anycast(): ifp->prefix_len=127
And verifying that it actually answers the anycast address (which is the problem since that is supposed to be the other end of the point-to-point link):
frtest1:~# ping6 2001:db8:f00::2 PING 2001:db8:f00::2(2001:db8:f00::2) 56 data bytes 64 bytes from 2001:db8:f00::3: icmp_seq=1 ttl=64 time=0.035 ms 64 bytes from 2001:db8:f00::3: icmp_seq=2 ttl=64 time=0.049 ms 64 bytes from 2001:db8:f00::3: icmp_seq=3 ttl=64 time=0.039 ms ^C --- 2001:db8:f00::2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 1998ms rtt min/avg/max/mdev = 0.035/0.041/0.049/0.005 ms
Disabling forwarding again:
echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
[ 247.281543] addrconf_leave_anycast(): ifp->prefix_len=128 [ 247.284220] addrconf_leave_anycast(): ifp->prefix_len=64 [ 247.287959] addrconf_leave_anycast(): ifp->prefix_len=64 [ 247.290178] addrconf_leave_anycast(): ifp->prefix_len=64 [ 247.293390] addrconf_leave_anycast(): ifp->prefix_len=127 [ 247.295476] addrconf_leave_anycast(): ifp->prefix_len=64
With the patch, we still get anycast addresses for the shorter prefix lengths, but not for /127 prefixes:
frtest1:~# echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
frtest1:~# ifconfig dummy0 up
frtest1:~#
frtest1:~# ip addr add 2001:db8:f00::3/127 dev dummy0
frtest1:~# ip -6 addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 fe80::5054:ff:feff:100/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 2001:4620:9:29a:5054:ff:feff:106/64 scope global dynamic
valid_lft 86356sec preferred_lft 14356sec
inet6 fe80::5054:ff:feff:106/64 scope link
valid_lft forever preferred_lft forever
4: dummy0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500
inet6 2001:db8:f00::3/127 scope global
valid_lft forever preferred_lft forever
inet6 fe80::d8b4:bcff:fe81:172/64 scope link
valid_lft forever preferred_lft forever
frtest1:~# ping6 2001:4620:9:29a::
PING 2001:4620:9:29a::(2001:4620:9:29a::) 56 data bytes
64 bytes from 2001:4620:9:29a:5054:ff:feff:106: icmp_seq=1 ttl=64 time=0.032 ms
64 bytes from 2001:4620:9:29a:5054:ff:feff:106: icmp_seq=2 ttl=64 time=0.040 ms
^C
--- 2001:4620:9:29a:: ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.032/0.036/0.040/0.004 ms
frtest1:~# ping6 2001:db8:f00::2
PING 2001:db8:f00::2(2001:db8:f00::2) 56 data bytes
^C
--- 2001:db8:f00::2 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1008msBjørn
Re: [PATCH] Disable router anycast address for /127 prefixes
Quoted 20 lines · Bjørn Mork
Quoted 7 lines · Brian Haley
Quoted 5 lines · Bjørn Mork
RFC 6164 requires that routers MUST disable Subnet-Router anycast for the prefix when /127 prefixes are used.
Signed-off-by Bjørn Mork <[email protected]>---
Quoted 11 lines
net/ipv6/addrconf.c static void addrconf_join_anycast(struct inet6_ifaddr *ifp) · line 1488
Quoted 9 lines
net/ipv6/addrconf.c +2
-0@@ -1479,6 +1481,8 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)static void addrconf_leave_anycast (struct inet6_ifaddr *ifp) {struct in6_addr addr; +if (ifp->prefix_len ==127 )/* RFC 6164 */ +return ;ipv6_addr_prefix (&addr, &ifp->addr, ifp->prefix_len);if (ipv6_addr_any (&addr))return ;I'm not sure you'd need this part as there shouldn't be a /127 in the list to remove.
Quoted 1 line
I don't understand exactly what you mean here....
If you never add an anycast address when the prefix length is 127, the address wouldn't be there when you went to remove it. In other words, the call to __ipv6_dev_ac_dec() would return -ENOENT, which is ignored anyways.
It's not a common codepath so the two lines of code wouldn't hurt anything I guess...
-Brian
Re: [PATCH] Disable router anycast address for /127 prefixes
Quoted 10 lines · Brian Haley
Quoted 5 lines · Bjørn Mork
Quoted 1 line · Brian Haley
I'm not sure you'd need this part as there shouldn't be a /127 in the list to remove.
I don't understand exactly what you mean here....
If you never add an anycast address when the prefix length is 127, the address wouldn't be there when you went to remove it. In other words, the call to
__ipv6_dev_ac_dec()would return-ENOENT, which is ignored anyways.
Doh! Of course. Sorry for being that slow...
And thanks for taking the time to feed it to me with a small enough spoon :-)
Quoted 2 lines
It's not a common codepath so the two lines of code wouldn't hurt anything I guess...
Personally I prefer "symmetric" coding because it leaves fewer questions unanswered (necessary for the slow among us, as demonstrated above).
But I think that's for those actually maintaining this code to decide. I can post an updated patch if required, or feel free to apply only the first hunk.
Bjørn
PATCH v2 1/1 Disable router anycast address for /127 prefixes
RFC 6164 requires that routers MUST disable Subnet-Router anycast for the prefix when /127 prefixes are used.
No need for matching code in addrconf_leave_anycast() as it will silently ignore any attempt to leave an unknown anycast address.
---
Changes since v1:
* removed unneeded change based on review comments from Brian Haley
Thought a bit more about this and found that adding less code makes more sense, given that the meaning is clear enough. But I really don't have any strong meanings about this. Please apply either version 1 or version 2 depending on your preferences.
Bjørn
net/ipv6/addrconf.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
net/ipv6/addrconf.c +2 -0
@@ -1470,6 +1470,8 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)static void addrconf_join_anycast (struct inet6_ifaddr *ifp) {struct in6_addr addr; +if (ifp->prefix_len ==127 )/* RFC 6164 */ +return ;ipv6_addr_prefix (&addr, &ifp->addr, ifp->prefix_len);if (ipv6_addr_any (&addr))return ;
Signature · 1 line
1.7.2.5
Re: [PATCH v2] Disable router anycast address for /127 prefixes
From: Bjørn Mork <[email protected]>
Date: Wed, 6 Jul 2011 11:04:13 +0200
Quoted 8 lines
RFC 6164 requires that routers MUST disable Subnet-Router anycast for the prefix when /127 prefixes are used.
No need for matching code in
addrconf_leave_anycast()as it will silently ignore any attempt to leave an unknown anycast address.Signed-off-by Bjørn Mork <[email protected]>
Applied to net-next-2.6, thanks.