From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225lBqx9qh6xDdXDTIqG2U+nxqe1QhacidF/feRX37nnoO9r4yj7s26vTU9CHXlaazIa63bo ARC-Seal: i=1; a=rsa-sha256; t=1517256312; cv=none; d=google.com; s=arc-20160816; b=aMik+8ykZO0Le6NnJ7/lI/N8QdteyddqzzTNhxGz/s0J8AAD8wHf+GCYHTbHXihWxf bNP6pgQonO6ZWnBheoZzPluuJGm2cpUjSJI6wZlgstfTU8hyq/7Zf2ZSu0AXL1NzUMP+ R6VvWU61Xarl4WnB7xLNmkw1gJ0A3OEYsIRkSUQDqcY7hB4Qiyh5ujfTIwCVb3xpl9b7 pggLUhVTzie5v/yPPwe647IhbB8tVCr6nAWT0Dm2e3wJQ+/3GHrac2maprIqbvgdJGih xPN0X2ewNJzfbY7FIckgIbiCzNiKSjKaJG4IPgJsTryd2lbVFCaGSjPsnBpj585He84Y 55iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fE/bDF+ptzcvJuNJq1lDil8liAqOLm9MBs/kBnc08PY=; b=KDPARvMtNFPG+pfqEn0ylDiYz3RBIfRFhIOLwm4UPkYepikBoO/tQ7Rn5wYwjlt9dp kSq0TWBx8wiJ8ylFMp8mon55+XbgTcohc+QNDNeDTzLRvPiDvzMr9v156vuLmNx9Z1/y 8L3eZFSTJpQMV8HaI9sTsodS5nd3sTqNbzH5et1pTYUD+l5VR14VDR8KNkfnT7a4QlWO vK68zz5N5oVR40v5cfk9/dYcFmMyaHZ1zd63kKMBl/7Ia1XooGAa/If8EQUPMTC6Ukei Qr9zuPi43tEV9iae9/HiqsScfFEKQFVD6EbntKzJaoAItcwG7z9PzSlP+eogAPokqNit 1iVg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Westfall , "David S. Miller" Subject: [PATCH 4.9 48/66] ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY Date: Mon, 29 Jan 2018 13:57:12 +0100 Message-Id: <20180129123842.405843264@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958544277885244?= X-GMAIL-MSGID: =?utf-8?q?1590958554962367806?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jim Westfall [ 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: Greg Kroah-Hartman --- include/net/arp.h | 3 +++ net/ipv4/arp.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) --- a/include/net/arp.h +++ b/include/net/arp.h @@ -19,6 +19,9 @@ static inline u32 arp_hashfn(const void static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) { + if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) + key = INADDR_ANY; + return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev); } --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -223,11 +223,16 @@ static bool arp_key_eq(const struct neig static int arp_constructor(struct neighbour *neigh) { - __be32 addr = *(__be32 *)neigh->primary_key; + __be32 addr; struct net_device *dev = neigh->dev; struct in_device *in_dev; struct neigh_parms *parms; + u32 inaddr_any = INADDR_ANY; + if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) + memcpy(neigh->primary_key, &inaddr_any, arp_tbl.key_len); + + addr = *(__be32 *)neigh->primary_key; rcu_read_lock(); in_dev = __in_dev_get_rcu(dev); if (!in_dev) {