Commit 4dbd24f6 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

drop_monitor: add net device refcount tracker

We want to track all dev_hold()/dev_put() to ease leak hunting.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 14ed029b
......@@ -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;
};
......
......@@ -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 @@ net_dm_hw_metadata_copy(const struct devlink_trap_metadata *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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment