All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields!
@ 2008-10-14 11:06 Pedro Ribeiro
  2008-10-14 12:58 ` Arnaud Ebalard
  2008-10-14 20:54 ` [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields! David Miller
  0 siblings, 2 replies; 12+ messages in thread
From: Pedro Ribeiro @ 2008-10-14 11:06 UTC (permalink / raw
  To: netdev

First, let-me say sorry for the long text, i think is needed for
context.

My name is Pedro Ribeiro and I’m the operations coordinator at
IPLNet, a network that interconnects all the schools belonging to the
Polytechnic Institute of Lisbon (IPL) and in addition I’m also a
teacher of network engineering at ISEL (a local university).

In the majority of the network segments of our infrastructure, we
have dual stack connectivity with IPv4/IPv6. In the last months, we
have upgraded most of the infrastructure, specially targeting IPv6
performance leaving most of the segments with an “old/slow router” and
a “new/fast” router as possible default gateways.
In the course of validating the changes, we have done some tests with
IPv6 and some of them were really disappointing with no gains at all.

While investigating the cause of that, I have seen that our main
Linux servers were using the “wrong” default gateway, the “old/slow”
one. This behaviour is inconsistent with the configuration of the
routers; the “new/fast” is sending the router advertisements
announcing himself as default gateway with MEDIUM (default) preference
and the “old/slow” announcing himself as LOW preference.

Deep analysis in the sources of Linux revealed that the value of
“pref” passed to rt6_add_dflt_router(...) in the file net/ipv6/route.c
isn’t consistent with the one sent by the routers and observed with
wireshark. Seeking the roots of the problem I’ve detected a bug in the
definitions of the bitfield that includes the router preference in the
router advertisement message that are resulting in retrieving the
wrong bits from the structure defined in “include/linux/icmpv6.h”. The
struct is the base one from ICMPv6 (icmp6hdr) and was lacking the bit
field “home_agent” between “router_pref” and “other” and the reserved
bits are only 3, not 4 as in the structure (according to RFC4191)

Follows a “diff” with the changes I’ve made to correct this problem
(I’ve made it against kernel 2.6.23, but I’ve confirmed that the
problem still exists in 2.6.25)

--- /usr/src/linux-2.6.23-gentoo-r9orig/include/linux/icmpv6.h      2007-10-09 21:31:38.000000000 +0100
+++ /usr/src/linux-2.6.23-gentoo-r9/include/linux/icmpv6.h      2008-10-13 17:42:56.000000000 +0100
@@ -40,16 +40,18 @@
                 struct icmpv6_nd_ra {
                        __u8            hop_limit;
 #if defined(__LITTLE_ENDIAN_BITFIELD)
-                       __u8            reserved:4,
+                       __u8            reserved:3,
                                        router_pref:2,
+                                       home_agent:1,
                                        other:1,
                                        managed:1;
 
 #elif defined(__BIG_ENDIAN_BITFIELD)
                        __u8            managed:1,
                                        other:1,
+                                       home_agent:1,
                                        router_pref:2,
-                                       reserved:4;
+                                       reserved:3;
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif

Even after this fix, the problem of deterministic and preference
aware default route selection, remains. I have not figured until now
how the preference affects the selection, maybe it is a missing
feature.

I am sorry to say it (I am not a Windows fan), but the behaviour
observed in Windows Vista is in this matter consistent with the one I
was expecting from the reading of the RFCs.

Developers on this area please clarify me this subject; does the
preference present in the RAs is supposed to influence the decision?
In addition, what is the criterion for selecting the default route in
the presence of multiple candidates with the same preference?
Best Regards to all the Linux community!

-- 
Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Pedro Ribeiro
IPLNet - Rede de dados e comunicações
Instituto Politécnico de Lisboa (IPL)
Mail: mailto:pribeiro AT net.ipl.pt
VoIP: sip:pribeiro AT net.ipl.pt
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

* Re: [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields!
  2008-10-14 11:06 [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields! Pedro Ribeiro
@ 2008-10-14 12:58 ` Arnaud Ebalard
  2008-10-14 15:32   ` Re[2]: " Pedro Ribeiro
  2008-10-14 20:07   ` [PATCH] FIXED: IPv6 Route selection now correct with multiple gateways and preferences Pedro Ribeiro
  2008-10-14 20:54 ` [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields! David Miller
  1 sibling, 2 replies; 12+ messages in thread
From: Arnaud Ebalard @ 2008-10-14 12:58 UTC (permalink / raw
  To: netdev; +Cc: Pedro Ribeiro,
	YOSHIFUJI Hideaki / 吉藤英明

Hi,

Pedro Ribeiro <pribeiro-bulk@net.ipl.pt> writes:

> Deep analysis in the sources of Linux revealed that the value of
> “pref” passed to rt6_add_dflt_router(...) in the file net/ipv6/route.c
> isn’t consistent with the one sent by the routers and observed with
> wireshark. Seeking the roots of the problem I’ve detected a bug in the
> definitions of the bitfield that includes the router preference in the
> router advertisement message that are resulting in retrieving the
> wrong bits from the structure defined in “include/linux/icmpv6.h”. The
> struct is the base one from ICMPv6 (icmp6hdr) and was lacking the bit
> field “home_agent” between “router_pref” and “other” and the reserved
> bits are only 3, not 4 as in the structure (according to RFC4191)

+1

> Follows a “diff” with the changes I’ve made to correct this problem
> (I’ve made it against kernel 2.6.23, but I’ve confirmed that the
> problem still exists in 2.6.25)
>
> --- /usr/src/linux-2.6.23-gentoo-r9orig/include/linux/icmpv6.h      2007-10-09 21:31:38.000000000 +0100
> +++ /usr/src/linux-2.6.23-gentoo-r9/include/linux/icmpv6.h      2008-10-13 17:42:56.000000000 +0100
> @@ -40,16 +40,18 @@
>                  struct icmpv6_nd_ra {
>                         __u8            hop_limit;
>  #if defined(__LITTLE_ENDIAN_BITFIELD)
> -                       __u8            reserved:4,
> +                       __u8            reserved:3,
>                                         router_pref:2,
> +                                       home_agent:1,
>                                         other:1,
>                                         managed:1;
>  
>  #elif defined(__BIG_ENDIAN_BITFIELD)
>                         __u8            managed:1,
>                                         other:1,
> +                                       home_agent:1,
>                                         router_pref:2,
> -                                       reserved:4;
> +                                       reserved:3;
>  #else
>  #error "Please fix <asm/byteorder.h>"
>  #endif

Changes look ok to me.

> Even after this fix, the problem of deterministic and preference
> aware default route selection, remains. I have not figured until now
> how the preference affects the selection, maybe it is a missing
> feature.

can you confirm that you already activated CONFIG_IPV6_ROUTER_PREF in
your kernel configuration?

What are the values of following parameters on your system?:

  /proc/sys/net/ipv6/conf/*/accept_ra_rtr_pref
  /proc/sys/net/ipv6/conf/*/accept_ra_pinfo
  /proc/sys/net/ipv6/conf/*/accept_ra
  /proc/sys/net/ipv6/conf/*/autoconf

> Developers on this area please clarify me this subject; does the
> preference present in the RAs is supposed to influence the decision?

Looking at the code in ndisc.c (ndisc_router_discovery()), it should,
but I may have missed something.

> In addition, what is the criterion for selecting the default route in
> the presence of multiple candidates with the same preference?

Don't know.

Funny it was not detected sooner. In patches I have for UMIP (userland
MIPv6 Daemon for Linux), access to router preferences field is done by
shifting bits (correctly, AFAICT) and routes are set from userspace
using that info. radvd also fills its RA that way, i.e. by shifting bits
(it uses struct nd_router_advert from netinet/icmp6.h, which does not
have anything for router preference). That would explain why I never hit
the bug.

Cheers,

a+

ps: added YOSHIFUJI Hideaki in CC.


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

* Re[2]: [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields!
  2008-10-14 12:58 ` Arnaud Ebalard
@ 2008-10-14 15:32   ` Pedro Ribeiro
  2008-10-14 20:07   ` [PATCH] FIXED: IPv6 Route selection now correct with multiple gateways and preferences Pedro Ribeiro
  1 sibling, 0 replies; 12+ messages in thread
From: Pedro Ribeiro @ 2008-10-14 15:32 UTC (permalink / raw
  To: Arnaud Ebalard
  Cc: netdev, YOSHIFUJI Hideaki / 吉藤英明

Hello Arnaud,

Thanks for your quick answer ...

Here goes the information solicited.

TIA.

Tuesday, October 14, 2008, 1:58:41 PM, you wrote:

...

> can you confirm that you already activated CONFIG_IPV6_ROUTER_PREF in
> your kernel configuration?

host ~ # gzip -d -c /proc/config.gz | grep -F CONFIG_IPV6_ROUTER_PREF
CONFIG_IPV6_ROUTER_PREF=y

> What are the values of following parameters on your system?:

>   /proc/sys/net/ipv6/conf/*/accept_ra_rtr_pref
>   /proc/sys/net/ipv6/conf/*/accept_ra_pinfo
>   /proc/sys/net/ipv6/conf/*/accept_ra
>   /proc/sys/net/ipv6/conf/*/autoconf

All of them have value "1"

/proc/sys/net/ipv6/conf/all/accept_ra:1
/proc/sys/net/ipv6/conf/all/accept_ra_defrtr:1
/proc/sys/net/ipv6/conf/all/accept_ra_pinfo:1
/proc/sys/net/ipv6/conf/all/accept_ra_rtr_pref:1
/proc/sys/net/ipv6/conf/default/accept_ra:1
/proc/sys/net/ipv6/conf/default/accept_ra_defrtr:1
/proc/sys/net/ipv6/conf/default/accept_ra_pinfo:1
/proc/sys/net/ipv6/conf/default/accept_ra_rtr_pref:1
/proc/sys/net/ipv6/conf/eth0/accept_ra:1
/proc/sys/net/ipv6/conf/eth0/accept_ra_defrtr:1
/proc/sys/net/ipv6/conf/eth0/accept_ra_pinfo:1
/proc/sys/net/ipv6/conf/eth0/accept_ra_rtr_pref:1
/proc/sys/net/ipv6/conf/lo/accept_ra:1
/proc/sys/net/ipv6/conf/lo/accept_ra_defrtr:1
/proc/sys/net/ipv6/conf/lo/accept_ra_pinfo:1
/proc/sys/net/ipv6/conf/lo/accept_ra_rtr_pref:1
/proc/sys/net/ipv6/conf/all/autoconf:1
/proc/sys/net/ipv6/conf/default/autoconf:1
/proc/sys/net/ipv6/conf/eth0/autoconf:1
/proc/sys/net/ipv6/conf/lo/autoconf:1

Best regards.

-- 
Best regards,
 Pedro                            mailto:pribeiro-bulk@net.ipl.pt


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

* [PATCH] FIXED: IPv6 Route selection now correct with multiple gateways and preferences
  2008-10-14 12:58 ` Arnaud Ebalard
  2008-10-14 15:32   ` Re[2]: " Pedro Ribeiro
@ 2008-10-14 20:07   ` Pedro Ribeiro
  2008-10-14 20:15     ` David Miller
  1 sibling, 1 reply; 12+ messages in thread
From: Pedro Ribeiro @ 2008-10-14 20:07 UTC (permalink / raw
  To: netdev; +Cc: arno, YOSHIFUJI Hideaki / 吉藤英明

Hello Arnaud and all,

I’ve found the other part of the problem.
ndisc_router_discovery () at ndisc.c weren’t correctly updating the
flags in the route table, the problem is now fixed with the correct
default router being updated as soon as the next RA with the new
preference is received.

Follows the two patches made against 2.6.23 (this one and the first
I’ve sent) but I’ve seen in 2.6.26 the problem also exists and the fix
should apply without problems.

Can any of the maintainers give-me some expectations of when (and if) this fix
will be added to a kernel release?

Should I patch all of our ~60 Linux machines or wait for a general
upgrade with a new kernel soon?

Thanks for all the support in this subject.

Best regards.

#######################################################################

--- linux-2.6.23-gentoo-r9orig/net/ipv6/ndisc.c    2007-10-09 21:31:38.000000000 +0100
+++ linux-2.6.23-gentoo-r9/net/ipv6/ndisc.c    2008-10-14 20:07:48.000000000 +0100
@@ -1101,7 +1101,7 @@
                }
                neigh->flags |= NTF_ROUTER;
        } else if (rt) {
-               rt->rt6i_flags |= (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+               rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
        }
 
        if (rt)

(this part is a "repost" just to keep both patches together)

--- linux-2.6.23-gentoo-r9orig/include/linux/icmpv6.h      2007-10-09 21:31:38.000000000 +0100
+++ linux-2.6.23-gentoo-r9/include/linux/icmpv6.h      2008-10-13 17:42:56.000000000 +0100
@@ -40,16 +40,18 @@
                 struct icmpv6_nd_ra {
                        __u8            hop_limit;
 #if defined(__LITTLE_ENDIAN_BITFIELD)
-                       __u8            reserved:4,
+                       __u8            reserved:3,
                                        router_pref:2,
+                                       home_agent:1,
                                        other:1,
                                        managed:1;

 #elif defined(__BIG_ENDIAN_BITFIELD)
                        __u8            managed:1,
                                        other:1,
+                                       home_agent:1,
                                        router_pref:2,
-                                       reserved:4;
+                                       reserved:3;
 #else
 #error "Please fix <asm/byteorder.h>"

-- 
Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Pedro Ribeiro
IPLNet - Rede de dados e comunicações
Instituto Politécnico de Lisboa (IPL)
Mail: mailto:pribeiro@net.ipl.pt
VoIP: sip:pribeiro@net.ipl.pt
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

* Re: [PATCH] FIXED: IPv6 Route selection now correct with multiple gateways and preferences
  2008-10-14 20:07   ` [PATCH] FIXED: IPv6 Route selection now correct with multiple gateways and preferences Pedro Ribeiro
@ 2008-10-14 20:15     ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2008-10-14 20:15 UTC (permalink / raw
  To: pribeiro-bulk; +Cc: netdev, arno, yoshfuji

From: Pedro Ribeiro <pribeiro-bulk@net.ipl.pt>
Date: Tue, 14 Oct 2008 21:07:32 +0100

> Can any of the maintainers give-me some expectations of when (and
> if) this fix will be added to a kernel release?

Well, first of all, your email client corrupted the patch (turning
tab characters into spaces etc.) so that is the first thing you
need to fix before we'll even look at this.

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

* Re: [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields!
  2008-10-14 11:06 [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields! Pedro Ribeiro
  2008-10-14 12:58 ` Arnaud Ebalard
@ 2008-10-14 20:54 ` David Miller
  2008-10-14 22:38   ` [PATCH for 2.6.27] " Pedro Ribeiro
  1 sibling, 1 reply; 12+ messages in thread
From: David Miller @ 2008-10-14 20:54 UTC (permalink / raw
  To: pribeiro-bulk-reply, pribeiro-bulk; +Cc: netdev

From: Pedro Ribeiro <pribeiro-bulk@net.ipl.pt>
Date: Tue, 14 Oct 2008 12:06:20 +0100

> Follows a “diff” with the changes I’ve made to correct this problem
> (I’ve made it against kernel 2.6.23, but I’ve confirmed that the
> problem still exists in 2.6.25)

Please make your patch against current sources, it does not apply
to the current tree.

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

* [PATCH for 2.6.27] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields!
  2008-10-14 20:54 ` [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields! David Miller
@ 2008-10-14 22:38   ` Pedro Ribeiro
  2008-10-14 22:47     ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Pedro Ribeiro @ 2008-10-14 22:38 UTC (permalink / raw
  To: David Miller; +Cc: netdev

Hello David,

Thanks for your time on this, follows a new patch made against 2.6.27,
this time I minimized the cut&paste to avoid corrupting the patch.

diff -wurNbB linux-2.6.27/include/linux/icmpv6.h linux-2.6.27fix/include/linux/icmpv6.h
--- linux-2.6.27/include/linux/icmpv6.h 2008-10-09 23:13:53.000000000 +0100
+++ linux-2.6.27fix/include/linux/icmpv6.h      2008-10-14 23:24:31.000000000 +0100
@@ -40,16 +40,18 @@
                 struct icmpv6_nd_ra {
                        __u8            hop_limit;
 #if defined(__LITTLE_ENDIAN_BITFIELD)
-                       __u8            reserved:4,
+                       __u8            reserved:3,
                                        router_pref:2,
+                                       home_agent:1,
                                        other:1,
                                        managed:1;
 
 #elif defined(__BIG_ENDIAN_BITFIELD)
                        __u8            managed:1,
                                        other:1,
+                                       home_agent:1,
                                        router_pref:2,
-                                       reserved:4;
+                                       reserved:3;
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif
diff -wurNbB linux-2.6.27/net/ipv6/ndisc.c linux-2.6.27fix/net/ipv6/ndisc.c
--- linux-2.6.27/net/ipv6/ndisc.c       2008-10-09 23:13:53.000000000 +0100
+++ linux-2.6.27fix/net/ipv6/ndisc.c    2008-10-14 23:24:31.000000000 +0100
@@ -1199,7 +1199,7 @@
                }
                neigh->flags |= NTF_ROUTER;
        } else if (rt) {
-               rt->rt6i_flags |= (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+               rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
        }
 
        if (rt)



Best regards.

Tuesday, October 14, 2008, 9:54:23 PM, you wrote:

> From: Pedro Ribeiro <pribeiro-bulk@net.ipl.pt>
> Date: Tue, 14 Oct 2008 12:06:20 +0100

>> Follows a “diff” with the changes I’ve made to correct this problem
>> (I’ve made it against kernel 2.6.23, but I’ve confirmed that the
>> problem still exists in 2.6.25)

> Please make your patch against current sources, it does not apply
> to the current tree.
> \x04\x14?\x06?칻\x1c?&?\x05???^[a??e??A\x06ǧt^[a|\x19b??A?{.n?+?????]z?A?{a|\x16?w0h|\x16???,j\a???fj:+v??\x06?\x1e?\x19\x1e?w?\x06??2??\x06f???h??b??Aj?A??i\a????????zPh?\x0f?j:+v??\x06)ߤ\x18m?



-- 
Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Pedro Ribeiro
IPLNet - Rede de dados e comunicações
Instituto Politécnico de Lisboa (IPL)
Mail: mailto:pribeiro-bulk@net.ipl.pt
VoIP: sip:pribeiro@net.ipl.pt
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

* Re: [PATCH for 2.6.27] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields!
  2008-10-14 22:38   ` [PATCH for 2.6.27] " Pedro Ribeiro
@ 2008-10-14 22:47     ` David Miller
  2008-10-15 15:55       ` [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements Pedro Ribeiro
  2008-10-15 16:09       ` [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements (text wrap fixed I hope!) Pedro Ribeiro
  0 siblings, 2 replies; 12+ messages in thread
From: David Miller @ 2008-10-14 22:47 UTC (permalink / raw
  To: pribeiro-bulk; +Cc: netdev

From: Pedro Ribeiro <pribeiro-bulk@net.ipl.pt>
Date: Tue, 14 Oct 2008 23:38:11 +0100

> Hello David,
> 
> Thanks for your time on this, follows a new patch made against 2.6.27,
> this time I minimized the cut&paste to avoid corrupting the patch.

It's still corrupted, the tab characters in the patch were
transformed into spaces.

It's not about cut&paste, your email client is reformatting the
content (no matter how you compose it) before sending it out.

You need to configure your email client explicitly to not reformat the
content and to use plain ASCII text.

Also, you need to provide a proper "Signed-off-by: " line.

All of this is detailed in the following kernel source doc
files:

linux/Documentation/email-clients.txt
linux/Documentation/SubmittingPatches 

Thanks.

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

* [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements
  2008-10-14 22:47     ` David Miller
@ 2008-10-15 15:55       ` Pedro Ribeiro
  2008-10-15 16:11         ` YOSHIFUJI Hideaki / 吉藤英明
  2008-10-15 16:09       ` [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements (text wrap fixed I hope!) Pedro Ribeiro
  1 sibling, 1 reply; 12+ messages in thread
From: Pedro Ribeiro @ 2008-10-15 15:55 UTC (permalink / raw
  To: David Miller; +Cc: netdev

Problem observed:
               In IPv6, in the presence of multiple routers candidates to
               default gateway in one segment, each sending a different
               value of preference, the Linux hosts connected to the
               segment weren't selecting the right one in all the
               combinations possible of LOW/MEDIUM/HIGH preference.
                         
This patch changes two files:
include/linux/icmpv6.h
               Get the "router_pref" bitfield in the right place
               (as RFC4191 says), named the bit left with this fix as
               "home_agent" (RFC3775 say that's his function)

net/ipv6/ndisc.c
               Corrects the binary logic behind the updating of the
               router preference in the flags of the routing table

Result:
               With this two fixes applied, the default route used by
               the system was to consistent with the rules mentioned
               in RFC4191 in case of changes in the value of preference
               in router advertisements

Signed-off-by: Pedro Ribeiro <pribeiro@net.ipl.pt>

diff -uprN linux-2.6.27/include/linux/icmpv6.h linux-2.6.27fix/include/linux/icmpv6.h
--- linux-2.6.27/include/linux/icmpv6.h	2008-10-09 23:13:53.000000000 +0100
+++ linux-2.6.27fix/include/linux/icmpv6.h	2008-10-14 23:24:31.000000000 +0100
@@ -40,16 +40,18 @@ struct icmp6hdr {
                 struct icmpv6_nd_ra {
 			__u8		hop_limit;
 #if defined(__LITTLE_ENDIAN_BITFIELD)
-			__u8		reserved:4,
+			__u8		reserved:3,
 					router_pref:2,
+					home_agent:1,
 					other:1,
 					managed:1;
 
 #elif defined(__BIG_ENDIAN_BITFIELD)
 			__u8		managed:1,
 					other:1,
+					home_agent:1,
 					router_pref:2,
-					reserved:4;
+					reserved:3;
 #else
 #error	"Please fix <asm/byteorder.h>"
 #endif
diff -uprN linux-2.6.27/net/ipv6/ndisc.c linux-2.6.27fix/net/ipv6/ndisc.c
--- linux-2.6.27/net/ipv6/ndisc.c	2008-10-09 23:13:53.000000000 +0100
+++ linux-2.6.27fix/net/ipv6/ndisc.c	2008-10-14 23:24:31.000000000 +0100
@@ -1199,7 +1199,7 @@ static void ndisc_router_discovery(struc
 		}
 		neigh->flags |= NTF_ROUTER;
 	} else if (rt) {
-		rt->rt6i_flags |= (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+		rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
 	}
 
 	if (rt)

-- 
Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Pedro Ribeiro
IPLNet - Rede de dados e comunicações
Instituto Politécnico de Lisboa (IPL)
Mail: mailto:pribeiro AT net.ipl.pt
VoIP: sip:pribeiro AT net.ipl.pt
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



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

* [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements (text wrap fixed I hope!)
  2008-10-14 22:47     ` David Miller
  2008-10-15 15:55       ` [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements Pedro Ribeiro
@ 2008-10-15 16:09       ` Pedro Ribeiro
  1 sibling, 0 replies; 12+ messages in thread
From: Pedro Ribeiro @ 2008-10-15 16:09 UTC (permalink / raw
  To: David Miller; +Cc: netdev

Problem observed:
               In IPv6, in the presence of multiple routers candidates to
               default gateway in one segment, each sending a different
               value of preference, the Linux hosts connected to the
               segment weren't selecting the right one in all the
               combinations possible of LOW/MEDIUM/HIGH preference.
                         
This patch changes two files:
include/linux/icmpv6.h
               Get the "router_pref" bitfield in the right place
               (as RFC4191 says), named the bit left with this fix as
               "home_agent" (RFC3775 say that's his function)

net/ipv6/ndisc.c
               Corrects the binary logic behind the updating of the
               router preference in the flags of the routing table

Result:
               With this two fixes applied, the default route used by
               the system was to consistent with the rules mentioned
               in RFC4191 in case of changes in the value of preference
               in router advertisements

Signed-off-by: Pedro Ribeiro <pribeiro@net.ipl.pt>

diff -uprN linux-2.6.27/include/linux/icmpv6.h linux-2.6.27fix/include/linux/icmpv6.h
--- linux-2.6.27/include/linux/icmpv6.h	2008-10-09 23:13:53.000000000 +0100
+++ linux-2.6.27fix/include/linux/icmpv6.h	2008-10-14 23:24:31.000000000 +0100
@@ -40,16 +40,18 @@ struct icmp6hdr {
                 struct icmpv6_nd_ra {
 			__u8		hop_limit;
 #if defined(__LITTLE_ENDIAN_BITFIELD)
-			__u8		reserved:4,
+			__u8		reserved:3,
 					router_pref:2,
+					home_agent:1,
 					other:1,
 					managed:1;
 
 #elif defined(__BIG_ENDIAN_BITFIELD)
 			__u8		managed:1,
 					other:1,
+					home_agent:1,
 					router_pref:2,
-					reserved:4;
+					reserved:3;
 #else
 #error	"Please fix <asm/byteorder.h>"
 #endif
diff -uprN linux-2.6.27/net/ipv6/ndisc.c linux-2.6.27fix/net/ipv6/ndisc.c
--- linux-2.6.27/net/ipv6/ndisc.c	2008-10-09 23:13:53.000000000 +0100
+++ linux-2.6.27fix/net/ipv6/ndisc.c	2008-10-14 23:24:31.000000000 +0100
@@ -1199,7 +1199,7 @@ static void ndisc_router_discovery(struc
 		}
 		neigh->flags |= NTF_ROUTER;
 	} else if (rt) {
-		rt->rt6i_flags |= (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
+		rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
 	}
 
 	if (rt)



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

* Re: [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements
  2008-10-15 15:55       ` [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements Pedro Ribeiro
@ 2008-10-15 16:11         ` YOSHIFUJI Hideaki / 吉藤英明
  2008-10-15 22:47           ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2008-10-15 16:11 UTC (permalink / raw
  To: pribeiro-bulk; +Cc: davem, netdev, yoshfuji

In article <48F61285.6010500@net.ipl.pt> (at Wed, 15 Oct 2008 16:55:49 +0100), Pedro Ribeiro <pribeiro-bulk@net.ipl.pt> says:

> Signed-off-by: Pedro Ribeiro <pribeiro@net.ipl.pt>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

--yoshfuji

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

* Re: [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements
  2008-10-15 16:11         ` YOSHIFUJI Hideaki / 吉藤英明
@ 2008-10-15 22:47           ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2008-10-15 22:47 UTC (permalink / raw
  To: yoshfuji; +Cc: pribeiro-bulk, netdev

From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Date: Thu, 16 Oct 2008 01:11:43 +0900 (JST)

> In article <48F61285.6010500@net.ipl.pt> (at Wed, 15 Oct 2008 16:55:49 +0100), Pedro Ribeiro <pribeiro-bulk@net.ipl.pt> says:
> 
> > Signed-off-by: Pedro Ribeiro <pribeiro@net.ipl.pt>
> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

Applied, thanks everyone.

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

end of thread, other threads:[~2008-10-15 22:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-14 11:06 [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields! Pedro Ribeiro
2008-10-14 12:58 ` Arnaud Ebalard
2008-10-14 15:32   ` Re[2]: " Pedro Ribeiro
2008-10-14 20:07   ` [PATCH] FIXED: IPv6 Route selection now correct with multiple gateways and preferences Pedro Ribeiro
2008-10-14 20:15     ` David Miller
2008-10-14 20:54 ` [PATCH] Structure icmp6hdr (IPv6/ICMPv6) with bug in the bitfields! David Miller
2008-10-14 22:38   ` [PATCH for 2.6.27] " Pedro Ribeiro
2008-10-14 22:47     ` David Miller
2008-10-15 15:55       ` [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements Pedro Ribeiro
2008-10-15 16:11         ` YOSHIFUJI Hideaki / 吉藤英明
2008-10-15 22:47           ` David Miller
2008-10-15 16:09       ` [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements (text wrap fixed I hope!) Pedro Ribeiro

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.