提交 c04438f5 编写于 作者: E Eric Dumazet 提交者: Jakub Kicinski

ipv4: add net device refcount tracker to struct in_device

Signed-off-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
上级 8c727003
...@@ -24,6 +24,8 @@ struct ipv4_devconf { ...@@ -24,6 +24,8 @@ struct ipv4_devconf {
struct in_device { struct in_device {
struct net_device *dev; struct net_device *dev;
netdevice_tracker dev_tracker;
refcount_t refcnt; refcount_t refcnt;
int dead; int dead;
struct in_ifaddr __rcu *ifa_list;/* IP ifaddr chain */ struct in_ifaddr __rcu *ifa_list;/* IP ifaddr chain */
......
...@@ -243,7 +243,7 @@ void in_dev_finish_destroy(struct in_device *idev) ...@@ -243,7 +243,7 @@ void in_dev_finish_destroy(struct in_device *idev)
#ifdef NET_REFCNT_DEBUG #ifdef NET_REFCNT_DEBUG
pr_debug("%s: %p=%s\n", __func__, idev, dev ? dev->name : "NIL"); pr_debug("%s: %p=%s\n", __func__, idev, dev ? dev->name : "NIL");
#endif #endif
dev_put(dev); dev_put_track(dev, &idev->dev_tracker);
if (!idev->dead) if (!idev->dead)
pr_err("Freeing alive in_device %p\n", idev); pr_err("Freeing alive in_device %p\n", idev);
else else
...@@ -271,7 +271,7 @@ static struct in_device *inetdev_init(struct net_device *dev) ...@@ -271,7 +271,7 @@ static struct in_device *inetdev_init(struct net_device *dev)
if (IPV4_DEVCONF(in_dev->cnf, FORWARDING)) if (IPV4_DEVCONF(in_dev->cnf, FORWARDING))
dev_disable_lro(dev); dev_disable_lro(dev);
/* Reference in_dev->dev */ /* Reference in_dev->dev */
dev_hold(dev); dev_hold_track(dev, &in_dev->dev_tracker, GFP_KERNEL);
/* Account for reference dev->ip_ptr (below) */ /* Account for reference dev->ip_ptr (below) */
refcount_set(&in_dev->refcnt, 1); refcount_set(&in_dev->refcnt, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册