From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Tariq Toukan <tariqt@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Saeed Mahameed <saeedm@nvidia.com>, Gal Pressman <gal@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 6/6] net/mlx5e: Properly match IPsec subnet addresses
Date: Tue, 4 Mar 2025 08:50:46 +0100 [thread overview]
Message-ID: <Z8aw1gn5iFNiSxd3@mev-dev.igk.intel.com> (raw)
In-Reply-To: <20250226114752.104838-7-tariqt@nvidia.com>
On Wed, Feb 26, 2025 at 01:47:52PM +0200, Tariq Toukan wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> Existing match criteria didn't allow to match whole subnet and
> only by specific addresses only. This caused to tunnel mode do not
> forward such traffic through relevant SA.
>
> In tunnel mode, policies look like this:
> src 192.169.0.0/16 dst 192.169.0.0/16
> dir out priority 383615 ptype main
> tmpl src 192.169.101.2 dst 192.169.101.1
> proto esp spi 0xc5141c18 reqid 1 mode tunnel
> crypto offload parameters: dev eth2 mode packet
>
> In this case, the XFRM core code handled all subnet calculations and
> forwarded network address to the drivers e.g. 192.169.0.0.
>
> For mlx5 devices, there is a need to set relevant prefix e.g. 0xFFFF00
> to perform flow steering match operation.
>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> .../mellanox/mlx5/core/en_accel/ipsec.c | 49 +++++++++++++++++++
> .../mellanox/mlx5/core/en_accel/ipsec.h | 9 +++-
> .../mellanox/mlx5/core/en_accel/ipsec_fs.c | 20 +++++---
> 3 files changed, 69 insertions(+), 9 deletions(-)
>
[...]
>
> +static __be32 word_to_mask(int prefix)
> +{
> + if (prefix < 0)
> + return 0;
> +
> + if (!prefix || prefix > 31)
> + return cpu_to_be32(0xFFFFFFFF);
> +
> + return cpu_to_be32(((1U << prefix) - 1) << (32 - prefix));
Isn't it GENMASK(31, 32 - prefix)? I don't know if it is preferable to
use this macro in such place.
> +}
> +
> +static void mlx5e_ipsec_policy_mask(struct mlx5e_ipsec_addr *addrs,
> + struct xfrm_selector *sel)
> +{
> + int i;
> +
> + if (addrs->family == AF_INET) {
> + addrs->smask.m4 = word_to_mask(sel->prefixlen_s);
> + addrs->saddr.a4 &= addrs->smask.m4;
> + addrs->dmask.m4 = word_to_mask(sel->prefixlen_d);
> + addrs->daddr.a4 &= addrs->dmask.m4;
> + return;
> + }
> +
> + for (i = 0; i < 4; i++) {
> + if (sel->prefixlen_s != 32 * i)
> + addrs->smask.m6[i] =
> + word_to_mask(sel->prefixlen_s - 32 * i);
> + addrs->saddr.a6[i] &= addrs->smask.m6[i];
> +
> + if (sel->prefixlen_d != 32 * i)
> + addrs->dmask.m6[i] =
> + word_to_mask(sel->prefixlen_d - 32 * i);
> + addrs->daddr.a6[i] &= addrs->dmask.m6[i];
> + }
> +}
> +
[...]
Looks fine,
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Thanks
next prev parent reply other threads:[~2025-03-04 7:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 11:47 [PATCH net-next 0/6] mlx5 misc enhancements 2025-02-26 Tariq Toukan
2025-02-26 11:47 ` [PATCH net-next 1/6] net/mlx5: Relocate function declarations from port.h to mlx5_core.h Tariq Toukan
2025-02-26 11:47 ` [PATCH net-next 2/6] net/mlx5: Refactor link speed handling with mlx5_link_info struct Tariq Toukan
2025-02-26 11:47 ` [PATCH net-next 3/6] net/mlx5e: Enable lanes configuration when auto-negotiation is off Tariq Toukan
2025-02-28 22:51 ` Jakub Kicinski
2025-03-02 8:17 ` Shahar Shitrit
2025-03-03 22:19 ` Jakub Kicinski
2025-02-28 23:54 ` Jakub Kicinski
2025-02-26 11:47 ` [PATCH net-next 4/6] net/mlx5: Lag, Enable Multiport E-Switch offloads on 8 ports LAG Tariq Toukan
2025-03-04 7:12 ` Michal Swiatkowski
2025-02-26 11:47 ` [PATCH net-next 5/6] net/mlx5e: Separate address related variables to be in struct Tariq Toukan
2025-03-04 7:23 ` Michal Swiatkowski
2025-02-26 11:47 ` [PATCH net-next 6/6] net/mlx5e: Properly match IPsec subnet addresses Tariq Toukan
2025-03-04 7:50 ` Michal Swiatkowski [this message]
2025-03-04 8:05 ` Leon Romanovsky
2025-03-04 9:51 ` Michal Swiatkowski
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=Z8aw1gn5iFNiSxd3@mev-dev.igk.intel.com \
--to=michal.swiatkowski@linux.intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=leonro@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--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).