Commit 1e7313e8 authored by Yevhen Orlov's avatar Yevhen Orlov Committed by Jakub Kicinski
Browse files

net: marvell: prestera: Add cleanup of allocated fib_nodes



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: default avatarTaras Chornyi <tchornyi@marvell.com>
Signed-off-by: default avatarTaras Chornyi <tchornyi@marvell.com>
Co-developed-by: default avatarOleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: default avatarOleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: default avatarYevhen Orlov <yevhen.orlov@plvision.eu>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0a23ae23
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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_cb(void *ptr, void *arg);

/* TODO: move to router.h as macros */
static bool prestera_nh_neigh_key_is_valid(struct prestera_nh_neigh_key *key)
@@ -97,6 +98,8 @@ int prestera_router_hw_init(struct prestera_switch *sw)

void prestera_router_hw_fini(struct prestera_switch *sw)
{
	rhashtable_free_and_destroy(&sw->router->fib_ht,
				    prestera_fib_node_destroy_ht_cb, 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 +608,15 @@ void prestera_fib_node_destroy(struct prestera_switch *sw,
	kfree(fib_node);
}

static void prestera_fib_node_destroy_ht_cb(void *ptr, void *arg)
{
	struct prestera_fib_node *node = ptr;
	struct prestera_switch *sw = arg;

	__prestera_fib_node_destruct(sw, node);
	kfree(node);
}

struct prestera_fib_node *
prestera_fib_node_create(struct prestera_switch *sw,
			 struct prestera_fib_key *key,