netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>, Aya Levin <ayal@nvidia.com>
Subject: [net 12/14] net/mlx5e: Ignore IPsec replay window values on sender side
Date: Wed, 24 Jan 2024 00:18:53 -0800	[thread overview]
Message-ID: <20240124081855.115410-13-saeed@kernel.org> (raw)
In-Reply-To: <20240124081855.115410-1-saeed@kernel.org>

From: Leon Romanovsky <leonro@nvidia.com>

XFRM stack doesn't prevent from users to configure replay window
in TX side and strongswan sets replay_window to be 1. It causes
to failures in validation logic when trying to offload the SA.

Replay window is not relevant in TX side and should be ignored.

Fixes: cded6d80129b ("net/mlx5e: Store replay window in XFRM attributes")
Signed-off-by: Aya Levin <ayal@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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 161c5190c236..05612d9c6080 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
@@ -336,12 +336,17 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
 	/* iv len */
 	aes_gcm->icv_len = x->aead->alg_icv_len;
 
+	attrs->dir = x->xso.dir;
+
 	/* esn */
 	if (x->props.flags & XFRM_STATE_ESN) {
 		attrs->replay_esn.trigger = true;
 		attrs->replay_esn.esn = sa_entry->esn_state.esn;
 		attrs->replay_esn.esn_msb = sa_entry->esn_state.esn_msb;
 		attrs->replay_esn.overlap = sa_entry->esn_state.overlap;
+		if (attrs->dir == XFRM_DEV_OFFLOAD_OUT)
+			goto skip_replay_window;
+
 		switch (x->replay_esn->replay_window) {
 		case 32:
 			attrs->replay_esn.replay_window =
@@ -365,7 +370,7 @@ void mlx5e_ipsec_build_accel_xfrm_attrs(struct mlx5e_ipsec_sa_entry *sa_entry,
 		}
 	}
 
-	attrs->dir = x->xso.dir;
+skip_replay_window:
 	/* spi */
 	attrs->spi = be32_to_cpu(x->id.spi);
 
@@ -501,7 +506,8 @@ static int mlx5e_xfrm_validate_state(struct mlx5_core_dev *mdev,
 			return -EINVAL;
 		}
 
-		if (x->replay_esn && x->replay_esn->replay_window != 32 &&
+		if (x->replay_esn && x->xso.dir == XFRM_DEV_OFFLOAD_IN &&
+		    x->replay_esn->replay_window != 32 &&
 		    x->replay_esn->replay_window != 64 &&
 		    x->replay_esn->replay_window != 128 &&
 		    x->replay_esn->replay_window != 256) {
-- 
2.43.0


  parent reply	other threads:[~2024-01-24  8:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24  8:18 [pull request][net 00/14] mlx5 fixes 2024-01-24 Saeed Mahameed
2024-01-24  8:18 ` [net 01/14] net/mlx5e: Use the correct lag ports number when creating TISes Saeed Mahameed
2024-01-25 11:00   ` patchwork-bot+netdevbpf
2024-01-24  8:18 ` [net 02/14] net/mlx5: Fix query of sd_group field Saeed Mahameed
2024-01-24  8:18 ` [net 03/14] net/mlx5e: Fix operation precedence bug in port timestamping napi_poll context Saeed Mahameed
2024-01-24  8:18 ` [net 04/14] net/mlx5e: Fix inconsistent hairpin RQT sizes Saeed Mahameed
2024-01-24  8:18 ` [net 05/14] net/mlx5e: Fix peer flow lists handling Saeed Mahameed
2024-01-24  8:18 ` [net 06/14] net/mlx5: Fix a WARN upon a callback command failure Saeed Mahameed
2024-01-24  8:18 ` [net 07/14] net/mlx5: Bridge, fix multicast packets sent to uplink Saeed Mahameed
2024-01-24  8:18 ` [net 08/14] net/mlx5: DR, Use the right GVMI number for drop action Saeed Mahameed
2024-01-24  8:18 ` [net 09/14] net/mlx5: DR, Can't go to uplink vport on RX rule Saeed Mahameed
2024-01-24  8:18 ` [net 10/14] net/mlx5: Use mlx5 device constant for selecting CQ period mode for ASO Saeed Mahameed
2024-01-24  8:18 ` [net 11/14] net/mlx5e: Allow software parsing when IPsec crypto is enabled Saeed Mahameed
2024-01-24  8:18 ` Saeed Mahameed [this message]
2024-01-24  8:18 ` [net 13/14] net/mlx5e: fix a double-free in arfs_create_groups Saeed Mahameed
2024-01-24  8:18 ` [net 14/14] net/mlx5e: fix a potential double-free in fs_any_create_groups Saeed Mahameed

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=20240124081855.115410-13-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=ayal@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.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).