Skip to content

Commit f6050ee

Browse files
pmachatadavem330
authored andcommitted
mlxsw: spectrum_router: Extract mlxsw_sp_rt6_is_gateway()
IPv6 counterpart of the previous patch: introduce a function to determine whether a given route is a gateway route. The new function takes a mlxsw_sp argument which follow-up patches will use. Thus mlxsw_sp_fib6_entry_type_set() got that argument as well. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9b01451 commit f6050ee

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,6 +3526,12 @@ static void mlxsw_sp_nexthop6_fini(struct mlxsw_sp *mlxsw_sp,
35263526
mlxsw_sp_nexthop_rif_fini(nh);
35273527
}
35283528

3529+
static bool mlxsw_sp_rt6_is_gateway(const struct mlxsw_sp *mlxsw_sp,
3530+
const struct rt6_info *rt)
3531+
{
3532+
return rt->rt6i_flags & RTF_GATEWAY;
3533+
}
3534+
35293535
static struct mlxsw_sp_nexthop_group *
35303536
mlxsw_sp_nexthop6_group_create(struct mlxsw_sp *mlxsw_sp,
35313537
struct mlxsw_sp_fib6_entry *fib6_entry)
@@ -3548,7 +3554,7 @@ mlxsw_sp_nexthop6_group_create(struct mlxsw_sp *mlxsw_sp,
35483554
#endif
35493555
mlxsw_sp_rt6 = list_first_entry(&fib6_entry->rt6_list,
35503556
struct mlxsw_sp_rt6, list);
3551-
nh_grp->gateway = !!(mlxsw_sp_rt6->rt->rt6i_flags & RTF_GATEWAY);
3557+
nh_grp->gateway = mlxsw_sp_rt6_is_gateway(mlxsw_sp, mlxsw_sp_rt6->rt);
35523558
nh_grp->count = fib6_entry->nrt6;
35533559
for (i = 0; i < nh_grp->count; i++) {
35543560
struct rt6_info *rt = mlxsw_sp_rt6->rt;
@@ -3705,7 +3711,8 @@ mlxsw_sp_fib6_entry_nexthop_del(struct mlxsw_sp *mlxsw_sp,
37053711
mlxsw_sp_rt6_destroy(mlxsw_sp_rt6);
37063712
}
37073713

3708-
static void mlxsw_sp_fib6_entry_type_set(struct mlxsw_sp_fib_entry *fib_entry,
3714+
static void mlxsw_sp_fib6_entry_type_set(struct mlxsw_sp *mlxsw_sp,
3715+
struct mlxsw_sp_fib_entry *fib_entry,
37093716
const struct rt6_info *rt)
37103717
{
37113718
/* Packets hitting RTF_REJECT routes need to be discarded by the
@@ -3718,7 +3725,7 @@ static void mlxsw_sp_fib6_entry_type_set(struct mlxsw_sp_fib_entry *fib_entry,
37183725
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_TRAP;
37193726
else if (rt->rt6i_flags & RTF_REJECT)
37203727
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_LOCAL;
3721-
else if (rt->rt6i_flags & RTF_GATEWAY)
3728+
else if (mlxsw_sp_rt6_is_gateway(mlxsw_sp, rt))
37223729
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_REMOTE;
37233730
else
37243731
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_LOCAL;
@@ -3758,7 +3765,7 @@ mlxsw_sp_fib6_entry_create(struct mlxsw_sp *mlxsw_sp,
37583765
goto err_rt6_create;
37593766
}
37603767

3761-
mlxsw_sp_fib6_entry_type_set(fib_entry, mlxsw_sp_rt6->rt);
3768+
mlxsw_sp_fib6_entry_type_set(mlxsw_sp, fib_entry, mlxsw_sp_rt6->rt);
37623769

37633770
INIT_LIST_HEAD(&fib6_entry->rt6_list);
37643771
list_add_tail(&mlxsw_sp_rt6->list, &fib6_entry->rt6_list);

0 commit comments

Comments
 (0)