[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201117174704.291990-9-idosch@idosch.org>
Date: Tue, 17 Nov 2020 19:47:03 +0200
From: Ido Schimmel <idosch@...sch.org>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, kuba@...nel.org, jiri@...dia.com,
dsahern@...il.com, mlxsw@...dia.com,
Ido Schimmel <idosch@...dia.com>
Subject: [PATCH net-next 8/9] mlxsw: spectrum_router: Add an indication if a nexthop group can be destroyed
From: Ido Schimmel <idosch@...dia.com>
Currently, a nexthop group is destroyed when the last FIB entry is
detached from it.
When nexthop objects are supported, this can no longer be the case, as
the group is a separate object whose lifetime is managed by user space.
Add an indication if a nexthop group can be destroyed and always set it
to true for the existing IPv4 and IPv6 nexthop groups.
Signed-off-by: Ido Schimmel <idosch@...dia.com>
Reviewed-by: Jiri Pirko <jiri@...dia.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 645ec70314d2..87b8c8db688b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -2897,6 +2897,7 @@ struct mlxsw_sp_nexthop_group {
};
struct mlxsw_sp_nexthop_group_info *nhgi;
enum mlxsw_sp_nexthop_group_type type;
+ bool can_destroy;
};
void mlxsw_sp_nexthop_counter_alloc(struct mlxsw_sp *mlxsw_sp,
@@ -4173,6 +4174,8 @@ mlxsw_sp_nexthop4_group_create(struct mlxsw_sp *mlxsw_sp, struct fib_info *fi)
if (err)
goto err_nexthop_group_insert;
+ nh_grp->can_destroy = true;
+
return nh_grp;
err_nexthop_group_insert:
@@ -4187,6 +4190,8 @@ static void
mlxsw_sp_nexthop4_group_destroy(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_nexthop_group *nh_grp)
{
+ if (!nh_grp->can_destroy)
+ return;
mlxsw_sp_nexthop_group_remove(mlxsw_sp, nh_grp);
mlxsw_sp_nexthop4_group_info_fini(mlxsw_sp, nh_grp);
fib_info_put(nh_grp->ipv4.fi);
@@ -5479,6 +5484,8 @@ mlxsw_sp_nexthop6_group_create(struct mlxsw_sp *mlxsw_sp,
if (err)
goto err_nexthop_group_insert;
+ nh_grp->can_destroy = true;
+
return nh_grp;
err_nexthop_group_insert:
@@ -5492,6 +5499,8 @@ static void
mlxsw_sp_nexthop6_group_destroy(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_nexthop_group *nh_grp)
{
+ if (!nh_grp->can_destroy)
+ return;
mlxsw_sp_nexthop_group_remove(mlxsw_sp, nh_grp);
mlxsw_sp_nexthop6_group_info_fini(mlxsw_sp, nh_grp);
kfree(nh_grp);
--
2.28.0
Powered by blists - more mailing lists