From: Kuniyuki Iwashima <kuniyu@google.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>
Cc: Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: [PATCH v1 net-next 04/11] neighbour: Remove __rcu from neigh_tables[].
Date: Thu, 6 Aug 2026 01:11:26 +0000 [thread overview]
Message-ID: <20260806011152.1170012-5-kuniyu@google.com> (raw)
In-Reply-To: <20260806011152.1170012-1-kuniyu@google.com>
Since commit 1bf20cc62a54 ("neighbour: remove obsolete
EXPORT_SYMBOL()") unexported neigh_table_init(), neigh_table
cannot be registered dynamically.
Let's remove RCU protection for neigh_tables[].
Note that neightbl_set() no longer needs RCU because it holds
spin_lock_bh(&tbl->lock).
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
net/core/neighbour.c | 23 +++++++++--------------
net/ipv4/arp.c | 3 +++
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 6fda0052027b..caa52bf64a2d 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1807,7 +1807,7 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
static struct lock_class_key neigh_table_proxy_queue_class;
-static struct neigh_table __rcu *neigh_tables[NEIGH_NR_TABLES] __read_mostly;
+static struct neigh_table *neigh_tables[NEIGH_NR_TABLES] __read_mostly;
void neigh_table_init(int index, struct neigh_table *tbl)
{
@@ -1864,7 +1864,7 @@ void neigh_table_init(int index, struct neigh_table *tbl)
tbl->last_flush = now;
tbl->last_rand = now + tbl->parms.reachable_time * 20;
- rcu_assign_pointer(neigh_tables[index], tbl);
+ neigh_tables[index] = tbl;
}
/*
@@ -1873,8 +1873,7 @@ void neigh_table_init(int index, struct neigh_table *tbl)
*/
int neigh_table_clear(int index, struct neigh_table *tbl)
{
- RCU_INIT_POINTER(neigh_tables[index], NULL);
- synchronize_rcu();
+ neigh_tables[index] = NULL;
/* It is not clean... Fix it to unload IPv6 module safely */
cancel_delayed_work_sync(&tbl->managed_work);
@@ -1906,10 +1905,10 @@ static struct neigh_table *neigh_find_table(int family)
switch (family) {
case AF_INET:
- tbl = rcu_dereference_rtnl(neigh_tables[NEIGH_ARP_TABLE]);
+ tbl = neigh_tables[NEIGH_ARP_TABLE];
break;
case AF_INET6:
- tbl = rcu_dereference_rtnl(neigh_tables[NEIGH_ND_TABLE]);
+ tbl = neigh_tables[NEIGH_ND_TABLE];
break;
}
@@ -2391,10 +2390,8 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh,
ndtmsg = nlmsg_data(nlh);
- rcu_read_lock();
-
for (tidx = 0; tidx < NEIGH_NR_TABLES; tidx++) {
- tbl = rcu_dereference(neigh_tables[tidx]);
+ tbl = neigh_tables[tidx];
if (!tbl)
continue;
@@ -2408,7 +2405,6 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh,
}
if (!found) {
- rcu_read_unlock();
err = -ENOENT;
goto errout;
}
@@ -2537,7 +2533,6 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh,
errout_tbl_lock:
spin_unlock_bh(&tbl->lock);
- rcu_read_unlock();
errout:
return err;
}
@@ -2589,7 +2584,7 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
for (tidx = 0; tidx < NEIGH_NR_TABLES; tidx++) {
struct neigh_parms *p;
- tbl = rcu_dereference(neigh_tables[tidx]);
+ tbl = neigh_tables[tidx];
if (!tbl)
continue;
@@ -2949,7 +2944,7 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
rcu_read_lock();
for (t = 0; t < NEIGH_NR_TABLES; t++) {
- tbl = rcu_dereference(neigh_tables[t]);
+ tbl = neigh_tables[t];
if (!tbl)
continue;
@@ -3162,7 +3157,7 @@ int neigh_xmit(int index, struct net_device *dev,
struct neighbour *neigh;
rcu_read_lock();
- tbl = rcu_dereference(neigh_tables[index]);
+ tbl = neigh_tables[index];
if (!tbl) {
rcu_read_unlock();
goto out_kfree_skb;
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index d409f606aec0..66063dd00aaa 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1495,9 +1495,12 @@ static const struct seq_operations arp_seq_ops = {
static int __net_init arp_net_init(struct net *net)
{
+#ifdef CONFIG_PROC_FS
if (!proc_create_net("arp", 0444, net->proc_net, &arp_seq_ops,
sizeof(struct neigh_seq_state)))
return -ENOMEM;
+#endif
+
return 0;
}
--
2.55.0.679.g6767b8d81c-goog
next prev parent reply other threads:[~2026-08-06 1:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 1:11 [PATCH v1 net-next 00/11] neighbour: Namespacify arp_tbl and nd_tbl Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 01/11] neighbour: Remove __neigh_for_each_release() Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 02/11] neighbour: Remove lock dance for neigh_update_{gc,managed}_list() Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 03/11] neighbour: Remove unnecessary EXPORT_SYMBOL() Kuniyuki Iwashima
2026-08-06 1:11 ` Kuniyuki Iwashima [this message]
2026-08-06 1:11 ` [PATCH v1 net-next 05/11] neighbour: Store arp_tbl and nd_tbl in net->neigh_tables[] Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 06/11] neighbour: Remove neigh_tables[] Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 07/11] ipv4: Replace &arp_tbl with arp_table(net) Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 08/11] ipv6: Replace &nd_tbl with nd_table(net) Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 09/11] neighbour: Clean up neigh_table_init() and neigh_table_clear() Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 10/11] neighbour: Namespacify neigh_tables Kuniyuki Iwashima
2026-08-06 1:11 ` [PATCH v1 net-next 11/11] neighbour: Remove unnecessary net_eq() Kuniyuki Iwashima
2026-08-06 3:38 ` [PATCH v1 net-next 00/11] neighbour: Namespacify arp_tbl and nd_tbl David Ahern
2026-08-06 13:45 ` Jakub Kicinski
2026-08-06 17:50 ` Kuniyuki Iwashima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260806011152.1170012-5-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox