From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0118.outbound.protection.outlook.com ([104.47.40.118]:42464 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932589AbeARVEe (ORCPT ); Thu, 18 Jan 2018 16:04:34 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Xin Long , "David S . Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] route: also update fnhe_genid when updating a route cache Date: Thu, 18 Jan 2018 21:01:05 +0000 Message-ID: <20180118205908.3220-190-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Xin Long This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit cebe84c6190d741045a322f5343f717139993c08 ] Now when ip route flush cache and it turn out all fnhe_genid !=3D genid. If a redirect/pmtu icmp packet comes and the old fnhe is found and all it's members but fnhe_genid will be updated. Then next time when it looks up route and tries to rebind this fnhe to the new dst, the fnhe will be flushed due to fnhe_genid !=3D genid. It causes this redirect/pmtu icmp packet acutally not to be applied. This patch is to also reset fnhe_genid when updating a route cache. Fixes: 5aad1de5ea2c ("ipv4: use separate genid for next hop exceptions") Acked-by: Hannes Frederic Sowa Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/route.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 8f29e29f18a1..42c7fed200b2 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -622,9 +622,12 @@ static void update_or_create_fnhe(struct fib_nh *nh, _= _be32 daddr, __be32 gw, struct fnhe_hash_bucket *hash; struct fib_nh_exception *fnhe; struct rtable *rt; + u32 genid, hval; unsigned int i; int depth; - u32 hval =3D fnhe_hashfun(daddr); + + genid =3D fnhe_genid(dev_net(nh->nh_dev)); + hval =3D fnhe_hashfun(daddr); =20 spin_lock_bh(&fnhe_lock); =20 @@ -647,6 +650,8 @@ static void update_or_create_fnhe(struct fib_nh *nh, __= be32 daddr, __be32 gw, } =20 if (fnhe) { + if (fnhe->fnhe_genid !=3D genid) + fnhe->fnhe_genid =3D genid; if (gw) fnhe->fnhe_gw =3D gw; if (pmtu) { @@ -671,7 +676,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __= be32 daddr, __be32 gw, fnhe->fnhe_next =3D hash->chain; rcu_assign_pointer(hash->chain, fnhe); } - fnhe->fnhe_genid =3D fnhe_genid(dev_net(nh->nh_dev)); + fnhe->fnhe_genid =3D genid; fnhe->fnhe_daddr =3D daddr; fnhe->fnhe_gw =3D gw; fnhe->fnhe_pmtu =3D pmtu; --=20 2.11.0