diff options
author | David Miller <davem@davemloft.net> | 2011-07-25 00:01:25 +0000 |
---|---|---|
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) | |
download | op-kernel-dev-596b9b68ef118f7409afbc78487263e08ef96261.zip op-kernel-dev-596b9b68ef118f7409afbc78487263e08ef96261.tar.gz |
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 661ad12..ef750ff 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) } EXPORT_SYMBOL(neigh_ifdown); -static struct neighbour *neigh_alloc(struct neigh_table *tbl) +static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device *dev) { struct neighbour *n = NULL; unsigned long now = jiffies; @@ -288,7 +288,15 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl) goto out_entries; } - n = kzalloc(tbl->entry_size, GFP_ATOMIC); + if (tbl->entry_size) + n = kzalloc(tbl->entry_size, GFP_ATOMIC); + else { + int sz = sizeof(*n) + tbl->key_len; + + sz = ALIGN(sz, NEIGH_PRIV_ALIGN); + sz += dev->neigh_priv_len; + n = kzalloc(sz, GFP_ATOMIC); + } if (!n) goto out_entries; @@ -463,7 +471,7 @@ struct neighbour *neigh_create(struct neigh_table *tbl, const void *pkey, u32 hash_val; int key_len = tbl->key_len; int error; - struct neighbour *n1, *rc, *n = neigh_alloc(tbl); + struct neighbour *n1, *rc, *n = neigh_alloc(tbl, dev); struct neigh_hash_table *nht; if (!n) { |