Skip to content

Commit

Permalink
net: linkwatch: add net device refcount tracker
Browse files Browse the repository at this point in the history
Add a netdevice_tracker inside struct net_device, to track
the self reference when a device is in lweventlist.

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 7, 2021
1 parent 606509f commit 63f1393
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,7 @@ enum netdev_ml_priv_type {
* keep a list of interfaces to be deleted.
*
* @dev_addr_shadow: Copy of @dev_addr to catch direct writes.
* @linkwatch_dev_tracker: refcount tracker used by linkwatch.
*
* FIXME: cleanup struct net_device such that network protocol info
* moves out.
Expand Down Expand Up @@ -2280,6 +2281,7 @@ struct net_device {
struct bpf_xdp_entity xdp_state[__MAX_XDP_MODE];

u8 dev_addr_shadow[MAX_ADDR_LEN];
netdevice_tracker linkwatch_dev_tracker;
};
#define to_net_dev(d) container_of(d, struct net_device, dev)

Expand Down
4 changes: 2 additions & 2 deletions net/core/link_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void linkwatch_add_event(struct net_device *dev)
spin_lock_irqsave(&lweventlist_lock, flags);
if (list_empty(&dev->link_watch_list)) {
list_add_tail(&dev->link_watch_list, &lweventlist);
dev_hold(dev);
dev_hold_track(dev, &dev->linkwatch_dev_tracker, GFP_ATOMIC);
}
spin_unlock_irqrestore(&lweventlist_lock, flags);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ static void linkwatch_do_dev(struct net_device *dev)

netdev_state_change(dev);
}
dev_put(dev);
dev_put_track(dev, &dev->linkwatch_dev_tracker);
}

static void __linkwatch_run_queue(int urgent_only)
Expand Down

0 comments on commit 63f1393

Please sign in to comment.