Skip to contentSkip to conversation

Bugfix in neigh_create

PATCH In review Raivis Bucis 2 participants 2 messages Jan 7, 2005 – Jan 8, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bugfix in neigh_create

Hello,

I believe that there is a bug in neigh_create in linux-2.4.28 introduced by neighbor cache backport from v2.6.9.

New neigh entry hash_val was calculated before possible hash growth. So it got inserted in wrong place, making ARP entry (that was inserted immediately after hash growth)
unresolvable until entry timeout.

It looked like this. The host did not answer to pings from some random host, but it could ping it after that with no problems. And vice versa.

Raivis Bucis

diff -uNr linux-2.4.28.org/net/core/neighbour.c
linux-2.4.28/net/core/neighbour.c

net/core/neighbour.c 2005-01-07 14:11:57.000000000 +0200 renamed from net/core/neighbour.c 2004-11-17 13:54:22.000000000 +0200 +3 -2
@@ -427,11 +427,12 @@
 
  n->confirmed = jiffies - (n->parms->base_reachable_time<<1);
 
- hash_val = tbl->hash(pkey, dev) & tbl->hash_mask;
-
  write_lock_bh(&tbl->lock);
  if (atomic_read(&tbl->entries) > (tbl->hash_mask + 1))
   neigh_hash_grow(tbl, (tbl->hash_mask + 1) << 1);
+
+ hash_val = tbl->hash(pkey, dev) & tbl->hash_mask;
+
  for (n1 = tbl->hash_buckets[hash_val]; n1; n1 = n1->next) {
   if (dev == n1->dev &&
       memcmp(n1->primary_key, pkey, key_len) == 0) {
#1 lore raw
Quoted 3 lines · Raivis Bucis

I believe that there is a bug in neigh_create in linux-2.4.28 introduced by neighbor cache backport from v2.6.9.

Yes you're right. Unfortunately your patch's been broken by your mailer. Can you please resend it to davem as an attachment?

Thanks,

Quoted 19 lines

diff -uNr linux-2.4.28.org/net/core/neighbour.c
linux-2.4.28/net/core/neighbour.c

net/core/neighbour.c 2005-01-07 14:11:57.000000000 +0200 renamed from net/core/neighbour.c 2004-11-17 13:54:22.000000000 +0200 +3 -2
@@ -427,11 +427,12 @@
 
 n->confirmed = jiffies - (n->parms->base_reachable_time<<1);
 
- hash_val = tbl->hash(pkey, dev) & tbl->hash_mask;
-
 write_lock_bh(&tbl->lock);
 if (atomic_read(&tbl->entries) > (tbl->hash_mask + 1))
  neigh_hash_grow(tbl, (tbl->hash_mask + 1) << 1);
+
+ hash_val = tbl->hash(pkey, dev) & tbl->hash_mask;
+
 for (n1 = tbl->hash_buckets[hash_val]; n1; n1 = n1->next) {
  if (dev == n1->dev &&
      memcmp(n1->primary_key, pkey, key_len) == 0) {
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt