[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d729f05a-e5e6-4d67-8fe6-888e1e761b34@unstable.cc>
Date: Thu, 6 Feb 2025 15:15:00 +0100
From: Antonio Quartulli <a@...table.cc>
To: Eric Dumazet <edumazet@...gle.com>,
Marek Lindner <marek.lindner@...lbox.org>,
Simon Wunderlich <sw@...onwunderlich.de>, Sven Eckelmann <sven@...fation.org>
Cc: b.a.t.m.a.n@...ts.open-mesh.org, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
eric.dumazet@...il.com
Subject: Re: [PATCH net-next] batman-adv: adopt netdev_hold() / netdev_put()
On 06/02/2025 15:04, Eric Dumazet wrote:
> Add a device tracker to struct batadv_hard_iface to help
> debugging of network device refcount imbalances.
>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> ---
> net/batman-adv/hard-interface.c | 14 +++++---------
> net/batman-adv/types.h | 3 +++
> 2 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
> index 96a412beab2de9069c0f88e4cd844fbc0922aa18..9a3ae567eb12d0c65b25292d020462b6ad60b699 100644
> --- a/net/batman-adv/hard-interface.c
> +++ b/net/batman-adv/hard-interface.c
> @@ -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)
> diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
> index f491bff8c51b8bf68eb11dbbeb1a434d446c25f0..a73fc3ab7dd28ae2c8484c0d198a15437d49ea73 100644
> --- a/net/batman-adv/types.h
> +++ b/net/batman-adv/types.h
> @@ -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?
> +
> /** @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,
--
Antonio Quartulli
Powered by blists - more mailing lists