From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net] net/ipv6: fix incorrect fib6 gateway info after do redirect Date: Thu, 6 Sep 2018 08:35:08 -0600 Message-ID: <2f7a40e2-9a72-a1fc-61f0-eb38e6487a72@gmail.com> References: <1536238666-5307-1-git-send-email-liuhangbin@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "David S. Miller" To: Hangbin Liu , netdev@vger.kernel.org Return-path: Received: from mail-pf1-f195.google.com ([209.85.210.195]:35691 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729788AbeIFTK0 (ORCPT ); Thu, 6 Sep 2018 15:10:26 -0400 Received: by mail-pf1-f195.google.com with SMTP id p12-v6so5393287pfh.2 for ; Thu, 06 Sep 2018 07:34:36 -0700 (PDT) In-Reply-To: <1536238666-5307-1-git-send-email-liuhangbin@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 9/6/18 6:57 AM, Hangbin Liu wrote: > 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") > Reported-by: Jianlin Shi > Signed-off-by: Hangbin Liu > --- > net/ipv6/route.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index 18e00ce..3d367c9 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -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.