Skip to content

Commit d6bf781

Browse files
Eric Dumazetdavem330
authored andcommitted
net neigh: RCU conversion of neigh hash table
David This is the first step for RCU conversion of neigh code. Next patches will convert hash_buckets[] and "struct neighbour" to RCU protected objects. Thanks [PATCH net-next] net neigh: RCU conversion of neigh hash table Instead of storing hash_buckets, hash_mask and hash_rnd in "struct neigh_table", a new structure is defined : struct neigh_hash_table { struct neighbour **hash_buckets; unsigned int hash_mask; __u32 hash_rnd; struct rcu_head rcu; }; And "struct neigh_table" has an RCU protected pointer to such a neigh_hash_table. This means the signature of (*hash)() function changed: We need to add a third parameter with the actual hash_rnd value, since this is not anymore a neigh_table field. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 110b249 commit d6bf781

File tree

6 files changed

+170
-100
lines changed

6 files changed

+170
-100
lines changed

include/net/neighbour.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,22 @@ struct pneigh_entry {
138138
* neighbour table manipulation
139139
*/
140140

141+
struct neigh_hash_table {
142+
struct neighbour **hash_buckets;
143+
unsigned int hash_mask;
144+
__u32 hash_rnd;
145+
struct rcu_head rcu;
146+
};
147+
141148

142149
struct neigh_table {
143150
struct neigh_table *next;
144151
int family;
145152
int entry_size;
146153
int key_len;
147-
__u32 (*hash)(const void *pkey, const struct net_device *);
154+
__u32 (*hash)(const void *pkey,
155+
const struct net_device *dev,
156+
__u32 hash_rnd);
148157
int (*constructor)(struct neighbour *);
149158
int (*pconstructor)(struct pneigh_entry *);
150159
void (*pdestructor)(struct pneigh_entry *);
@@ -165,9 +174,7 @@ struct neigh_table {
165174
unsigned long last_rand;
166175
struct kmem_cache *kmem_cachep;
167176
struct neigh_statistics __percpu *stats;
168-
struct neighbour **hash_buckets;
169-
unsigned int hash_mask;
170-
__u32 hash_rnd;
177+
struct neigh_hash_table __rcu *nht;
171178
struct pneigh_entry **phash_buckets;
172179
};
173180

@@ -237,6 +244,7 @@ extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_en
237244
struct neigh_seq_state {
238245
struct seq_net_private p;
239246
struct neigh_table *tbl;
247+
struct neigh_hash_table *nht;
240248
void *(*neigh_sub_iter)(struct neigh_seq_state *state,
241249
struct neighbour *n, loff_t *pos);
242250
unsigned int bucket;

net/atm/clip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ static int clip_constructor(struct neighbour *neigh)
310310
return 0;
311311
}
312312

313-
static u32 clip_hash(const void *pkey, const struct net_device *dev)
313+
static u32 clip_hash(const void *pkey, const struct net_device *dev, __u32 rnd)
314314
{
315-
return jhash_2words(*(u32 *) pkey, dev->ifindex, clip_tbl.hash_rnd);
315+
return jhash_2words(*(u32 *) pkey, dev->ifindex, rnd);
316316
}
317317

318318
static struct neigh_table clip_tbl = {

0 commit comments

Comments
 (0)