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.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, T_DKIMWL_WL_HIGH,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 723BDC04AAA for ; Fri, 3 May 2019 15:53:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41B112087F for ; Fri, 3 May 2019 15:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556898832; bh=9lLucm5+W1Auddm1GFDkkqllaxje41X1M+JhnYNJ+go=; h=From:To:Cc:Subject:Date:List-ID:From; b=sosM3LKI3dBBePY906QiXAMh1O/uHWQWX24XvHSAK4zTz3fnXcmVcKO1CSvMXAwU+ MBr9tN6hLG6oFpgDlD/DHknAL/4y498SqzmxFFuzbzmrFp7QNuN36wiX1/qiNBl2UD E9fH2LCfmQFZbF3fmDkPzx4dV2Oui2ZjvmuA+VOg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728285AbfECPxv (ORCPT ); Fri, 3 May 2019 11:53:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:60598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbfECPxu (ORCPT ); Fri, 3 May 2019 11:53:50 -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 8A41A2075C; Fri, 3 May 2019 15:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556898829; bh=9lLucm5+W1Auddm1GFDkkqllaxje41X1M+JhnYNJ+go=; h=From:To:Cc:Subject:Date:From; b=AzXMmgg/hE+my9m9xFJ8/1g57ZFzNGcKIIUupvSCStUNunm9JHUTtnxuIjinLhhJS 0d5kZxV0ab3VQ3zVeOnqg/Uoth2rPT1ZUhBu5ACJXyTEpDaWreyBG50fqMqHRqJlUc 5uoXlk2JbdPvo7iQKwiiN7PuOSzt6X96cEJRxK4Y= From: David Ahern To: davem@davemloft.net Cc: netdev@vger.kernel.org, alan.maguire@oracle.com, jwestfall@surrealistic.net, David Ahern Subject: [PATCH v2 net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit Date: Fri, 3 May 2019 08:55:01 -0700 Message-Id: <20190503155501.28182-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. Define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set. v2 - define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set as reported by kbuild test robot 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 Signed-off-by: David Ahern --- include/net/arp.h | 8 ++++++++ net/core/neighbour.c | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/net/arp.h b/include/net/arp.h index 977aabfcdc03..c8f580a0e6b1 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -18,6 +18,7 @@ static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32 return val * hash_rnd[0]; } +#ifdef CONFIG_INET static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) { if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) @@ -25,6 +26,13 @@ static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev); } +#else +static inline +struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) +{ + return NULL; +} +#endif static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) { diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 30f6fd8f68e0..0ba5018ccb7f 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -2982,7 +2983,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