ipv6: add net device refcount tracker to struct inet6_dev

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Eric Dumazet 2021-12-04 20:22:11 -08:00 committed by Jakub Kicinski
parent f77159a348
commit 8c727003c4
3 changed files with 4 additions and 3 deletions

View File

@ -160,6 +160,7 @@ struct ipv6_devstat {
struct inet6_dev { struct inet6_dev {
struct net_device *dev; struct net_device *dev;
netdevice_tracker dev_tracker;
struct list_head addr_list; struct list_head addr_list;

View File

@ -405,13 +405,13 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
if (ndev->cnf.forwarding) if (ndev->cnf.forwarding)
dev_disable_lro(dev); dev_disable_lro(dev);
/* We refer to the device */ /* We refer to the device */
dev_hold(dev); dev_hold_track(dev, &ndev->dev_tracker, GFP_KERNEL);
if (snmp6_alloc_dev(ndev) < 0) { if (snmp6_alloc_dev(ndev) < 0) {
netdev_dbg(dev, "%s: cannot allocate memory for statistics\n", netdev_dbg(dev, "%s: cannot allocate memory for statistics\n",
__func__); __func__);
neigh_parms_release(&nd_tbl, ndev->nd_parms); neigh_parms_release(&nd_tbl, ndev->nd_parms);
dev_put(dev); dev_put_track(dev, &ndev->dev_tracker);
kfree(ndev); kfree(ndev);
return ERR_PTR(err); return ERR_PTR(err);
} }

View File

@ -263,7 +263,7 @@ void in6_dev_finish_destroy(struct inet6_dev *idev)
#ifdef NET_REFCNT_DEBUG #ifdef NET_REFCNT_DEBUG
pr_debug("%s: %s\n", __func__, dev ? dev->name : "NIL"); pr_debug("%s: %s\n", __func__, dev ? dev->name : "NIL");
#endif #endif
dev_put(dev); dev_put_track(dev, &idev->dev_tracker);
if (!idev->dead) { if (!idev->dead) {
pr_warn("Freeing alive inet6 device %p\n", idev); pr_warn("Freeing alive inet6 device %p\n", idev);
return; return;