From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn3nam01on0131.outbound.protection.outlook.com ([104.47.33.131]:56088 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032288AbeCAPcO (ORCPT ); Thu, 1 Mar 2018 10:32:14 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Jim Westfall , "David S . Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY Date: Thu, 1 Mar 2018 15:25:06 +0000 Message-ID: <20180301152116.1486-248-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-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: Jim Westfall This patch has been added to the 4.1 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 cd9ff4de0107c65d69d02253bb25d6db93c3dbc1 ] Map all lookup neigh keys to INADDR_ANY for loopback/point-to-point devices to avoid making an entry for every remote ip the device needs to talk to. This used the be the old behavior but became broken in a263b3093641f (ipv4: Make neigh lookups directly in output packet path) and later removed in 0bb4087cbec0 (ipv4: Fix neigh lookup keying over loopback/point-to-point devices) because it was broken. Signed-off-by: Jim Westfall Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/arp.h | 3 +++ net/ipv4/arp.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/net/arp.h b/include/net/arp.h index 5e0f891d476c..1b3f86981757 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -19,6 +19,9 @@ static inline u32 arp_hashfn(const void *pkey, const stru= ct net_device *dev, u32 =20 static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_devic= e *dev, u32 key) { + if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) + key =3D INADDR_ANY; + return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, = dev); } =20 diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index a7e74fbf2ce6..24b4174a84bf 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -221,11 +221,16 @@ static bool arp_key_eq(const struct neighbour *neigh,= const void *pkey) =20 static int arp_constructor(struct neighbour *neigh) { - __be32 addr =3D *(__be32 *)neigh->primary_key; + __be32 addr; struct net_device *dev =3D neigh->dev; struct in_device *in_dev; struct neigh_parms *parms; + u32 inaddr_any =3D INADDR_ANY; =20 + if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) + memcpy(neigh->primary_key, &inaddr_any, arp_tbl.key_len); + + addr =3D *(__be32 *)neigh->primary_key; rcu_read_lock(); in_dev =3D __in_dev_get_rcu(dev); if (!in_dev) { --=20 2.14.1