Skip to content

Commit

Permalink
net: macvlan: add net device refcount tracker
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ziyang Xuan authored and David S. Miller committed Mar 14, 2022
1 parent 291ac68 commit 1f4a598
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/macvlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ static int macvlan_init(struct net_device *dev)
port->count += 1;

/* Get macvlan's reference to lowerdev */
dev_hold(lowerdev);
dev_hold_track(lowerdev, &vlan->dev_tracker, GFP_KERNEL);

return 0;
}
Expand Down Expand Up @@ -1181,7 +1181,7 @@ static void macvlan_dev_free(struct net_device *dev)
struct macvlan_dev *vlan = netdev_priv(dev);

/* 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)
Expand Down
1 change: 1 addition & 0 deletions include/linux/if_macvlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct macvlan_dev {
struct hlist_node hlist;
struct macvlan_port *port;
struct net_device *lowerdev;
netdevice_tracker dev_tracker;
void *accel_priv;
struct vlan_pcpu_stats __percpu *pcpu_stats;

Expand Down

0 comments on commit 1f4a598

Please sign in to comment.