Skip to content

Commit

Permalink
net: add net device refcount tracker to struct pneigh_entry
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 85662c9 commit 77a23b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/net/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ struct pneigh_entry {
struct pneigh_entry *next;
possible_net_t net;
struct net_device *dev;
netdevice_tracker dev_tracker;
u32 flags;
u8 protocol;
u8 key[];
Expand Down
8 changes: 4 additions & 4 deletions net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
write_pnet(&n->net, net);
memcpy(n->key, pkey, key_len);
n->dev = dev;
dev_hold(dev);
dev_hold_track(dev, &n->dev_tracker, GFP_KERNEL);

if (tbl->pconstructor && tbl->pconstructor(n)) {
dev_put(dev);
dev_put_track(dev, &n->dev_tracker);
kfree(n);
n = NULL;
goto out;
Expand Down Expand Up @@ -806,7 +806,7 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey,
write_unlock_bh(&tbl->lock);
if (tbl->pdestructor)
tbl->pdestructor(n);
dev_put(n->dev);
dev_put_track(n->dev, &n->dev_tracker);
kfree(n);
return 0;
}
Expand Down Expand Up @@ -839,7 +839,7 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl,
n->next = NULL;
if (tbl->pdestructor)
tbl->pdestructor(n);
dev_put(n->dev);
dev_put_track(n->dev, &n->dev_tracker);
kfree(n);
}
return -ENOENT;
Expand Down

0 comments on commit 77a23b1

Please sign in to comment.