Skip to content

Commit

Permalink
vlan: add net device refcount tracker
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Dec 8, 2021
1 parent 08f0b22 commit 19c9ebf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/linux/if_vlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ struct netpoll;
* @vlan_id: VLAN identifier
* @flags: device flags
* @real_dev: underlying netdevice
* @dev_tracker: refcount tracker for @real_dev reference
* @real_dev_addr: address of underlying netdevice
* @dent: proc dir entry
* @vlan_pcpu_stats: ptr to percpu rx stats
Expand All @@ -177,6 +178,8 @@ struct vlan_dev_priv {
u16 flags;

struct net_device *real_dev;
netdevice_tracker dev_tracker;

unsigned char real_dev_addr[ETH_ALEN];

struct proc_dir_entry *dent;
Expand Down
4 changes: 2 additions & 2 deletions net/8021q/vlan_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static int vlan_dev_init(struct net_device *dev)
return -ENOMEM;

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

return 0;
}
Expand Down Expand Up @@ -848,7 +848,7 @@ static void vlan_dev_free(struct net_device *dev)
vlan->vlan_pcpu_stats = NULL;

/* Get rid of the vlan's reference to real_dev */
dev_put(vlan->real_dev);
dev_put_track(vlan->real_dev, &vlan->dev_tracker);
}

void vlan_setup(struct net_device *dev)
Expand Down

0 comments on commit 19c9ebf

Please sign in to comment.