Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90442
b: refs/heads/master
c: be01d65
h: refs/heads/master
v: v3
  • Loading branch information
YOSHIFUJI Hideaki committed Mar 28, 2008
1 parent 75a571d commit e296f7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0a204500f913974b4ca9b6f509a43e1544239c6d
refs/heads/master: be01d655d9b07c1350b19bf3d80eae0059254b4b
61 changes: 29 additions & 32 deletions trunk/net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,26 +472,40 @@ struct neighbour *neigh_create(struct neigh_table *tbl, const void *pkey,
}
EXPORT_SYMBOL(neigh_create);

struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl,
struct net *net, const void *pkey, struct net_device *dev)
static u32 pneigh_hash(const void *pkey, int key_len)
{
struct pneigh_entry *n;
int key_len = tbl->key_len;
u32 hash_val = *(u32 *)(pkey + key_len - 4);

hash_val ^= (hash_val >> 16);
hash_val ^= hash_val >> 8;
hash_val ^= hash_val >> 4;
hash_val &= PNEIGH_HASHMASK;
return hash_val;
}

for (n = tbl->phash_buckets[hash_val]; n; n = n->next) {
static struct pneigh_entry *__pneigh_lookup_1(struct pneigh_entry *n,
struct net *net,
const void *pkey,
int key_len,
struct net_device *dev)
{
while (n) {
if (!memcmp(n->key, pkey, key_len) &&
(pneigh_net(n) == net) &&
net_eq(pneigh_net(n), net) &&
(n->dev == dev || !n->dev))
break;
return n;
n = n->next;
}
return NULL;
}

return n;
struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl,
struct net *net, const void *pkey, struct net_device *dev)
{
int key_len = tbl->key_len;
u32 hash_val = pneigh_hash(pkey, key_len);

return __pneigh_lookup_1(tbl->phash_buckets[hash_val],
net, pkey, key_len, dev);
}
EXPORT_SYMBOL_GPL(__pneigh_lookup);

Expand All @@ -501,26 +515,14 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
{
struct pneigh_entry *n;
int key_len = tbl->key_len;
u32 hash_val = *(u32 *)(pkey + key_len - 4);

hash_val ^= (hash_val >> 16);
hash_val ^= hash_val >> 8;
hash_val ^= hash_val >> 4;
hash_val &= PNEIGH_HASHMASK;
u32 hash_val = pneigh_hash(pkey, key_len);

read_lock_bh(&tbl->lock);

for (n = tbl->phash_buckets[hash_val]; n; n = n->next) {
if (!memcmp(n->key, pkey, key_len) &&
net_eq(pneigh_net(n), net) &&
(n->dev == dev || !n->dev)) {
read_unlock_bh(&tbl->lock);
goto out;
}
}
n = __pneigh_lookup_1(tbl->phash_buckets[hash_val],
net, pkey, key_len, dev);
read_unlock_bh(&tbl->lock);
n = NULL;
if (!creat)

if (n || !creat)
goto out;

ASSERT_RTNL();
Expand Down Expand Up @@ -561,12 +563,7 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey,
{
struct pneigh_entry *n, **np;
int key_len = tbl->key_len;
u32 hash_val = *(u32 *)(pkey + key_len - 4);

hash_val ^= (hash_val >> 16);
hash_val ^= hash_val >> 8;
hash_val ^= hash_val >> 4;
hash_val &= PNEIGH_HASHMASK;
u32 hash_val = pneigh_hash(pkey, key_len);

write_lock_bh(&tbl->lock);
for (np = &tbl->phash_buckets[hash_val]; (n = *np) != NULL;
Expand Down

0 comments on commit e296f7c

Please sign in to comment.