diff options
Diffstat (limited to 'include/net/arp.h')
-rw-r--r-- | include/net/arp.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/include/net/arp.h b/include/net/arp.h index 4a1f3fb562eb..7f7df93f37cd 100644 --- a/include/net/arp.h +++ b/include/net/arp.h | |||
@@ -15,24 +15,31 @@ static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd | |||
15 | return val * hash_rnd; | 15 | return val * hash_rnd; |
16 | } | 16 | } |
17 | 17 | ||
18 | static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) | 18 | static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) |
19 | { | 19 | { |
20 | struct neigh_hash_table *nht; | 20 | struct neigh_hash_table *nht = rcu_dereference_bh(arp_tbl.nht); |
21 | struct neighbour *n; | 21 | struct neighbour *n; |
22 | u32 hash_val; | 22 | u32 hash_val; |
23 | 23 | ||
24 | rcu_read_lock_bh(); | ||
25 | nht = rcu_dereference_bh(arp_tbl.nht); | ||
26 | hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); | 24 | hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); |
27 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); | 25 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); |
28 | n != NULL; | 26 | n != NULL; |
29 | n = rcu_dereference_bh(n->next)) { | 27 | n = rcu_dereference_bh(n->next)) { |
30 | if (n->dev == dev && *(u32 *)n->primary_key == key) { | 28 | if (n->dev == dev && *(u32 *)n->primary_key == key) |
31 | if (!atomic_inc_not_zero(&n->refcnt)) | 29 | return n; |
32 | n = NULL; | ||
33 | break; | ||
34 | } | ||
35 | } | 30 | } |
31 | |||
32 | return NULL; | ||
33 | } | ||
34 | |||
35 | static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) | ||
36 | { | ||
37 | struct neighbour *n; | ||
38 | |||
39 | rcu_read_lock_bh(); | ||
40 | n = __ipv4_neigh_lookup_noref(dev, key); | ||
41 | if (n && !atomic_inc_not_zero(&n->refcnt)) | ||
42 | n = NULL; | ||
36 | rcu_read_unlock_bh(); | 43 | rcu_read_unlock_bh(); |
37 | 44 | ||
38 | return n; | 45 | return n; |