diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-01-19 17:02:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-20 19:59:34 -0500 |
commit | 6193d2be290990b789021e06fa770ecb45319f2d (patch) | |
tree | b350cd567603e490226469b9624c6cbe514df7e6 /net/core/neighbour.c | |
parent | 753ea8e96258d87be1951083b5c4a368524515f1 (diff) |
neigh: __rcu annotations
fix some minor issues and sparse (__rcu) warnings
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/neighbour.c')
-rw-r--r-- | net/core/neighbour.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 60a902913429..799f06e03a22 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -316,7 +316,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries) | |||
316 | { | 316 | { |
317 | size_t size = entries * sizeof(struct neighbour *); | 317 | size_t size = entries * sizeof(struct neighbour *); |
318 | struct neigh_hash_table *ret; | 318 | struct neigh_hash_table *ret; |
319 | struct neighbour **buckets; | 319 | struct neighbour __rcu **buckets; |
320 | 320 | ||
321 | ret = kmalloc(sizeof(*ret), GFP_ATOMIC); | 321 | ret = kmalloc(sizeof(*ret), GFP_ATOMIC); |
322 | if (!ret) | 322 | if (!ret) |
@@ -324,14 +324,14 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries) | |||
324 | if (size <= PAGE_SIZE) | 324 | if (size <= PAGE_SIZE) |
325 | buckets = kzalloc(size, GFP_ATOMIC); | 325 | buckets = kzalloc(size, GFP_ATOMIC); |
326 | else | 326 | else |
327 | buckets = (struct neighbour **) | 327 | buckets = (struct neighbour __rcu **) |
328 | __get_free_pages(GFP_ATOMIC | __GFP_ZERO, | 328 | __get_free_pages(GFP_ATOMIC | __GFP_ZERO, |
329 | get_order(size)); | 329 | get_order(size)); |
330 | if (!buckets) { | 330 | if (!buckets) { |
331 | kfree(ret); | 331 | kfree(ret); |
332 | return NULL; | 332 | return NULL; |
333 | } | 333 | } |
334 | rcu_assign_pointer(ret->hash_buckets, buckets); | 334 | ret->hash_buckets = buckets; |
335 | ret->hash_mask = entries - 1; | 335 | ret->hash_mask = entries - 1; |
336 | get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd)); | 336 | get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd)); |
337 | return ret; | 337 | return ret; |
@@ -343,7 +343,7 @@ static void neigh_hash_free_rcu(struct rcu_head *head) | |||
343 | struct neigh_hash_table, | 343 | struct neigh_hash_table, |
344 | rcu); | 344 | rcu); |
345 | size_t size = (nht->hash_mask + 1) * sizeof(struct neighbour *); | 345 | size_t size = (nht->hash_mask + 1) * sizeof(struct neighbour *); |
346 | struct neighbour **buckets = nht->hash_buckets; | 346 | struct neighbour __rcu **buckets = nht->hash_buckets; |
347 | 347 | ||
348 | if (size <= PAGE_SIZE) | 348 | if (size <= PAGE_SIZE) |
349 | kfree(buckets); | 349 | kfree(buckets); |
@@ -1540,7 +1540,7 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl) | |||
1540 | panic("cannot create neighbour proc dir entry"); | 1540 | panic("cannot create neighbour proc dir entry"); |
1541 | #endif | 1541 | #endif |
1542 | 1542 | ||
1543 | tbl->nht = neigh_hash_alloc(8); | 1543 | RCU_INIT_POINTER(tbl->nht, neigh_hash_alloc(8)); |
1544 | 1544 | ||
1545 | phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *); | 1545 | phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *); |
1546 | tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL); | 1546 | tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL); |
@@ -1602,7 +1602,8 @@ int neigh_table_clear(struct neigh_table *tbl) | |||
1602 | } | 1602 | } |
1603 | write_unlock(&neigh_tbl_lock); | 1603 | write_unlock(&neigh_tbl_lock); |
1604 | 1604 | ||
1605 | call_rcu(&tbl->nht->rcu, neigh_hash_free_rcu); | 1605 | call_rcu(&rcu_dereference_protected(tbl->nht, 1)->rcu, |
1606 | neigh_hash_free_rcu); | ||
1606 | tbl->nht = NULL; | 1607 | tbl->nht = NULL; |
1607 | 1608 | ||
1608 | kfree(tbl->phash_buckets); | 1609 | kfree(tbl->phash_buckets); |