From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D296A0C45; Wed, 22 Sep 2021 06:40:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 280FD4003F; Wed, 22 Sep 2021 06:40:29 +0200 (CEST) Received: from mail-m2456.qiye.163.com (mail-m2456.qiye.163.com [220.194.24.56]) by mails.dpdk.org (Postfix) with ESMTP id E86354003C for ; Wed, 22 Sep 2021 06:40:26 +0200 (CEST) Received: from localhost.localdomain (unknown [117.50.0.204]) by mail-m2456.qiye.163.com (Hmail) with ESMTPA id 3AF23700564; Wed, 22 Sep 2021 12:40:19 +0800 (CST) From: wenxu@ucloud.cn To: viacheslavo@nvidia.com, rasland@nvidia.com Cc: dev@dpdk.org Date: Wed, 22 Sep 2021 12:40:18 +0800 Message-Id: <1632285618-7830-1-git-send-email-wenxu@ucloud.cn> X-Mailer: git-send-email 1.8.3.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlCN1dZLVlBSVdZDwkaFQgSH1lBWUNMTkxWTUodTExKGk8fT0 pMVRkRExYaEhckFA4PWVdZFhoPEhUdFFlBWVVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OE06Qio4HjNOKwICI0I9MipN NAEwCypVSlVKTUhJSUNOTUpCT0lNVTMWGhIXVQweFQMOOw4YFxQOH1UYFUVZV1kSC1lBWUpKTFVO S1VLVUlLT1lXWQgBWUFIT0pONwY+ X-HM-Tid: 0a7c0bcdf4378c15kuqt3af23700564 Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix NULL err msg in mlx5_flow_tunnel_validate X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: wenxu If the mlx5_flow_tunnel_validate validating the flow tunnel rule failed, the err_msg will be NULL in the rte_flow_error. Fixes: 4ec6360de37d ("net/mlx5: implement tunnel offload") Signed-off-by: wenxu --- drivers/net/mlx5/mlx5_flow.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index e63a297..3c5aca0 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -9081,30 +9081,31 @@ int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh) return err; } -static inline bool +static inline int mlx5_flow_tunnel_validate(struct rte_eth_dev *dev, struct rte_flow_tunnel *tunnel, - const char *err_msg) + struct rte_flow_error *error) { - err_msg = NULL; if (!is_tunnel_offload_active(dev)) { - err_msg = "tunnel offload was not activated"; - goto out; + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "tunnel offload was not activated"); } else if (!tunnel) { - err_msg = "no application tunnel"; - goto out; + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "no application tunnel"); } switch (tunnel->type) { default: - err_msg = "unsupported tunnel type"; - goto out; + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "unsupported tunnel type"); case RTE_FLOW_ITEM_TYPE_VXLAN: break; } -out: - return !err_msg; + return 0; } static int @@ -9116,13 +9117,11 @@ int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh) { int ret; struct mlx5_flow_tunnel *tunnel; - const char *err_msg = NULL; - bool verdict = mlx5_flow_tunnel_validate(dev, app_tunnel, err_msg); - if (!verdict) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, - err_msg); + ret = mlx5_flow_tunnel_validate(dev, app_tunnel, error); + if (ret < 0) + return ret; + ret = mlx5_get_flow_tunnel(dev, app_tunnel, &tunnel); if (ret < 0) { return rte_flow_error_set(error, ret, @@ -9143,13 +9142,11 @@ int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh) { int ret; struct mlx5_flow_tunnel *tunnel; - const char *err_msg = NULL; - bool verdict = mlx5_flow_tunnel_validate(dev, app_tunnel, err_msg); - if (!verdict) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - err_msg); + ret = mlx5_flow_tunnel_validate(dev, app_tunnel, error); + if (ret < 0) + return ret; + ret = mlx5_get_flow_tunnel(dev, app_tunnel, &tunnel); if (ret < 0) { return rte_flow_error_set(error, ret, -- 1.8.3.1