Commit 77a23b1f authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

net: add net device refcount tracker to struct pneigh_entry

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 85662c9f
...@@ -174,6 +174,7 @@ struct pneigh_entry { ...@@ -174,6 +174,7 @@ struct pneigh_entry {
struct pneigh_entry *next; struct pneigh_entry *next;
possible_net_t net; possible_net_t net;
struct net_device *dev; struct net_device *dev;
netdevice_tracker dev_tracker;
u32 flags; u32 flags;
u8 protocol; u8 protocol;
u8 key[]; u8 key[];
......
...@@ -771,10 +771,10 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl, ...@@ -771,10 +771,10 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
write_pnet(&n->net, net); write_pnet(&n->net, net);
memcpy(n->key, pkey, key_len); memcpy(n->key, pkey, key_len);
n->dev = dev; n->dev = dev;
dev_hold(dev); dev_hold_track(dev, &n->dev_tracker, GFP_KERNEL);
if (tbl->pconstructor && tbl->pconstructor(n)) { if (tbl->pconstructor && tbl->pconstructor(n)) {
dev_put(dev); dev_put_track(dev, &n->dev_tracker);
kfree(n); kfree(n);
n = NULL; n = NULL;
goto out; goto out;
...@@ -806,7 +806,7 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey, ...@@ -806,7 +806,7 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey,
write_unlock_bh(&tbl->lock); write_unlock_bh(&tbl->lock);
if (tbl->pdestructor) if (tbl->pdestructor)
tbl->pdestructor(n); tbl->pdestructor(n);
dev_put(n->dev); dev_put_track(n->dev, &n->dev_tracker);
kfree(n); kfree(n);
return 0; return 0;
} }
...@@ -839,7 +839,7 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl, ...@@ -839,7 +839,7 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl,
n->next = NULL; n->next = NULL;
if (tbl->pdestructor) if (tbl->pdestructor)
tbl->pdestructor(n); tbl->pdestructor(n);
dev_put(n->dev); dev_put_track(n->dev, &n->dev_tracker);
kfree(n); kfree(n);
} }
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment