diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2015-03-03 18:10:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-04 00:23:23 -0500 |
commit | 60395a20ffd74166ea373ea91418d6f98fa7fdfb (patch) | |
tree | c4ed2b51ec4f179a48018d86660e6f2bb5b8bd81 /include/net/arp.h | |
parent | 2f56f6be47dbc6883e28107edfe2f9f98f4d5a24 (diff) |
neigh: Factor out ___neigh_lookup_noref
While looking at the mpls code I found myself writing yet another
version of neigh_lookup_noref. We currently have __ipv4_lookup_noref
and __ipv6_lookup_noref.
So to make my work a little easier and to make it a smidge easier to
verify/maintain the mpls code in the future I stopped and wrote
___neigh_lookup_noref. Then I rewote __ipv4_lookup_noref and
__ipv6_lookup_noref in terms of this new function. I tested my new
version by verifying that the same code is generated in
ip_finish_output2 and ip6_finish_output2 where these functions are
inlined.
To get to ___neigh_lookup_noref I added a new neighbour cache table
function key_eq. So that the static size of the key would be
available.
I also added __neigh_lookup_noref for people who want to to lookup
a neighbour table entry quickly but don't know which neibhgour table
they are going to look up.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/arp.h')
-rw-r--r-- | include/net/arp.h | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/include/net/arp.h b/include/net/arp.h index 21ee1860abbc..5e0f891d476c 100644 --- a/include/net/arp.h +++ b/include/net/arp.h | |||
@@ -9,28 +9,17 @@ | |||
9 | 9 | ||
10 | extern struct neigh_table arp_tbl; | 10 | extern struct neigh_table arp_tbl; |
11 | 11 | ||
12 | static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) | 12 | static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32 *hash_rnd) |
13 | { | 13 | { |
14 | u32 key = *(const u32 *)pkey; | ||
14 | u32 val = key ^ hash32_ptr(dev); | 15 | u32 val = key ^ hash32_ptr(dev); |
15 | 16 | ||
16 | return val * hash_rnd; | 17 | return val * hash_rnd[0]; |
17 | } | 18 | } |
18 | 19 | ||
19 | static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) | 20 | static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) |
20 | { | 21 | { |
21 | struct neigh_hash_table *nht = rcu_dereference_bh(arp_tbl.nht); | 22 | return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev); |
22 | struct neighbour *n; | ||
23 | u32 hash_val; | ||
24 | |||
25 | hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); | ||
26 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); | ||
27 | n != NULL; | ||
28 | n = rcu_dereference_bh(n->next)) { | ||
29 | if (n->dev == dev && *(u32 *)n->primary_key == key) | ||
30 | return n; | ||
31 | } | ||
32 | |||
33 | return NULL; | ||
34 | } | 23 | } |
35 | 24 | ||
36 | static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) | 25 | static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) |