Skip to contentSkip to conversation

net/ipv6: fix incorrect fib6 gateway info after do redirect

PATCH In review Hangbin Liu 2 participants 2 messages Sep 6, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ipv6: fix incorrect fib6 gateway info after do redirect

When receive a redirect message and call rt6_do_redirect(), we allocate a new rt6_info and set new flags and gateway info, but not update these info to fib6_info.

Then if a user try to get the route info via ip route get, he will still get the old default gateway, because inet6_rtm_getroute() get gateway info from fib6_info.

Fixes 23fb93a4d3f11 ("net/ipv6: Cleanup exception and cache route handling")
---
 net/ipv6/route.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv6/route.c +4 -0
index 18e00ce..3d367c9 100644
@@ -3446,6 +3446,10 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
 		goto out;
 	}
 
+	/* Update fib6_info from rt6_info */
+	from->fib6_flags = rt->rt6i_flags;
+	from->fib6_nh.nh_gw = rt->rt6i_gateway;
+
 	netevent.old = &rt->dst;
 	netevent.new = &nrt->dst;
 	netevent.daddr = &msg->dest;
Signature · 1 line
2.5.5
#1 lore raw
Quoted 21 lines · Hangbin Liu

When receive a redirect message and call rt6_do_redirect(), we allocate a new rt6_info and set new flags and gateway info, but not update these info to fib6_info.

Then if a user try to get the route info via ip route get, he will still get the old default gateway, because inet6_rtm_getroute() get gateway info from fib6_info.

Fixes 23fb93a4d3f11 ("net/ipv6: Cleanup exception and cache route handling")
---
 net/ipv6/route.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv6/route.c +0 -0
index 18e00ce..3d367c9 100644

net/ipv6/route.c static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu · line 3455

Quoted 10 lines
net/ipv6/route.c +4 -0
@@ -3446,6 +3446,10 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
 		goto out;
 	}
 
+	/* Update fib6_info from rt6_info */
+	from->fib6_flags = rt->rt6i_flags;
+	from->fib6_nh.nh_gw = rt->rt6i_gateway;
+
 	netevent.old = &rt->dst;
 	netevent.new = &nrt->dst;
 	netevent.daddr = &msg->dest;

Only an exception should be inserted - and it is. The original route should not be updated.

The code prior to the fib6_info did not update the actual FIB entry, and the IPv4 code does not update the original route.