Skip to content

Commit 55366ba

Browse files
rleonsmb49
authored andcommitted
net/mlx5e: Always start IPsec sequence number from 1
BugLink: https://bugs.launchpad.net/bugs/2107449 [ Upstream commit 7f95b02 ] According to RFC4303, section "3.3.3. Sequence Number Generation", the first packet sent using a given SA will contain a sequence number of 1. This is applicable to both ESN and non-ESN mode, which was not covered in commit mentioned in Fixes line. Fixes: 3d42c8c ("net/mlx5e: Ensure that IPsec sequence packet number starts from 1") Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 1bef295 commit 55366ba

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,12 @@ static int mlx5e_xfrm_add_state(struct xfrm_state *x,
724724
/* check esn */
725725
if (x->props.flags & XFRM_STATE_ESN)
726726
mlx5e_ipsec_update_esn_state(sa_entry);
727+
else
728+
/* According to RFC4303, section "3.3.3. Sequence Number Generation",
729+
* the first packet sent using a given SA will contain a sequence
730+
* number of 1.
731+
*/
732+
sa_entry->esn_state.esn = 1;
727733

728734
mlx5e_ipsec_build_accel_xfrm_attrs(sa_entry, &sa_entry->attrs);
729735

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev)
9191
EXPORT_SYMBOL_GPL(mlx5_ipsec_device_caps);
9292

9393
static void mlx5e_ipsec_packet_setup(void *obj, u32 pdn,
94-
struct mlx5_accel_esp_xfrm_attrs *attrs)
94+
struct mlx5e_ipsec_sa_entry *sa_entry)
9595
{
96+
struct mlx5_accel_esp_xfrm_attrs *attrs = &sa_entry->attrs;
9697
void *aso_ctx;
9798

9899
aso_ctx = MLX5_ADDR_OF(ipsec_obj, obj, ipsec_aso);
@@ -120,8 +121,12 @@ static void mlx5e_ipsec_packet_setup(void *obj, u32 pdn,
120121
* active.
121122
*/
122123
MLX5_SET(ipsec_obj, obj, aso_return_reg, MLX5_IPSEC_ASO_REG_C_4_5);
123-
if (attrs->dir == XFRM_DEV_OFFLOAD_OUT)
124+
if (attrs->dir == XFRM_DEV_OFFLOAD_OUT) {
124125
MLX5_SET(ipsec_aso, aso_ctx, mode, MLX5_IPSEC_ASO_INC_SN);
126+
if (!attrs->replay_esn.trigger)
127+
MLX5_SET(ipsec_aso, aso_ctx, mode_parameter,
128+
sa_entry->esn_state.esn);
129+
}
125130

126131
if (attrs->lft.hard_packet_limit != XFRM_INF) {
127132
MLX5_SET(ipsec_aso, aso_ctx, remove_flow_pkt_cnt,
@@ -174,7 +179,7 @@ static int mlx5_create_ipsec_obj(struct mlx5e_ipsec_sa_entry *sa_entry)
174179

175180
res = &mdev->mlx5e_res.hw_objs;
176181
if (attrs->type == XFRM_DEV_OFFLOAD_PACKET)
177-
mlx5e_ipsec_packet_setup(obj, res->pdn, attrs);
182+
mlx5e_ipsec_packet_setup(obj, res->pdn, sa_entry);
178183

179184
err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
180185
if (!err)

0 commit comments

Comments
 (0)