From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f65.google.com ([209.85.160.65]:45887 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751643AbeBBPHQ (ORCPT ); Fri, 2 Feb 2018 10:07:16 -0500 Received: by mail-pl0-f65.google.com with SMTP id p5so6382241plo.12 for ; Fri, 02 Feb 2018 07:07:16 -0800 (PST) Received: from localhost ([123.139.114.230]) by smtp.gmail.com with ESMTPSA id f12sm3871069pga.67.2018.02.02.07.07.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Feb 2018 07:07:15 -0800 (PST) Date: Fri, 2 Feb 2018 23:06:51 +0800 From: Wang Han To: stable@vger.kernel.org Subject: [PATCH for 3.18] ipv4: Map neigh lookup keys in __ipv4_neigh_lookup_noref() Message-ID: <20180202224114.00002fd9@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: As discussed earlier, From: Wang Han Date: Sat, 3 Feb 2018 03:28:35 +1400 Subject: [PATCH] ipv4: Map neigh lookup keys in __ipv4_neigh_lookup_noref() Commit 6c16fa957e84 is an incorrect backport as we map the keys in struct __ipv4_neigh_lookup(), but the correct place to add the code is struct __ipv4_neigh_lookup_noref(), compared to upstream. Fix it by moving the code, or fewer cases will be covered as __ipv4_neigh_lookup_noref() will be called unconditionally from __ipv4_neigh_lookup(), and it can be called from other places such as ip_output.c. Fixes: 6c16fa957e84 (ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY) Signed-off-by: Wang Han --- include/net/arp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/arp.h b/include/net/arp.h index 174014585ade..5d8c7990582f 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -22,6 +22,9 @@ static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev struct neighbour *n; u32 hash_val; + if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) + key = INADDR_ANY; + hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); n != NULL; @@ -37,9 +40,6 @@ static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 { struct neighbour *n; - if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) - key = INADDR_ANY; - rcu_read_lock_bh(); n = __ipv4_neigh_lookup_noref(dev, key); if (n && !atomic_inc_not_zero(&n->refcnt)) -- 2.14.1