Commit f2b18732 authored by Raed Salem's avatar Raed Salem Committed by Saeed Mahameed

net/mlx5: IPSec, Fix the SA context hash key

The commit "net/mlx5: Refactor accel IPSec code" introduced a
bug where asynchronous short time change in hash key value
by create/release SA context might happen during an asynchronous
hash resize operation this could cause a subsequent remove SA
context operation to fail as the key value used during resize is
not the same key value used when remove SA context operation is
invoked.

This commit fixes the bug by defining the SA context hash key
such that it includes only fields that never change during the
lifetime of the SA context object.

Fixes: d6c4f029 ("net/mlx5: Refactor accel IPSec code")
Signed-off-by: default avatarRaed Salem <raeds@mellanox.com>
Reviewed-by: default avatarAviad Yehezkel <aviadye@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 65102238
...@@ -83,8 +83,14 @@ struct mlx5_fpga_ipsec_rule { ...@@ -83,8 +83,14 @@ struct mlx5_fpga_ipsec_rule {
}; };
static const struct rhashtable_params rhash_sa = { static const struct rhashtable_params rhash_sa = {
.key_len = FIELD_SIZEOF(struct mlx5_fpga_ipsec_sa_ctx, hw_sa), /* Keep out "cmd" field from the key as it's
.key_offset = offsetof(struct mlx5_fpga_ipsec_sa_ctx, hw_sa), * value is not constant during the lifetime
* of the key object.
*/
.key_len = FIELD_SIZEOF(struct mlx5_fpga_ipsec_sa_ctx, hw_sa) -
FIELD_SIZEOF(struct mlx5_ifc_fpga_ipsec_sa_v1, cmd),
.key_offset = offsetof(struct mlx5_fpga_ipsec_sa_ctx, hw_sa) +
FIELD_SIZEOF(struct mlx5_ifc_fpga_ipsec_sa_v1, cmd),
.head_offset = offsetof(struct mlx5_fpga_ipsec_sa_ctx, hash), .head_offset = offsetof(struct mlx5_fpga_ipsec_sa_ctx, hash),
.automatic_shrinking = true, .automatic_shrinking = true,
.min_size = 1, .min_size = 1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment