From: Leon Romanovsky <leon@kernel.org>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: Leon Romanovsky <leonro@nvidia.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
netdev@vger.kernel.org, Patrisious Haddad <phaddad@nvidia.com>,
Raed Salem <raeds@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>
Subject: [PATCH xfrm-next 4/9] net/mlx5e: Ensure that IPsec sequence packet number starts from 1
Date: Mon, 16 Oct 2023 12:15:12 +0300 [thread overview]
Message-ID: <1f32944a06ab72d61d7b5d2471e99d4dc189b205.1697444728.git.leon@kernel.org> (raw)
In-Reply-To: <cover.1697444728.git.leon@kernel.org>
From: Leon Romanovsky <leonro@nvidia.com>
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.
However if user didn't set seq/oseq, the HW used zero as first sequence
packet number. Such misconfiguration causes to drop of first packet
if replay window protection was enabled in SA.
To fix it, set sequence number to be at least 1.
Fixes: 7db21ef4566e ("net/mlx5e: Set IPsec replay sequence numbers")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
index ddd2230f04aa..bf88232a2fc2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
@@ -121,7 +121,14 @@ static bool mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry)
if (x->xso.type == XFRM_DEV_OFFLOAD_CRYPTO)
esn_msb = xfrm_replay_seqhi(x, htonl(seq_bottom));
- sa_entry->esn_state.esn = esn;
+ if (sa_entry->esn_state.esn_msb)
+ sa_entry->esn_state.esn = esn;
+ else
+ /* 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.
+ */
+ sa_entry->esn_state.esn = max_t(u32, esn, 1);
sa_entry->esn_state.esn_msb = esn_msb;
if (unlikely(overlap && seq_bottom < MLX5E_IPSEC_ESN_SCOPE_MID)) {
--
2.41.0
next prev parent reply other threads:[~2023-10-16 9:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 9:15 [PATCH xfrm-next 0/9] mlx5 IPsec replay window enhancement and XFRM core statistics Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 1/9] xfrm: generalize xdo_dev_state_update_curlft to allow statistics update Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 2/9] xfrm: get global statistics from the offloaded device Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 3/9] net/mlx5e: Honor user choice of IPsec replay window size Leon Romanovsky
2023-10-16 9:15 ` Leon Romanovsky [this message]
2023-10-16 9:15 ` [PATCH xfrm-next 5/9] net/mlx5e: Unify esw and normal IPsec status table creation/destruction Leon Romanovsky
2023-10-17 9:38 ` Steffen Klassert
2023-10-17 12:13 ` Leon Romanovsky
2023-10-18 5:13 ` Leon Romanovsky
2023-10-19 8:46 ` Steffen Klassert
2023-10-19 11:01 ` Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 6/9] net/mlx5e: Remove exposure of IPsec RX flow steering struct Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 7/9] net/mlx5e: Add IPsec and ASO syndromes check in HW Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 8/9] net/mlx5e: Connect mlx5 IPsec statistics with XFRM core Leon Romanovsky
2023-10-16 9:15 ` [PATCH xfrm-next 9/9] net/mlx5e: Delete obsolete IPsec code Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f32944a06ab72d61d7b5d2471e99d4dc189b205.1697444728.git.leon@kernel.org \
--to=leon@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=leonro@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=phaddad@nvidia.com \
--cc=raeds@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).