diff options
author | David Miller <davem@davemloft.net> | 2011-07-24 20:01:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-30 18:46:43 -0500 |
commit | 596b9b68ef118f7409afbc78487263e08ef96261 (patch) | |
tree | 0def3e591a0d5ede89e85339e35da3072f09330c /net/core/neighbour.c | |
parent | 5b8b0060cbd6332ae5d1fa0bec0e8e211248d0e7 (diff) |
neigh: Add infrastructure for allocating device neigh privates.
netdev->neigh_priv_len records the private area length.
This will trigger for neigh_table objects which set tbl->entry_size
to zero, and the first instances of this will be forthcoming.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/neighbour.c')
-rw-r--r-- | net/core/neighbour.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 661ad12e0cc9..ef750ff7497e 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -273,7 +273,7 @@ int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev) | |||
273 | } | 273 | } |
274 | EXPORT_SYMBOL(neigh_ifdown); | 274 | EXPORT_SYMBOL(neigh_ifdown); |
275 | 275 | ||
276 | static struct neighbour *neigh_alloc(struct neigh_table *tbl) | 276 | static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device *dev) |
277 | { | 277 | { |
278 | struct neighbour *n = NULL; | 278 | struct neighbour *n = NULL; |
279 | unsigned long now = jiffies; | 279 | unsigned long now = jiffies; |
@@ -288,7 +288,15 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl) | |||
288 | goto out_entries; | 288 | goto out_entries; |
289 | } | 289 | } |
290 | 290 | ||
291 | n = kzalloc(tbl->entry_size, GFP_ATOMIC); | 291 | if (tbl->entry_size) |
292 | n = kzalloc(tbl->entry_size, GFP_ATOMIC); | ||
293 | else { | ||
294 | int sz = sizeof(*n) + tbl->key_len; | ||
295 | |||
296 | sz = ALIGN(sz, NEIGH_PRIV_ALIGN); | ||
297 | sz += dev->neigh_priv_len; | ||
298 | n = kzalloc(sz, GFP_ATOMIC); | ||
299 | } | ||
292 | if (!n) | 300 | if (!n) |
293 | goto out_entries; | 301 | goto out_entries; |
294 | 302 | ||
@@ -463,7 +471,7 @@ struct neighbour *neigh_create(struct neigh_table *tbl, const void *pkey, | |||
463 | u32 hash_val; | 471 | u32 hash_val; |
464 | int key_len = tbl->key_len; | 472 | int key_len = tbl->key_len; |
465 | int error; | 473 | int error; |
466 | struct neighbour *n1, *rc, *n = neigh_alloc(tbl); | 474 | struct neighbour *n1, *rc, *n = neigh_alloc(tbl, dev); |
467 | struct neigh_hash_table *nht; | 475 | struct neigh_hash_table *nht; |
468 | 476 | ||
469 | if (!n) { | 477 | if (!n) { |