Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3448304imm; Tue, 17 Jul 2018 05:09:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdzjq8tfNMApw7KicKnPT1HTvTMhG9ULhR32j+jqucxKW2ahJq0ey6GcKTCQZBZ0MuGXnYg X-Received: by 2002:a17:902:9689:: with SMTP id n9-v6mr1414492plp.128.1531829351528; Tue, 17 Jul 2018 05:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531829351; cv=none; d=google.com; s=arc-20160816; b=mra/cO717QoihhATN82EQwaiOAZgvJuFZZASN0KN69iFLj0EWC9V1pcbfz/J5ebLT4 HH0DtnSKxfb6MRP2D4SqkoHprq4BOlH3gke4LVp4X0IW1F6xxITMndW/z5EthlCnj5vn xztYCuZUxzNr/eqdJTdUZ7KDiRh4aZ8d88sc8tcIr2gHH8tmOJO2lydaZGcLI9PgyGFb 4UuOZgmnpoiucu76y/osypZp6WWh8NCPoEG9QxHINXLgSUxZYElQCFICI43XhobRNDtf l0ufDGTgJzEhWIgDx46HmAM05qkCrHjWUswacvz1miE1oGpfL/NImPeDlkK1ruCaP8DR 3xOw== 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=rH4Apaq0+VlX9u8p0A2/rmOwDamCaVz2S44NsfLjatM=; b=OJv7Ehcxy928OEWIuD/L2N8SyehZ7h7Au7ttAxGosLCaDgAc0uFKe9lZI05WKq/ILd rS5msg6E5fyS8fnYFyexWwOQkR8I0JFgPRRBgt11yQaYwj6tapzWTp2dPaBecEDTx6Mt x2hM+QkwY/eiW9Kj7CvkCKCeKzCwbrgER8vqaOWiKbv+/PPeoHJbC2JjMCBZrarxOIMb T4EH0IGlXUJYL0NmLZdBk9M/eskHHS5Ziuj/eVXqHEdjEQaxaKDch4+lLxWJonSCfI7R 4wPrRjzMbK9vZvSbQZFgDSJxzqKM1WqMT2CpMjv0ICVt7GW0GrNF8SCgCYEOB7VqHohu nf8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U5h++Urt; 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 b129-v6si835937pfa.12.2018.07.17.05.08.56; Tue, 17 Jul 2018 05:09:11 -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=U5h++Urt; 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 S1731840AbeGQMkQ (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) -- 2.11.0