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>,
	Emeel Hakim <ehakim@nvidia.com>, Raed Salem <raeds@nvidia.com>
Subject: [net 15/16] net/mlx5e: Fix macsec ssci attribute handling in offload path
Date: Mon,  9 Jan 2023 22:11:22 -0800	[thread overview]
Message-ID: <20230110061123.338427-16-saeed@kernel.org> (raw)
In-Reply-To: <20230110061123.338427-1-saeed@kernel.org>

From: Emeel Hakim <ehakim@nvidia.com>

Currently when macsec offload is set with extended packet number (epn)
enabled, the driver wrongly deduce the short secure channel identifier
(ssci) from the salt instead of the stand alone ssci attribute as it
should, consequently creating a mismatch between the kernel and driver's
ssci values.
Fix by using the ssci value from the relevant attribute.

Fixes: 4411a6c0abd3 ("net/mlx5e: Support MACsec offload extended packet number (EPN)")
Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
Reviewed-by: Raed Salem <raeds@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_accel/macsec.c  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
index 9369a580743e..cf7b3bb54c86 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
@@ -62,6 +62,7 @@ struct mlx5e_macsec_sa {
 	u32 enc_key_id;
 	u32 next_pn;
 	sci_t sci;
+	ssci_t ssci;
 	salt_t salt;
 
 	struct rhash_head hash;
@@ -499,10 +500,11 @@ mlx5e_macsec_get_macsec_device_context(const struct mlx5e_macsec *macsec,
 }
 
 static void update_macsec_epn(struct mlx5e_macsec_sa *sa, const struct macsec_key *key,
-			      const pn_t *next_pn_halves)
+			      const pn_t *next_pn_halves, ssci_t ssci)
 {
 	struct mlx5e_macsec_epn_state *epn_state = &sa->epn_state;
 
+	sa->ssci = ssci;
 	sa->salt = key->salt;
 	epn_state->epn_enabled = 1;
 	epn_state->epn_msb = next_pn_halves->upper;
@@ -550,7 +552,8 @@ static int mlx5e_macsec_add_txsa(struct macsec_context *ctx)
 	tx_sa->assoc_num = assoc_num;
 
 	if (secy->xpn)
-		update_macsec_epn(tx_sa, &ctx_tx_sa->key, &ctx_tx_sa->next_pn_halves);
+		update_macsec_epn(tx_sa, &ctx_tx_sa->key, &ctx_tx_sa->next_pn_halves,
+				  ctx_tx_sa->ssci);
 
 	err = mlx5_create_encryption_key(mdev, ctx->sa.key, secy->key_len,
 					 MLX5_ACCEL_OBJ_MACSEC_KEY,
@@ -945,7 +948,8 @@ static int mlx5e_macsec_add_rxsa(struct macsec_context *ctx)
 	rx_sa->fs_id = rx_sc->sc_xarray_element->fs_id;
 
 	if (ctx->secy->xpn)
-		update_macsec_epn(rx_sa, &ctx_rx_sa->key, &ctx_rx_sa->next_pn_halves);
+		update_macsec_epn(rx_sa, &ctx_rx_sa->key, &ctx_rx_sa->next_pn_halves,
+				  ctx_rx_sa->ssci);
 
 	err = mlx5_create_encryption_key(mdev, ctx->sa.key, ctx->secy->key_len,
 					 MLX5_ACCEL_OBJ_MACSEC_KEY,
-- 
2.39.0


  parent reply	other threads:[~2023-01-10  6:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10  6:11 [pull request][net 00/16] mlx5 fixes 2023-01-09 Saeed Mahameed
2023-01-10  6:11 ` [net 01/16] net/mlx5: DR, Fix 'stack frame size exceeds limit' error in dr_rule Saeed Mahameed
2023-01-11 13:00   ` patchwork-bot+netdevbpf
2023-01-10  6:11 ` [net 02/16] net/mlx5: check attr pointer validity before dereferencing it Saeed Mahameed
2023-01-10  6:11 ` [net 03/16] net/mlx5e: TC, Keep mod hdr actions after mod hdr alloc Saeed Mahameed
2023-01-10  6:11 ` [net 04/16] net/mlx5: Fix command stats access after free Saeed Mahameed
2023-01-10  6:11 ` [net 05/16] net/mlx5e: Verify dev is present for fix features ndo Saeed Mahameed
2023-01-10  6:11 ` [net 06/16] net/mlx5e: IPoIB, Block queue count configuration when sub interfaces are present Saeed Mahameed
2023-01-10  6:11 ` [net 07/16] net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent Saeed Mahameed
2023-01-10  6:11 ` [net 08/16] net/mlx5e: IPoIB, Fix child PKEY interface stats on rx path Saeed Mahameed
2023-01-10  6:11 ` [net 09/16] net/mlx5e: TC, ignore match level for post meter rules Saeed Mahameed
2023-01-10  6:11 ` [net 10/16] net/mlx5e: TC, Restore pkt rate policing support Saeed Mahameed
2023-01-10  6:11 ` [net 11/16] net/mlx5e: Fix memory leak on updating vport counters Saeed Mahameed
2023-01-10  6:11 ` [net 12/16] net/mlx5: Fix ptp max frequency adjustment range Saeed Mahameed
2023-01-10  6:11 ` [net 13/16] net/mlx5e: Don't support encap rules with gbp option Saeed Mahameed
2023-01-10  6:11 ` [net 14/16] net/mlx5: E-switch, Coverity: overlapping copy Saeed Mahameed
2023-01-10  6:11 ` Saeed Mahameed [this message]
2023-01-10  6:11 ` [net 16/16] net/mlx5e: Fix macsec possible null dereference when updating MAC security entity (SecY) Saeed Mahameed
2023-01-11  2:01 ` [pull request][net 00/16] mlx5 fixes 2023-01-09 Jakub Kicinski

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=20230110061123.338427-16-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ehakim@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=raeds@nvidia.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).