From patchwork Thu Mar 30 08:02:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13193552 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C5CDC6FD1D for ; Thu, 30 Mar 2023 08:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbjC3IDI (ORCPT ); Thu, 30 Mar 2023 04:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbjC3IDB (ORCPT ); Thu, 30 Mar 2023 04:03:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33E5E19B5 for ; Thu, 30 Mar 2023 01:03:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C08D561F15 for ; Thu, 30 Mar 2023 08:03:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A72B7C433EF; Thu, 30 Mar 2023 08:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680163380; bh=QmLangSyHAGlJ7U06UIlrZtPMmZnLJd7KBG9veM9zeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DynM8cfwwZ925zftG7+uqFgWFbI+TFx9zJd/MiOZvpJ+1FfD1HSbPI314q6/IITr+ tJuJeG3ONUK8AOQZ/YnwUFC15iDRvO9k9OXJOxHKgDP09TYdF+4IpY8EWbBxCKX2zG 2u1Li8P1BgA9U7VSGsTUwjBm+CXb8LX56/bfpnz+ZwIGj9qG7X0Q8HY/zH449FjRRF YMhMqM662agJpwo0oK1or4yYmr76SPkZrcitw1Q/x6jrVBnL/vUhfklyxQqUxSdDI3 bKi0Tk+e0YL/nXbAVBf8lMzyP0XTwcnQaGN6pGtdsFF7/8z5sxs0Ctk8lLh4337yJr tmQNzgWb8O/Fw== From: Leon Romanovsky To: Paolo Abeni , Jakub Kicinski , "David S . Miller" Cc: Leon Romanovsky , Saeed Mahameed , linux-netdev , Raed Salem , Eric Dumazet , Herbert Xu , Steffen Klassert Subject: [PATCH net-next 02/10] net/mlx5e: Prevent zero IPsec soft/hard limits Date: Thu, 30 Mar 2023 11:02:23 +0300 Message-Id: <80d0ba33e21fb28b1b91d306d1da39df3d990b68.1680162300.git.leonro@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Leon Romanovsky Hardware triggers limit events when the packets arrive and are processed through the device. In case zero was configured as a limit, the HW won't be able to arm event as it happens at the end of execution pipeline. Let's prevent such configuration. Reviewed-by: Raed Salem Signed-off-by: Leon Romanovsky --- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 5 +++++ 1 file changed, 5 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 91fa0a366316..c2e4f30d1f76 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c @@ -283,6 +283,11 @@ static int mlx5e_xfrm_validate_state(struct mlx5_core_dev *mdev, NL_SET_ERR_MSG_MOD(extack, "Hard packet limit must be greater than soft one"); return -EINVAL; } + + if (!x->lft.soft_packet_limit || !x->lft.hard_packet_limit) { + NL_SET_ERR_MSG_MOD(extack, "Soft/hard packet limits can't be 0"); + return -EINVAL; + } break; default: NL_SET_ERR_MSG_MOD(extack, "Unsupported xfrm offload type");