public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Yevhen Orlov <yevhen.orlov@plvision.eu>, netdev@vger.kernel.org
Cc: Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
	Taras Chornyi <taras.chornyi@plvision.eu>,
	Mickey Rachamim <mickeyr@marvell.com>,
	Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Stephen Hemminger <stephen@networkplumber.org>,
	linux-kernel@vger.kernel.org,
	Taras Chornyi <tchornyi@marvell.com>,
	Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Subject: Re: [PATCH net-next v5 2/9] net: marvell: prestera: Add cleanup of allocated fib_nodes
Date: Thu, 22 Sep 2022 11:33:09 +0200	[thread overview]
Message-ID: <b9bbe03d801d6224c8cec9700d22cec19346cebf.camel@redhat.com> (raw)
In-Reply-To: <20220908225211.31482-3-yevhen.orlov@plvision.eu>

On Fri, 2022-09-09 at 01:52 +0300, Yevhen Orlov wrote:
> Do explicity cleanup on router_hw_fini, to ensure, that all allocated
> objects cleaned. This will be used in cases,
> when upper layer (cache) is not mapped to router_hw layer.
> 
> Co-developed-by: Taras Chornyi <tchornyi@marvell.com>
> Signed-off-by: Taras Chornyi <tchornyi@marvell.com>
> Co-developed-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
> Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
> Signed-off-by: Yevhen Orlov <yevhen.orlov@plvision.eu>
> ---
>  .../marvell/prestera/prestera_router_hw.c     | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
> index db9d2e9d9904..1b9feb396811 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
> @@ -56,6 +56,7 @@ static int prestera_nexthop_group_set(struct prestera_switch *sw,
>  static bool
>  prestera_nexthop_group_util_hw_state(struct prestera_switch *sw,
>  				     struct prestera_nexthop_group *nh_grp);
> +static void prestera_fib_node_destroy_ht(struct prestera_switch *sw);
>  
>  /* TODO: move to router.h as macros */
>  static bool prestera_nh_neigh_key_is_valid(struct prestera_nh_neigh_key *key)
> @@ -97,6 +98,7 @@ int prestera_router_hw_init(struct prestera_switch *sw)
>  
>  void prestera_router_hw_fini(struct prestera_switch *sw)
>  {
> +	prestera_fib_node_destroy_ht(sw);
>  	WARN_ON(!list_empty(&sw->router->vr_list));
>  	WARN_ON(!list_empty(&sw->router->rif_entry_list));
>  	rhashtable_destroy(&sw->router->fib_ht);
> @@ -605,6 +607,27 @@ void prestera_fib_node_destroy(struct prestera_switch *sw,
>  	kfree(fib_node);
>  }
>  
> +static void prestera_fib_node_destroy_ht(struct prestera_switch *sw)
> +{
> +	struct prestera_fib_node *node;
> +	struct rhashtable_iter iter;
> +
> +	while (1) {
> +		rhashtable_walk_enter(&sw->router->fib_ht, &iter);
> +		rhashtable_walk_start(&iter);
> +		node = rhashtable_walk_next(&iter);
> +		rhashtable_walk_stop(&iter);
> +		rhashtable_walk_exit(&iter);
> +
> +		if (!node)
> +			break;
> +		else if (IS_ERR(node))
> +			continue;
> +		else if (node)
> +			prestera_fib_node_destroy(sw, node);
> +	}
> +}

You should use instead rhashtable_free_and_destroy(), providing a
callback which just frees the node, without removing it from the hash
table.

The same in the next patch

Cheers,

Paolo


  reply	other threads:[~2022-09-22  9:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 22:52 [PATCH net-next v5 0/9] net: marvell: prestera: add nexthop routes offloading Yevhen Orlov
2022-09-08 22:52 ` [PATCH net-next v5 1/9] net: marvell: prestera: Add router nexthops ABI Yevhen Orlov
2022-09-13  9:13   ` Dan Carpenter
2022-09-08 22:52 ` [PATCH net-next v5 2/9] net: marvell: prestera: Add cleanup of allocated fib_nodes Yevhen Orlov
2022-09-22  9:33   ` Paolo Abeni [this message]
2022-09-08 22:52 ` [PATCH net-next v5 3/9] net: marvell: prestera: Add strict cleanup of fib arbiter Yevhen Orlov
2022-09-08 22:52 ` [PATCH net-next v5 4/9] net: marvell: prestera: add delayed wq and flush wq on deinit Yevhen Orlov
2022-09-08 22:52 ` [PATCH net-next v5 5/9] net: marvell: prestera: Add length macros for prestera_ip_addr Yevhen Orlov
2022-09-08 22:52 ` [PATCH net-next v5 6/9] net: marvell: prestera: Add heplers to interact with fib_notifier_info Yevhen Orlov
2022-09-08 22:52 ` [PATCH net-next v5 7/9] net: marvell: prestera: add stub handler neighbour events Yevhen Orlov
2022-09-08 22:52 ` [PATCH net-next v5 8/9] net: marvell: prestera: Add neighbour cache accounting Yevhen Orlov
2022-09-13  9:27   ` Dan Carpenter
2022-09-08 22:52 ` [PATCH net-next v5 9/9] net: marvell: prestera: Propagate nh state from hw to kernel Yevhen Orlov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9bbe03d801d6224c8cec9700d22cec19346cebf.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mickeyr@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=oleksandr.mazur@plvision.eu \
    --cc=serhiy.pshyk@plvision.eu \
    --cc=stephen@networkplumber.org \
    --cc=taras.chornyi@plvision.eu \
    --cc=tchornyi@marvell.com \
    --cc=volodymyr.mytnyk@plvision.eu \
    --cc=yevhen.orlov@plvision.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox