Skip to contentSkip to conversation

ipv6: use rt6_get_dflt_router to get default router in rt6_route_rcv

PATCH In review Duan Jiong 3 participants 3 messages Nov 8, 2013

Subsystems (3)
lore
Share & tools
lore

Duan Jiong

author
#0 lore raw

PATCH 1/1 ipv6: use rt6_get_dflt_router to get default router in rt6_route_rcv

As the rfc 4191 said, the Router Preference and Lifetime values in a ::/0 Route Information Option should override the preference and lifetime values in the Router Advertisement header. But when the kernel deals with a ::/0 Route Information Option, the rt6_get_route_info() always return NULL, that means that overriding will not happen, because those default routers were added without flag RTF_ROUTEINFO in rt6_add_dflt_router().

In order to deal with that condition, we should call rt6_get_dflt_router when the prefix length is 0.

---
 net/ipv6/route.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv6/route.c +5 -2
index c28cdda..7faa9d5 100644
@@ -731,8 +731,11 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
 		prefix = &prefix_buf;
 	}
 
-	rt = rt6_get_route_info(net, prefix, rinfo->prefix_len, gwaddr,
-				dev->ifindex);
+	if (rinfo->prefix_len == 0)
+		rt = rt6_get_dflt_router(gwaddr, dev);
+	else
+		rt = rt6_get_route_info(net, prefix, rinfo->prefix_len,
+					gwaddr, dev->ifindex);
 
 	if (rt && !lifetime) {
 		ip6_del_rt(rt);
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Duan Jiong

As the rfc 4191 said, the Router Preference and Lifetime values in a ::/0 Route Information Option should override the preference and lifetime values in the Router Advertisement header. But when the kernel deals with a ::/0 Route Information Option, the rt6_get_route_info() always return NULL, that means that overriding will not happen, because those default routers were added without flag RTF_ROUTEINFO in rt6_add_dflt_router().

Quoted 4 lines

In order to deal with that condition, we should call rt6_get_dflt_router when the prefix length is 0.

Thanks,

Hannes

maintainer
#2 lore raw
In reply to Duan Jiong

From: Duan Jiong <[email protected]>
Date: Fri, 08 Nov 2013 09:56:53 +0800

Quoted 8 lines

As the rfc 4191 said, the Router Preference and Lifetime values in a ::/0 Route Information Option should override the preference and lifetime values in the Router Advertisement header. But when the kernel deals with a ::/0 Route Information Option, the rt6_get_route_info() always return NULL, that means that overriding will not happen, because those default routers were added without flag RTF_ROUTEINFO in rt6_add_dflt_router().

Quoted 4 lines

In order to deal with that condition, we should call rt6_get_dflt_router when the prefix length is 0.

Applied and queued up for -stable, thanks!