netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pedro Ribeiro <pribeiro-bulk@net.ipl.pt>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH] Fix IPv6 default gateway selection criteria in presence of the HIGH/LOW preference option in router advertisements (text wrap fixed I hope!)
Date: Wed, 15 Oct 2008 17:09:10 +0100	[thread overview]
Message-ID: <48F615A6.8000201@net.ipl.pt> (raw)
In-Reply-To: <20081014.154716.139460375.davem@davemloft.net>

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)



      parent reply	other threads:[~2008-10-15 16:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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       ` Pedro Ribeiro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48F615A6.8000201@net.ipl.pt \
    --to=pribeiro-bulk@net.ipl.pt \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).