[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f8b88b306ec18a32bd9ffd15e4ecadf537550da1.1660641154.git.leonro@nvidia.com>
Date: Tue, 16 Aug 2022 13:37:58 +0300
From: Leon Romanovsky <leon@...nel.org>
To: Steffen Klassert <steffen.klassert@...unet.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Saeed Mahameed <saeedm@...dia.com>
Cc: Leon Romanovsky <leonro@...dia.com>,
Eric Dumazet <edumazet@...gle.com>, netdev@...r.kernel.org,
Paolo Abeni <pabeni@...hat.com>, Raed Salem <raeds@...dia.com>,
ipsec-devel <devel@...ux-ipsec.org>
Subject: [PATCH xfrm-next 10/26] net/mlx5e: Validate that IPsec full offload can handle packets
From: Leon Romanovsky <leonro@...dia.com>
Add specific to IPsec full offload check to drop packets that are
larger than MTU and such are going to be fragmented.
Reviewed-by: Raed Salem <raeds@...dia.com>
Signed-off-by: Leon Romanovsky <leonro@...dia.com>
---
.../ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
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 56d70bbb4b5c..f8ba2d7581e4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
@@ -409,6 +409,8 @@ void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv)
static bool mlx5e_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
{
+ struct net_device *netdev = x->xso.real_dev;
+
if (x->props.family == AF_INET) {
/* Offload with IPv4 options is not supported yet */
if (ip_hdr(skb)->ihl > 5)
@@ -419,6 +421,17 @@ static bool mlx5e_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
return false;
}
+ if (x->xso.type == XFRM_DEV_OFFLOAD_FULL) {
+ /* Fragmented packets */
+ if (skb_is_gso(skb)) {
+ if (!skb_gso_validate_network_len(skb, netdev->mtu))
+ return false;
+ } else {
+ if (skb->len > netdev->mtu)
+ return false;
+ }
+ }
+
return true;
}
--
2.37.2
Powered by blists - more mailing lists