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>
This commit is contained in:

committed by
David S. Miller

parent
2f56f6be47
commit
60395a20ff
@@ -156,24 +156,7 @@ static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, _
|
||||
|
||||
static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey)
|
||||
{
|
||||
struct neigh_hash_table *nht;
|
||||
const u32 *p32 = pkey;
|
||||
struct neighbour *n;
|
||||
u32 hash_val;
|
||||
|
||||
nht = rcu_dereference_bh(nd_tbl.nht);
|
||||
hash_val = ndisc_hashfn(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift);
|
||||
for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]);
|
||||
n != NULL;
|
||||
n = rcu_dereference_bh(n->next)) {
|
||||
u32 *n32 = (u32 *) n->primary_key;
|
||||
if (n->dev == dev &&
|
||||
((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) |
|
||||
(n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0)
|
||||
return n;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return ___neigh_lookup_noref(&nd_tbl, neigh_key_eq128, ndisc_hashfn, pkey, dev);
|
||||
}
|
||||
|
||||
static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, const void *pkey)
|
||||
|
Reference in New Issue
Block a user