Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3449274imm; Tue, 17 Jul 2018 05:10:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdk2fvif8197Y30jge40orOeoHorkr2iW0mZEO04uJGRJul++yYeX+sqI5chTtjCVmj0FFm X-Received: by 2002:a63:da04:: with SMTP id c4-v6mr1291146pgh.398.1531829401883; Tue, 17 Jul 2018 05:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531829401; cv=none; d=google.com; s=arc-20160816; b=D1zdXsoQE4z2kv3rVQ6cPusQtS3mfEjWook7flic8PMuw1/QCnXY4W9ySVriiE30Qb xO3KLTVN+ojMoCR8PMwda9z4e7H0uPt1mQ7YF48K4iuT3J4cnwXrf6eiC2l4iC61Q5HF 5Mps/xXoP9yJSmQXsLbUAXllRECJx2U48+frMWewUFb+17nIvwK12IlE0MBW+UW2EKe7 Rg/QE6k+F0kB2KWIkzjxqH0OGnOxbCdkjJy3AM3jbv6jT0W37zhkb05R7aGNTI63VIC/ k3+6rZwquNKshS391lWXZNr6dd9iqxs/i1wQCbUid5QWfxCssuvBHLfqXu39WlRHI9gC f9+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=9Kat6iJoRBKgfTc/7GyzhNj33CeitLRXVQHJiKkWw9o=; b=uvLfxWvB0HyHDTHUDVui6PuJvc/JGHjZh9A0P4L8AZe+YJNpBYKkrVo3Kgpwiqi8nD iW7Tx8D3VZI+CjsZLJKuTUMmGKLm0YVQXu+IGEZNlhM7aIKD8Nu0nv2o+gQKr5AiOXbE aJan4jznobUwDvxWTSbkK3mbicLLFf1bHTvWGHu/kSZDXV8scLJuvG7frta2r0zSUdks davmrk1mWkb4hkOojvVmxLh2982qrQjadbn+H8lbiD+Y4TjNjarGcDEiUSFApK3TfInA mQQW2/Boj4T2wV11HQexxOkbdLAAgiUk6QCuHk3fAzvbvDnCTMUcpll7+gdM6Ec1FWUC 0oIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yu69DhCF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9-v6si766143pfc.121.2018.07.17.05.09.46; Tue, 17 Jul 2018 05:10:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yu69DhCF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731527AbeGQMjH (ORCPT + 99 others); Tue, 17 Jul 2018 08:39:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:60652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729508AbeGQMjG (ORCPT ); Tue, 17 Jul 2018 08:39:06 -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 D4B582146F; Tue, 17 Jul 2018 12:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1531829206; bh=KQdVRaz4SnPg7pOrOTp7YyfKELMCceKO5akI9ql/Wag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yu69DhCFMOFVZgpvKlfH/UKVG0qwqkmMldfn7Igm10UZ0dhnc2AFRHOxErRoQxSoJ SNob6dPhu5ECUigIAdpqaLOhHCokDbIALcmP0RvuTS5UJTYxoeBmkLGaoNCBgRt6Bn Xh+JomwXlh2CJAzirIVVOFf9hO0gb/QzELc/WbTc= From: dsahern@kernel.org To: netdev@vger.kernel.org Cc: nikita.leshchenko@oracle.com, roopa@cumulusnetworks.com, stephen@networkplumber.org, idosch@mellanox.com, jiri@mellanox.com, saeedm@mellanox.com, alex.aring@gmail.com, linux-wpan@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org, David Ahern Subject: [PATCH RFC/RFT net-next 03/17] net/ipv4: wrappers for arp table references Date: Tue, 17 Jul 2018 05:06:37 -0700 Message-Id: <20180717120651.15748-4-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180717120651.15748-1-dsahern@kernel.org> References: <20180717120651.15748-1-dsahern@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Ahern Create a helper, ipv4_neigh_table, for retrieving a reference to the arp table. Add additional wrappers for commonly used neigh_* functions to avoid propagating the ipv4_neigh_table lookup all over the code. Signed-off-by: David Ahern --- include/net/arp.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/include/net/arp.h b/include/net/arp.h index 977aabfcdc03..7b503bedd9fb 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -10,6 +10,29 @@ extern struct neigh_table arp_tbl; +static inline struct neigh_table *ipv4_neigh_table(struct net *net) +{ + return neigh_find_table(net, AF_INET); +} + +static inline struct neighbour *ipv4_neigh_create(struct net_device *dev, + const void *pkey) +{ + return neigh_create(ipv4_neigh_table(dev_net(dev)), pkey, dev); +} + +static inline struct neighbour *ipv4_neigh_create_noref(struct net_device *dev, + const void *pkey) +{ + return __neigh_create(ipv4_neigh_table(dev_net(dev)), pkey, dev, false); +} + +static inline struct neighbour *ipv4_neigh_lookup(struct net_device *dev, + void *key) +{ + return neigh_lookup(ipv4_neigh_table(dev_net(dev)), key, dev); +} + static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32 *hash_rnd) { u32 key = *(const u32 *)pkey; @@ -23,7 +46,8 @@ static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) key = INADDR_ANY; - return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev); + return ___neigh_lookup_noref(ipv4_neigh_table(dev_net(dev)), + neigh_key_eq32, arp_hashfn, &key, dev); } static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) -- 2.11.0