Skip to content

Commit 596b9b6

Browse files
committed
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>
1 parent 5b8b006 commit 596b9b6

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎drivers/infiniband/ulp/ipoib/ipoib_main.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,8 @@ static struct net_device *ipoib_add_port(const char *format,
12181218
priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu);
12191219
priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu;
12201220

1221+
priv->dev->neigh_priv_len = sizeof(struct ipoib_neigh);
1222+
12211223
result = ib_query_pkey(hca, port, 0, &priv->pkey);
12221224
if (result) {
12231225
printk(KERN_WARNING "%s: ib_query_pkey port %d failed (ret = %d)\n",

‎include/linux/netdevice.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ struct net_device {
10801080
unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
10811081
unsigned char addr_assign_type; /* hw address assignment type */
10821082
unsigned char addr_len; /* hardware address length */
1083+
unsigned char neigh_priv_len;
10831084
unsigned short dev_id; /* for shared network cards */
10841085

10851086
spinlock_t addr_list_lock;

‎net/atm/clip.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ static void clip_setup(struct net_device *dev)
535535
{
536536
dev->netdev_ops = &clip_netdev_ops;
537537
dev->type = ARPHRD_ATM;
538+
dev->neigh_priv_len = sizeof(struct atmarp_entry);
538539
dev->hard_header_len = RFC1483LLC_LEN;
539540
dev->mtu = RFC1626_MTU;
540541
dev->tx_queue_len = 100; /* "normal" queue (packets) */

‎net/core/neighbour.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
273273
}
274274
EXPORT_SYMBOL(neigh_ifdown);
275275

276-
static struct neighbour *neigh_alloc(struct neigh_table *tbl)
276+
static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device *dev)
277277
{
278278
struct neighbour *n = NULL;
279279
unsigned long now = jiffies;
@@ -288,7 +288,15 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl)
288288
goto out_entries;
289289
}
290290

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+
}
292300
if (!n)
293301
goto out_entries;
294302

@@ -463,7 +471,7 @@ struct neighbour *neigh_create(struct neigh_table *tbl, const void *pkey,
463471
u32 hash_val;
464472
int key_len = tbl->key_len;
465473
int error;
466-
struct neighbour *n1, *rc, *n = neigh_alloc(tbl);
474+
struct neighbour *n1, *rc, *n = neigh_alloc(tbl, dev);
467475
struct neigh_hash_table *nht;
468476

469477
if (!n) {

0 commit comments

Comments
 (0)