batman-adv: adopt netdev_hold() / netdev_put()
Subsystems (3)
PATCH 1/1 batman-adv: adopt netdev_hold() / netdev_put()
Add a device tracker to struct batadv_hard_iface to help debugging of network device refcount imbalances.
--- net/batman-adv/hard-interface.c | 14 +++++--------- net/batman-adv/types.h | 3 +++ 2 files changed, 8 insertions(+), 9 deletions(-)
net/batman-adv/hard-interface.c +5 -9
@@ -51,7 +51,7 @@ void batadv_hardif_release(struct kref *ref)struct batadv_hard_iface *hard_iface; hard_iface = container_of(ref, struct batadv_hard_iface, refcount); -dev_put (hard_iface->net_dev); +netdev_put (hard_iface->net_dev, &hard_iface->dev_tracker);kfree_rcu (hard_iface, rcu); }
@@ -875,15 +875,16 @@ batadv_hardif_add_interface(struct net_device *net_dev)ASSERT_RTNL ();if (!batadv_is_valid_iface (net_dev)) - goto out; +return NULL ; -dev_hold (net_dev); hard_iface =kzalloc (sizeof (*hard_iface),GFP_ATOMIC );if (!hard_iface) - goto release_dev; +return NULL ; +netdev_hold (net_dev, &hard_iface->dev_tracker,GFP_ATOMIC ); hard_iface->net_dev = net_dev; + hard_iface->soft_iface =NULL ; hard_iface->if_status =BATADV_IF_NOT_IN_USE ;
@@ -909,11 +910,6 @@ batadv_hardif_add_interface(struct net_device *net_dev) batadv_hardif_generation++;return hard_iface; - -release_dev: -dev_put (net_dev); -out: -return NULL ; }static void batadv_hardif_remove_interface (struct batadv_hard_iface *hard_iface)
net/batman-adv/types.h +3 -0
@@ -186,6 +186,9 @@ struct batadv_hard_iface {/** @net_dev: pointer to the net_device */ struct net_device *net_dev; +/** @dev_tracker device tracker for @net_dev */ +netdevice_tracker dev_tracker; +/** @refcount: number of contexts the object is used */ struct kref refcount;
Signature · 1 line
2.48.1.362.g079036d154-goog
Quoted 59 lines · Eric Dumazet
Add a device tracker to struct
batadv_hard_ifaceto help debugging of network device refcount imbalances.Signed-off-by Eric Dumazet <[email protected]>--- net/batman-adv/hard-interface.c | 14 +++++--------- net/batman-adv/types.h | 3 +++ 2 files changed, 8 insertions(+), 9 deletions(-)net/batman-adv/hard-interface.c +5
-9@@ -51,7 +51,7 @@ void batadv_hardif_release(struct kref *ref)struct batadv_hard_iface *hard_iface; hard_iface = container_of(ref, struct batadv_hard_iface, refcount); -dev_put (hard_iface->net_dev); +netdev_put (hard_iface->net_dev, &hard_iface->dev_tracker);kfree_rcu (hard_iface, rcu); }@@ -875,15 +875,16 @@ batadv_hardif_add_interface(struct net_device *net_dev)ASSERT_RTNL ();if (!batadv_is_valid_iface (net_dev)) - goto out; +return NULL ; -dev_hold (net_dev); hard_iface =kzalloc (sizeof (*hard_iface),GFP_ATOMIC );if (!hard_iface) - goto release_dev; +return NULL ; +netdev_hold (net_dev, &hard_iface->dev_tracker,GFP_ATOMIC ); hard_iface->net_dev = net_dev; + hard_iface->soft_iface =NULL ; hard_iface->if_status =BATADV_IF_NOT_IN_USE ;@@ -909,11 +910,6 @@ batadv_hardif_add_interface(struct net_device *net_dev) batadv_hardif_generation++;return hard_iface; - -release_dev: -dev_put (net_dev); -out: -return NULL ; }static void batadv_hardif_remove_interface (struct batadv_hard_iface *hard_iface)net/batman-adv/types.h +0
-0
net/batman-adv/types.h struct batadv_hard_iface { · line 190
Quoted 5 lines
net/batman-adv/types.h +2
-0@@ -186,6 +186,9 @@ struct batadv_hard_iface {/** @net_dev: pointer to the net_device */ struct net_device *net_dev; +/** @dev_tracker device tracker for @net_dev */ +netdevice_tracker dev_tracker;
There are two blanks between type and member name. Is that intended?
net/batman-adv/types.h struct batadv_hard_iface { · line 194
Quoted 4 lines
net/batman-adv/types.h +1
-0+/** @refcount: number of contexts the object is used */ struct kref refcount;
We also have hard_iface->soft_iface storing a pointer to the soft_iface (batX) netdev.
How about converting that to netdev_put/hold as well?
See batadv_hardif_enable_interface() / batadv_hardif_disable_interface()
Best Regards,
Signature · 1 line
Antonio Quartulli
Quoted 64 lines · Antonio Quartulli
Quoted 62 lines · Eric Dumazet
Add a device tracker to struct
batadv_hard_ifaceto help debugging of network device refcount imbalances.Signed-off-by Eric Dumazet <[email protected]>--- net/batman-adv/hard-interface.c | 14 +++++--------- net/batman-adv/types.h | 3 +++ 2 files changed, 8 insertions(+), 9 deletions(-)net/batman-adv/hard-interface.c +5
-9@@ -51,7 +51,7 @@ void batadv_hardif_release(struct kref *ref)struct batadv_hard_iface *hard_iface; hard_iface = container_of(ref, struct batadv_hard_iface, refcount); -dev_put (hard_iface->net_dev); +netdev_put (hard_iface->net_dev, &hard_iface->dev_tracker);kfree_rcu (hard_iface, rcu); }@@ -875,15 +875,16 @@ batadv_hardif_add_interface(struct net_device *net_dev)ASSERT_RTNL ();if (!batadv_is_valid_iface (net_dev)) - goto out; +return NULL ; -dev_hold (net_dev); hard_iface =kzalloc (sizeof (*hard_iface),GFP_ATOMIC );if (!hard_iface) - goto release_dev; +return NULL ; +netdev_hold (net_dev, &hard_iface->dev_tracker,GFP_ATOMIC ); hard_iface->net_dev = net_dev; + hard_iface->soft_iface =NULL ; hard_iface->if_status =BATADV_IF_NOT_IN_USE ;@@ -909,11 +910,6 @@ batadv_hardif_add_interface(struct net_device *net_dev) batadv_hardif_generation++;return hard_iface; - -release_dev: -dev_put (net_dev); -out: -return NULL ; }static void batadv_hardif_remove_interface (struct batadv_hard_iface *hard_iface)net/batman-adv/types.h +0
-0@@ -186,6 +186,9 @@ struct batadv_hard_iface {/** @net_dev: pointer to the net_device */ struct net_device *net_dev;
Quoted 4 lines
net/batman-adv/types.h struct batadv_hard_iface { · line 190
Quoted 2 lines
net/batman-adv/types.h +2
-0+/** @dev_tracker device tracker for @net_dev */ +netdevice_tracker dev_tracker;There are two blanks between type and member name. Is that intended?
Not intended. Also a : is missing :
I can submit a V2 if you want, or feel free to make the changes.
net/batman-adv/types.h +0 -0
100644
net/batman-adv/types.h +2 -2
@@ -186,8 +186,8 @@ struct batadv_hard_iface {/** @net_dev: pointer to the net_device */ struct net_device *net_dev; -/** @dev_tracker device tracker for @net_dev */ -netdevice_tracker dev_tracker; +/** @dev_tracker: device tracker for @net_dev */ +netdevice_tracker dev_tracker;/** @refcount: number of contexts the object is used */ struct kref refcount;
Quoted 6 lines
net/batman-adv/types.h struct batadv_hard_iface { · line 194
Quoted 5 lines
net/batman-adv/types.h +1
-0+/** @refcount: number of contexts the object is used */ struct kref refcount;
Quoted 6 lines
We also have
hard_iface->soft_ifacestoring a pointer to thesoft_iface(batX) netdev.How about converting that to netdev_put/hold as well?
Seebatadv_hardif_enable_interface()/batadv_hardif_disable_interface()
Sure, feel free to submit a patch for this one as well.
Thanks.