Skip to content

Commit 665030f

Browse files
pmachataPaolo Abeni
authored andcommitted
mlxsw: spectrum_router: Fix rollback in tunnel next hop init
In mlxsw_sp_nexthop6_init(), a next hop is always added to the router linked list, and mlxsw_sp_nexthop_type_init() is invoked afterwards. When that function results in an error, the next hop will not have been removed from the linked list. As the error is propagated upwards and the caller frees the next hop object, the linked list ends up holding an invalid object. A similar issue comes up with mlxsw_sp_nexthop4_init(), where rollback block does exist, however does not include the linked list removal. Both IPv6 and IPv4 next hops have a similar issue with next-hop counter rollbacks. As these were introduced in the same patchset as the next hop linked list, include the cleanup in this patch. Fixes: dbe4598 ("mlxsw: spectrum_router: Keep nexthops in a linked list") Fixes: a539027 ("mlxsw: spectrum: Add support for setting counters on nexthops") Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Amit Cohen <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 9cc02ed commit 665030f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4415,6 +4415,8 @@ static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp,
44154415
return 0;
44164416

44174417
err_nexthop_neigh_init:
4418+
list_del(&nh->router_list_node);
4419+
mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh);
44184420
mlxsw_sp_nexthop_remove(mlxsw_sp, nh);
44194421
return err;
44204422
}
@@ -6740,6 +6742,7 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp,
67406742
const struct fib6_info *rt)
67416743
{
67426744
struct net_device *dev = rt->fib6_nh->fib_nh_dev;
6745+
int err;
67436746

67446747
nh->nhgi = nh_grp->nhgi;
67456748
nh->nh_weight = rt->fib6_nh->fib_nh_weight;
@@ -6755,7 +6758,16 @@ static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp,
67556758
return 0;
67566759
nh->ifindex = dev->ifindex;
67576760

6758-
return mlxsw_sp_nexthop_type_init(mlxsw_sp, nh, dev);
6761+
err = mlxsw_sp_nexthop_type_init(mlxsw_sp, nh, dev);
6762+
if (err)
6763+
goto err_nexthop_type_init;
6764+
6765+
return 0;
6766+
6767+
err_nexthop_type_init:
6768+
list_del(&nh->router_list_node);
6769+
mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh);
6770+
return err;
67596771
}
67606772

67616773
static void mlxsw_sp_nexthop6_fini(struct mlxsw_sp *mlxsw_sp,

0 commit comments

Comments
 (0)