From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225tEFaO6a1cw8KsOXyzUHHJQ2zHBzG0txA8rWhnmReLKLgaX22COTrik4sZ9gyMUoypFpo9 ARC-Seal: i=1; a=rsa-sha256; t=1517256836; cv=none; d=google.com; s=arc-20160816; b=X5cDc+ZUZEbm5iYtYupwOnivBj+Gh0ycGEkXtBimk6amkzdGAfGMwltYhiUXl0gjPt KiL9NDM8W1mH2J4n8XXjeSfvwL4g0M2ovBAOarGt2LfY1TK4L/REuaHaRyLfMhxUpMmN dpSotHg75Tz7051mKB/qPXtnojOO3LDQjgGcU5oUnqC2/eLfDRefYrX2iP4b3iNVYAw7 zp/vjT+hfbyTbmiC8V5j+iNihkb8wW54Oy9WbIsQGP7/d1UW1VQQ12f7OW020RxV/f9d rHdlXvzgjnEKkfK0dGbIY6Xw+aG5LwjTU0tnBvtxk8iJsOeCHxhsNQVNTuonLbyXBkT1 xeHQ== 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=6Dp/P8H+VDg1pyGoNDyEBXndo4Tx/gbpVLj4q1OOQ6E=; b=g0hi8xMckXQZmaoN/1I3kuwqPY4cHHsypCdrMJvSho5uRIaFjnZqT6vQSBEVdVlJQN RX5RrdabHCmWOXcHVWMxRO76c501eXhTbzukaGM950KRFJg737BVUIYPCBnuqiHz8Vhb kdFkv74PIq1SEB/yxmRQ9/po/Wvr9T50qfCe4LU75AmKBhZYlAMZs9eUGPf117YYm0GD S2V1qj7QXln4O6DVyWHRkb48wuUeNx0RLzZrvAoU4Lum4IG3/W22cxfxSfLIGhFDGxcH 36mZTuivzl46bhqupn+aFvM7oGWyH0IAiNl/DPEyM0P4dMxMLhOxsKk36S/ZprOr83Qy V2aw== 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 3.18 52/52] ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY Date: Mon, 29 Jan 2018 13:57:10 +0100 Message-Id: <20180129123630.439271490@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123628.168904217@linuxfoundation.org> References: <20180129123628.168904217@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?1590959104370523916?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 3.18-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 @@ -37,6 +37,9 @@ static inline struct neighbour *__ipv4_n { 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)) --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -221,11 +221,16 @@ static u32 arp_hash(const void *pkey, 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 == NULL) {