Commit 08d62256 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

net: add net device refcount tracker to struct neigh_parms

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 77a23b1f
...@@ -70,6 +70,7 @@ enum { ...@@ -70,6 +70,7 @@ enum {
struct neigh_parms { struct neigh_parms {
possible_net_t net; possible_net_t net;
struct net_device *dev; struct net_device *dev;
netdevice_tracker dev_tracker;
struct list_head list; struct list_head list;
int (*neigh_setup)(struct neighbour *); int (*neigh_setup)(struct neighbour *);
struct neigh_table *tbl; struct neigh_table *tbl;
......
...@@ -1666,13 +1666,13 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev, ...@@ -1666,13 +1666,13 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
refcount_set(&p->refcnt, 1); refcount_set(&p->refcnt, 1);
p->reachable_time = p->reachable_time =
neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME)); neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME));
dev_hold(dev); dev_hold_track(dev, &p->dev_tracker, GFP_KERNEL);
p->dev = dev; p->dev = dev;
write_pnet(&p->net, net); write_pnet(&p->net, net);
p->sysctl_table = NULL; p->sysctl_table = NULL;
if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) { if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) {
dev_put(dev); dev_put_track(dev, &p->dev_tracker);
kfree(p); kfree(p);
return NULL; return NULL;
} }
...@@ -1703,7 +1703,7 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms) ...@@ -1703,7 +1703,7 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
list_del(&parms->list); list_del(&parms->list);
parms->dead = 1; parms->dead = 1;
write_unlock_bh(&tbl->lock); write_unlock_bh(&tbl->lock);
dev_put(parms->dev); dev_put_track(parms->dev, &parms->dev_tracker);
call_rcu(&parms->rcu_head, neigh_rcu_free_parms); call_rcu(&parms->rcu_head, neigh_rcu_free_parms);
} }
EXPORT_SYMBOL(neigh_parms_release); EXPORT_SYMBOL(neigh_parms_release);
......
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