From patchwork Tue Jul 17 12:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 10529237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ACAA9600F4 for ; Tue, 17 Jul 2018 12:08:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF4728EA8 for ; Tue, 17 Jul 2018 12:08:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9328D28EAB; Tue, 17 Jul 2018 12:08:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 440FD28EA8 for ; Tue, 17 Jul 2018 12:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731531AbeGQMkQ (ORCPT ); Tue, 17 Jul 2018 08:40:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:60678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731643AbeGQMjK (ORCPT ); Tue, 17 Jul 2018 08:39:10 -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 126322146F; Tue, 17 Jul 2018 12:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1531829210; bh=21c3T+U2OAnSmaX/4GUzGtZWUNcEdzgplop3uCRoUM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U5h++Urt8BjDagT3XZQzwodHT+cCIynDNca/2KReEcYPvwjFXTg6ud0d3/etAR17V xeh1CI8yH4iirGkLTkZhBkG9HIMym7Fgsxpb/3+T/bjMrSrHjOrQyFe/4AOkOK7Ygy n6xtTkuPVAp0diwtJV8oOtF0BrNLInifmVDXwTk0= 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 13/17] net/neighbor: Convert internal functions away from neigh_tables Date: Tue, 17 Jul 2018 05:06:47 -0700 Message-Id: <20180717120651.15748-14-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-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Ahern Convert uses of neigh_tables array to neigh_find_table. Maintain existing family order using a new table_families array. A later patch removes the neigh_tables array in favor of per-namespace accesses. Signed-off-by: David Ahern --- net/core/neighbour.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index b60087d7c0bc..afb2ee985dd1 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -62,6 +62,19 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl, static const struct seq_operations neigh_stat_seq_ops; #endif +/* used for table dumps to maintain the legacy order of + * ipv4, ipv6, decnet + */ +static int table_families[] = { + AF_INET, +#if IS_ENABLED(CONFIG_IPV6) + AF_INET6, +#endif +#if IS_ENABLED(CONFIG_DECNET) + AF_DECnet, +#endif +}; + /* Neighbour hash table buckets are protected with rwlock tbl->lock. @@ -2046,8 +2059,8 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, ndtmsg = nlmsg_data(nlh); - for (tidx = 0; tidx < NEIGH_NR_TABLES; tidx++) { - tbl = neigh_tables[tidx]; + for (tidx = 0; tidx < ARRAY_SIZE(table_families); tidx++) { + tbl = neigh_find_table(net, table_families[tidx]); if (!tbl) continue; if (ndtmsg->ndtm_family && tbl->family != ndtmsg->ndtm_family) @@ -2195,10 +2208,10 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family; - for (tidx = 0; tidx < NEIGH_NR_TABLES; tidx++) { + for (tidx = 0; tidx < ARRAY_SIZE(table_families); tidx++) { struct neigh_parms *p; - tbl = neigh_tables[tidx]; + tbl = neigh_find_table(net, table_families[tidx]); if (!tbl) continue; @@ -2453,6 +2466,7 @@ static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) { + struct net *net = sock_net(skb->sk); struct neigh_table *tbl; int t, family, s_t; int proxy = 0; @@ -2469,9 +2483,8 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) s_t = cb->args[0]; - for (t = 0; t < NEIGH_NR_TABLES; t++) { - tbl = neigh_tables[t]; - + for (t = 0; t < ARRAY_SIZE(table_families); t++) { + tbl = neigh_find_table(net, table_families[t]); if (!tbl) continue; if (t < s_t || (family && tbl->family != family))