diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2025-10-25 03:57:27 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2025-10-25 03:57:28 +0300 |
| commit | 612868762544bd08d3800b7bbf9331b8abaa64ec (patch) | |
| tree | 80154b9872342952bfe0f5c46c7b2972566355f0 /include | |
| parent | f0a24b2547cfdd5ec85a131e386a2ce4ff9179cb (diff) | |
| parent | 3064d0fe02af23a3956d2b690461abb44da88cf4 (diff) | |
| download | linux-612868762544bd08d3800b7bbf9331b8abaa64ec.tar.xz | |
Merge branch 'neighbour-convert-rtm_getneightbl-and-rtm_setneightbl-to-rcu'
Kuniyuki Iwashima says:
====================
neighbour: Convert RTM_GETNEIGHTBL and RTM_SETNEIGHTBL to RCU.
Patch 1 & 2 are prep for RCU conversion for RTM_GETNEIGHTBL.
Patch 3 & 4 converts RTM_GETNEIGHTBL and RTM_SETNEIGHTBL to RCU.
Patch 5 converts the neighbour table rwlock to the plain spinlock.
====================
Link: https://patch.msgid.link/20251022054004.2514876-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/net/neighbour.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 4a30bd458c5a..2dfee6d4258a 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -92,15 +92,17 @@ struct neigh_parms { static inline void neigh_var_set(struct neigh_parms *p, int index, int val) { set_bit(index, p->data_state); - p->data[index] = val; + WRITE_ONCE(p->data[index], val); } -#define NEIGH_VAR(p, attr) ((p)->data[NEIGH_VAR_ ## attr]) +#define __NEIGH_VAR(p, attr) ((p)->data[NEIGH_VAR_ ## attr]) +#define NEIGH_VAR(p, attr) READ_ONCE(__NEIGH_VAR(p, attr)) +#define NEIGH_VAR_PTR(p, attr) (&(__NEIGH_VAR(p, attr))) /* In ndo_neigh_setup, NEIGH_VAR_INIT should be used. * In other cases, NEIGH_VAR_SET should be used. */ -#define NEIGH_VAR_INIT(p, attr, val) (NEIGH_VAR(p, attr) = val) +#define NEIGH_VAR_INIT(p, attr, val) (__NEIGH_VAR(p, attr) = val) #define NEIGH_VAR_SET(p, attr, val) neigh_var_set(p, NEIGH_VAR_ ## attr, val) static inline void neigh_parms_data_state_setall(struct neigh_parms *p) @@ -236,7 +238,7 @@ struct neigh_table { atomic_t gc_entries; struct list_head gc_list; struct list_head managed_list; - rwlock_t lock; + spinlock_t lock; unsigned long last_rand; struct neigh_statistics __percpu *stats; struct neigh_hash_table __rcu *nht; @@ -378,6 +380,13 @@ struct net *neigh_parms_net(const struct neigh_parms *parms) unsigned long neigh_rand_reach_time(unsigned long base); +static inline void neigh_set_reach_time(struct neigh_parms *p) +{ + unsigned long base = NEIGH_VAR(p, BASE_REACHABLE_TIME); + + WRITE_ONCE(p->reachable_time, neigh_rand_reach_time(base)); +} + void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, struct sk_buff *skb); struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net, |
