Skip to content

Commit

Permalink
net: add net device refcount tracker to struct neighbour
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Dec 7, 2021
1 parent 56c1c77 commit 85662c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/net/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ struct neighbour {
struct list_head managed_list;
struct rcu_head rcu;
struct net_device *dev;
netdevice_tracker dev_tracker;
u8 primary_key[0];
} __randomize_layout;

Expand Down
4 changes: 2 additions & 2 deletions net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ ___neigh_create(struct neigh_table *tbl, const void *pkey,

memcpy(n->primary_key, pkey, key_len);
n->dev = dev;
dev_hold(dev);
dev_hold_track(dev, &n->dev_tracker, GFP_ATOMIC);

/* Protocol specific setup. */
if (tbl->constructor && (error = tbl->constructor(n)) < 0) {
Expand Down Expand Up @@ -880,7 +880,7 @@ void neigh_destroy(struct neighbour *neigh)
if (dev->netdev_ops->ndo_neigh_destroy)
dev->netdev_ops->ndo_neigh_destroy(dev, neigh);

dev_put(dev);
dev_put_track(dev, &neigh->dev_tracker);
neigh_parms_put(neigh->parms);

neigh_dbg(2, "neigh %p is destroyed\n", neigh);
Expand Down

0 comments on commit 85662c9

Please sign in to comment.