Skip to content

Commit 4ee4553

Browse files
committed
Merge branch 'mlxsw-gre-fixes'
Jiri Pirko says: ==================== mlxsw: Fixes in GRE offloading Petr says: This patchset fixes a couple unrelated problems in offloading IP-in-IP tunnels in mlxsw driver. - The first patch fixes a potential reference-counting problem that might lead to a kernel crash. - The second patch associates IPIP next hops with their loopback RIFs. Besides being the right thing to do, it also fixes a problem where offloaded IPv6 routes that forward to IP-in-IP netdevices were not flagged as such. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 8135961 + de0f43c commit 4ee4553

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,6 +2723,7 @@ static void mlxsw_sp_nexthop_type_fini(struct mlxsw_sp *mlxsw_sp,
27232723
mlxsw_sp_nexthop_rif_fini(nh);
27242724
break;
27252725
case MLXSW_SP_NEXTHOP_TYPE_IPIP:
2726+
mlxsw_sp_nexthop_rif_fini(nh);
27262727
mlxsw_sp_nexthop_ipip_fini(mlxsw_sp, nh);
27272728
break;
27282729
}
@@ -2742,7 +2743,11 @@ static int mlxsw_sp_nexthop4_type_init(struct mlxsw_sp *mlxsw_sp,
27422743
router->ipip_ops_arr[ipipt]->can_offload(mlxsw_sp, dev,
27432744
MLXSW_SP_L3_PROTO_IPV4)) {
27442745
nh->type = MLXSW_SP_NEXTHOP_TYPE_IPIP;
2745-
return mlxsw_sp_nexthop_ipip_init(mlxsw_sp, ipipt, nh, dev);
2746+
err = mlxsw_sp_nexthop_ipip_init(mlxsw_sp, ipipt, nh, dev);
2747+
if (err)
2748+
return err;
2749+
mlxsw_sp_nexthop_rif_init(nh, &nh->ipip_entry->ol_lb->common);
2750+
return 0;
27462751
}
27472752

27482753
nh->type = MLXSW_SP_NEXTHOP_TYPE_ETH;
@@ -4009,7 +4014,11 @@ static int mlxsw_sp_nexthop6_type_init(struct mlxsw_sp *mlxsw_sp,
40094014
router->ipip_ops_arr[ipipt]->can_offload(mlxsw_sp, dev,
40104015
MLXSW_SP_L3_PROTO_IPV6)) {
40114016
nh->type = MLXSW_SP_NEXTHOP_TYPE_IPIP;
4012-
return mlxsw_sp_nexthop_ipip_init(mlxsw_sp, ipipt, nh, dev);
4017+
err = mlxsw_sp_nexthop_ipip_init(mlxsw_sp, ipipt, nh, dev);
4018+
if (err)
4019+
return err;
4020+
mlxsw_sp_nexthop_rif_init(nh, &nh->ipip_entry->ol_lb->common);
4021+
return 0;
40134022
}
40144023

40154024
nh->type = MLXSW_SP_NEXTHOP_TYPE_ETH;
@@ -5068,6 +5077,7 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp,
50685077
vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN);
50695078
if (IS_ERR(vr))
50705079
return ERR_CAST(vr);
5080+
vr->rif_count++;
50715081

50725082
err = mlxsw_sp_rif_index_alloc(mlxsw_sp, &rif_index);
50735083
if (err)
@@ -5099,7 +5109,6 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp,
50995109

51005110
mlxsw_sp_rif_counters_alloc(rif);
51015111
mlxsw_sp->router->rifs[rif_index] = rif;
5102-
vr->rif_count++;
51035112

51045113
return rif;
51055114

@@ -5110,6 +5119,7 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp,
51105119
kfree(rif);
51115120
err_rif_alloc:
51125121
err_rif_index_alloc:
5122+
vr->rif_count--;
51135123
mlxsw_sp_vr_put(vr);
51145124
return ERR_PTR(err);
51155125
}
@@ -5124,14 +5134,14 @@ void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif)
51245134
mlxsw_sp_router_rif_gone_sync(mlxsw_sp, rif);
51255135
vr = &mlxsw_sp->router->vrs[rif->vr_id];
51265136

5127-
vr->rif_count--;
51285137
mlxsw_sp->router->rifs[rif->rif_index] = NULL;
51295138
mlxsw_sp_rif_counters_free(rif);
51305139
ops->deconfigure(rif);
51315140
if (fid)
51325141
/* Loopback RIFs are not associated with a FID. */
51335142
mlxsw_sp_fid_put(fid);
51345143
kfree(rif);
5144+
vr->rif_count--;
51355145
mlxsw_sp_vr_put(vr);
51365146
}
51375147

0 commit comments

Comments
 (0)