Skip to content

Commit 9b01451

Browse files
pmachatadavem330
authored andcommitted
mlxsw: spectrum_router: Extract mlxsw_sp_fi_is_gateway()
For IPv4 IP-in-IP offload, routes that direct traffic to IP-in-IP devices need to be considered gateway routes as well. That involves a bit more logic, so extract the current test to a separate function, where the logic can be later added. 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 6ddb742 commit 9b01451

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,12 @@ static void mlxsw_sp_nexthop_rif_gone_sync(struct mlxsw_sp *mlxsw_sp,
23822382
}
23832383
}
23842384

2385+
static bool mlxsw_sp_fi_is_gateway(const struct mlxsw_sp *mlxsw_sp,
2386+
const struct fib_info *fi)
2387+
{
2388+
return fi->fib_nh->nh_scope == RT_SCOPE_LINK;
2389+
}
2390+
23852391
static struct mlxsw_sp_nexthop_group *
23862392
mlxsw_sp_nexthop4_group_create(struct mlxsw_sp *mlxsw_sp, struct fib_info *fi)
23872393
{
@@ -2401,7 +2407,7 @@ mlxsw_sp_nexthop4_group_create(struct mlxsw_sp *mlxsw_sp, struct fib_info *fi)
24012407
INIT_LIST_HEAD(&nh_grp->fib_list);
24022408
nh_grp->neigh_tbl = &arp_tbl;
24032409

2404-
nh_grp->gateway = fi->fib_nh->nh_scope == RT_SCOPE_LINK;
2410+
nh_grp->gateway = mlxsw_sp_fi_is_gateway(mlxsw_sp, fi);
24052411
nh_grp->count = fi->fib_nhs;
24062412
fib_info_hold(fi);
24072413
for (i = 0; i < nh_grp->count; i++) {
@@ -2801,10 +2807,10 @@ mlxsw_sp_fib4_entry_type_set(struct mlxsw_sp *mlxsw_sp,
28012807
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_LOCAL;
28022808
return 0;
28032809
case RTN_UNICAST:
2804-
if (fi->fib_nh->nh_scope != RT_SCOPE_LINK)
2805-
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_LOCAL;
2806-
else
2810+
if (mlxsw_sp_fi_is_gateway(mlxsw_sp, fi))
28072811
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_REMOTE;
2812+
else
2813+
fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_LOCAL;
28082814
return 0;
28092815
default:
28102816
return -EINVAL;

0 commit comments

Comments
 (0)