diff options
Diffstat (limited to 'net/core/neighbour.c')
-rw-r--r-- | net/core/neighbour.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index c815f285e5ab..3863b8f639c5 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -290,15 +290,7 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device | |||
290 | goto out_entries; | 290 | goto out_entries; |
291 | } | 291 | } |
292 | 292 | ||
293 | if (tbl->entry_size) | 293 | n = kzalloc(tbl->entry_size + dev->neigh_priv_len, GFP_ATOMIC); |
294 | n = kzalloc(tbl->entry_size, GFP_ATOMIC); | ||
295 | else { | ||
296 | int sz = sizeof(*n) + tbl->key_len; | ||
297 | |||
298 | sz = ALIGN(sz, NEIGH_PRIV_ALIGN); | ||
299 | sz += dev->neigh_priv_len; | ||
300 | n = kzalloc(sz, GFP_ATOMIC); | ||
301 | } | ||
302 | if (!n) | 294 | if (!n) |
303 | goto out_entries; | 295 | goto out_entries; |
304 | 296 | ||
@@ -778,6 +770,9 @@ static void neigh_periodic_work(struct work_struct *work) | |||
778 | nht = rcu_dereference_protected(tbl->nht, | 770 | nht = rcu_dereference_protected(tbl->nht, |
779 | lockdep_is_held(&tbl->lock)); | 771 | lockdep_is_held(&tbl->lock)); |
780 | 772 | ||
773 | if (atomic_read(&tbl->entries) < tbl->gc_thresh1) | ||
774 | goto out; | ||
775 | |||
781 | /* | 776 | /* |
782 | * periodically recompute ReachableTime from random function | 777 | * periodically recompute ReachableTime from random function |
783 | */ | 778 | */ |
@@ -832,6 +827,7 @@ next_elt: | |||
832 | nht = rcu_dereference_protected(tbl->nht, | 827 | nht = rcu_dereference_protected(tbl->nht, |
833 | lockdep_is_held(&tbl->lock)); | 828 | lockdep_is_held(&tbl->lock)); |
834 | } | 829 | } |
830 | out: | ||
835 | /* Cycle through all hash buckets every base_reachable_time/2 ticks. | 831 | /* Cycle through all hash buckets every base_reachable_time/2 ticks. |
836 | * ARP entry timeouts range from 1/2 base_reachable_time to 3/2 | 832 | * ARP entry timeouts range from 1/2 base_reachable_time to 3/2 |
837 | * base_reachable_time. | 833 | * base_reachable_time. |
@@ -1542,6 +1538,12 @@ static void neigh_table_init_no_netlink(struct neigh_table *tbl) | |||
1542 | if (!tbl->nht || !tbl->phash_buckets) | 1538 | if (!tbl->nht || !tbl->phash_buckets) |
1543 | panic("cannot allocate neighbour cache hashes"); | 1539 | panic("cannot allocate neighbour cache hashes"); |
1544 | 1540 | ||
1541 | if (!tbl->entry_size) | ||
1542 | tbl->entry_size = ALIGN(offsetof(struct neighbour, primary_key) + | ||
1543 | tbl->key_len, NEIGH_PRIV_ALIGN); | ||
1544 | else | ||
1545 | WARN_ON(tbl->entry_size % NEIGH_PRIV_ALIGN); | ||
1546 | |||
1545 | rwlock_init(&tbl->lock); | 1547 | rwlock_init(&tbl->lock); |
1546 | INIT_DEFERRABLE_WORK(&tbl->gc_work, neigh_periodic_work); | 1548 | INIT_DEFERRABLE_WORK(&tbl->gc_work, neigh_periodic_work); |
1547 | schedule_delayed_work(&tbl->gc_work, tbl->parms.reachable_time); | 1549 | schedule_delayed_work(&tbl->gc_work, tbl->parms.reachable_time); |