net: macvlan: add net device refcount tracker

Add net device refcount tracker to macvlan.

Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ziyang Xuan 2022-03-11 17:04:03 +08:00 committed by David S. Miller
parent 291ac68478
commit 1f4a5983d6
2 changed files with 3 additions and 2 deletions

View File

@ -912,7 +912,7 @@ static int macvlan_init(struct net_device *dev)
port->count += 1; port->count += 1;
/* Get macvlan's reference to lowerdev */ /* Get macvlan's reference to lowerdev */
dev_hold(lowerdev); dev_hold_track(lowerdev, &vlan->dev_tracker, GFP_KERNEL);
return 0; return 0;
} }
@ -1181,7 +1181,7 @@ static void macvlan_dev_free(struct net_device *dev)
struct macvlan_dev *vlan = netdev_priv(dev); struct macvlan_dev *vlan = netdev_priv(dev);
/* Get rid of the macvlan's reference to lowerdev */ /* Get rid of the macvlan's reference to lowerdev */
dev_put(vlan->lowerdev); dev_put_track(vlan->lowerdev, &vlan->dev_tracker);
} }
void macvlan_common_setup(struct net_device *dev) void macvlan_common_setup(struct net_device *dev)

View File

@ -21,6 +21,7 @@ struct macvlan_dev {
struct hlist_node hlist; struct hlist_node hlist;
struct macvlan_port *port; struct macvlan_port *port;
struct net_device *lowerdev; struct net_device *lowerdev;
netdevice_tracker dev_tracker;
void *accel_priv; void *accel_priv;
struct vlan_pcpu_stats __percpu *pcpu_stats; struct vlan_pcpu_stats __percpu *pcpu_stats;