From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E919FC43219 for ; Thu, 2 May 2019 01:17:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE9E22085A for ; Thu, 2 May 2019 01:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556759855; bh=MI4GiHRyFuoxJ7qSu+5vOU4uQv7NttY1eeOtpJKf3K0=; h=From:To:Cc:Subject:Date:List-ID:From; b=hYPHCEHieNpwehtt8zQzBSROw890Fy7QgSZH9Va9/cKe/HOhkF+REVSd6YDFZlgTK D6HS0ve0rmmJ5UF3qYzn0IjcPhjVmA2MQn07/NNt51mdKwIvzTU/SAm08TxKIvXx3m 6dSoRiFs3RpeEA61TIQ9K+phZk4qqCE0nb3j/JJE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726191AbfEBBRe (ORCPT ); Wed, 1 May 2019 21:17:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:40044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbfEBBRe (ORCPT ); Wed, 1 May 2019 21:17:34 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4B4522085A; Thu, 2 May 2019 01:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556759853; bh=MI4GiHRyFuoxJ7qSu+5vOU4uQv7NttY1eeOtpJKf3K0=; h=From:To:Cc:Subject:Date:From; b=T4mWd3x7ozohFe6C/yKDr5masxKrvmGhKzjIirOwQ5Xal4kshiI3uHukORWHBkw6r 6HZ1EW76Wn3y5w8pQZg7CFO9/zaQUHvoM9SYUpAIX6mekjEU9c+TyZXsQmVBar66Wm 0b1nAFVdotcF3b1Xo7p+ZLE57cWw4xAhYM4XOBrQ= From: David Ahern To: davem@davemloft.net Cc: netdev@vger.kernel.org, alan.maguire@oracle.com, jwestfall@surrealistic.net, David Ahern Subject: [PATCH net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit Date: Wed, 1 May 2019 18:18:42 -0700 Message-Id: <20190502011842.1645-1-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Commit cd9ff4de0107 changed the key for IFF_POINTOPOINT devices to INADDR_ANY but neigh_xmit which is used for MPLS encapsulations was not updated to use the altered key. The result is that every packet Tx does a lookup on the gateway address which does not find an entry, a new one is created only to find the existing one in the table right before the insert since arp_constructor was updated to reset the primary key. This is seen in the allocs and destroys counters: ip -s -4 ntable show | head -10 | grep alloc which increase for each packet showing the unnecessary overhread. Fix by having neigh_xmit use __ipv4_neigh_lookup_noref for NEIGH_ARP_TABLE. Fixes: cd9ff4de0107 ("ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY") Reported-by: Alan Maguire Signed-off-by: David Ahern --- net/core/neighbour.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index aff051e5521d..9b9da5142613 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -2984,7 +2985,13 @@ int neigh_xmit(int index, struct net_device *dev, if (!tbl) goto out; rcu_read_lock_bh(); - neigh = __neigh_lookup_noref(tbl, addr, dev); + if (index == NEIGH_ARP_TABLE) { + u32 key = *((u32 *)addr); + + neigh = __ipv4_neigh_lookup_noref(dev, key); + } else { + neigh = __neigh_lookup_noref(tbl, addr, dev); + } if (!neigh) neigh = __neigh_create(tbl, addr, dev, false); err = PTR_ERR(neigh); -- 2.11.0