drop_monitor: add net device refcount tracker

We want to track all dev_hold()/dev_put() to ease leak hunting.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Eric Dumazet 2021-12-04 20:22:02 -08:00 committed by Jakub Kicinski
parent 14ed029b5e
commit 4dbd24f65c
2 changed files with 7 additions and 3 deletions

View File

@ -664,13 +664,17 @@ struct devlink_health_reporter_ops {
* @trap_name: Trap name.
* @trap_group_name: Trap group name.
* @input_dev: Input netdevice.
* @dev_tracker: refcount tracker for @input_dev.
* @fa_cookie: Flow action user cookie.
* @trap_type: Trap type.
*/
struct devlink_trap_metadata {
const char *trap_name;
const char *trap_group_name;
struct net_device *input_dev;
netdevice_tracker dev_tracker;
const struct flow_action_cookie *fa_cookie;
enum devlink_trap_type trap_type;
};

View File

@ -850,7 +850,7 @@ net_dm_hw_metadata_copy(const struct devlink_trap_metadata *metadata)
}
hw_metadata->input_dev = metadata->input_dev;
dev_hold(hw_metadata->input_dev);
dev_hold_track(hw_metadata->input_dev, &hw_metadata->dev_tracker, GFP_ATOMIC);
return hw_metadata;
@ -864,9 +864,9 @@ free_hw_metadata:
}
static void
net_dm_hw_metadata_free(const struct devlink_trap_metadata *hw_metadata)
net_dm_hw_metadata_free(struct devlink_trap_metadata *hw_metadata)
{
dev_put(hw_metadata->input_dev);
dev_put_track(hw_metadata->input_dev, &hw_metadata->dev_tracker);
kfree(hw_metadata->fa_cookie);
kfree(hw_metadata->trap_name);
kfree(hw_metadata->trap_group_name);