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 7285545D5D for ; Thu, 21 Nov 2024 00:43:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 09CB140296; Thu, 21 Nov 2024 00:43:56 +0100 (CET) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mails.dpdk.org (Postfix) with ESMTP id 25DAE43278 for ; Thu, 21 Nov 2024 00:43:54 +0100 (CET) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-431481433bdso2074715e9.3 for ; Wed, 20 Nov 2024 15:43:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732146234; x=1732751034; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=goLqExMdZsyDZY6aDxgWuBPymLHd3iNBeoDPCn68pvs=; b=GTKtW/OCECGAl4mAQ4wWXlELJlIrtEGX3RxTiRnaeSj7T7JupIiKeqx0+tMA7Cvdl6 Z5cXHPgKRRCyT9DPUcr5f71fZqJgceAQqHpZEvpnk/Wv+Xt3ILaOn/HppQwAAq9L0eFV D4nn1og82xaQd1AYqrnJsnn2BZXh+2l7r9lmPwWoJYSaMBrICuTVNF7MQ6L2N26fAp0h shjxkTyn4rvqBBqQkrL0AJMpAYdNjjE+Xl8nMpKIopOdmQWWJPuh9tEBx2lFjLfxa17e jwemxSgsXwG7wKUSiyxpcXl6rqCmFEBlO8uOhD3/tzln73wxs7Bgpx65htbM8R2UA7X6 ztMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732146234; x=1732751034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=goLqExMdZsyDZY6aDxgWuBPymLHd3iNBeoDPCn68pvs=; b=YFU6fZafYXf5dT/FNImBBftDVdgWaQknhjXpYxAVgdv8Wk44Ee4JbpPHsYUZFs+9aJ aShnnfLDlZG2l5EIENXxWPI24bgAisKhXyHVpA7rMmwafYMy8T4DmPH/ioIa78ZjQwlK ATvMZpMYDnN7X3PM3d+rsPtqfjfh/dRXNB5B9X1yLlz3zjdOkT0AtLETz5waWFVVTHLm gW6t9EOKAGKk8XLMocLPniXibYTqbf9bd22OjKm5yCjGy9ytUPWxYrBWMDMFwk+s/y5z p7ztatYKEPXsNKexUgh3zYeOiCJLRl8aZUV4wm/ssIe5r37XlosFzmgos+cAQra5jZK3 LDZw== X-Forwarded-Encrypted: i=1; AJvYcCVc/isJCpWZSgY1ZUbq+CGm4KVkHCjWWbbRFtFQMeE6T/PzfvtUPh6yv8DIhk5Cl485b9B7QnE=@dpdk.org X-Gm-Message-State: AOJu0Ywxk6g1TxvpiZdqiTVjpxTLf/eaJO+98Rlx/6a6/aeo+1TjlDYo njMocymaB9jM4aTk3rX6Df9hTPUCBior0WsIQ0pX83OFm61ywBCD X-Google-Smtp-Source: AGHT+IHnloye8pixx5QGmgYpqS/blXzx9sSy6y8H3WcJ25hf1wjedHLWc9k1ukhipdYZwfg01T12Fg== X-Received: by 2002:a05:600c:3b9d:b0:432:7c08:d0ff with SMTP id 5b1f17b1804b1-4334f01f748mr35350165e9.23.1732146233731; Wed, 20 Nov 2024 15:43:53 -0800 (PST) Received: from localhost ([2a01:4b00:d036:ae00:21cd:def0:a01d:d2aa]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-433b4616843sm34609775e9.20.2024.11.20.15.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 15:43:52 -0800 (PST) From: luca.boccassi@gmail.com To: Vladimir Medvedkin Cc: Bruce Richardson , dpdk stable Subject: patch 'net/i40e: check register read for outer VLAN' has been queued to stable release 22.11.7 Date: Wed, 20 Nov 2024 23:41:49 +0000 Message-ID: <20241120234215.233355-24-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241120234215.233355-1-luca.boccassi@gmail.com> References: <20241112220754.666489-40-luca.boccassi@gmail.com> <20241120234215.233355-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/22/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/e4545205ccf909b5846666e253cb4458bbbc411c Thanks. Luca Boccassi --- >From e4545205ccf909b5846666e253cb4458bbbc411c Mon Sep 17 00:00:00 2001 From: Vladimir Medvedkin Date: Fri, 15 Nov 2024 19:14:25 +0000 Subject: [PATCH] net/i40e: check register read for outer VLAN [ upstream commit c11c52dd5d2a19c97616ac32a1d4911c48f157d4 ] 'i40e_get_outer_vlan()' does not check 'i40e_aq_debug_read_register()' return value. This patch fixes this issue, by checking the return value and, on error, having the i40e_get_outer_vlan() function return that error back to the caller. This in turn requires a change in the return type of that function and updates to the places where it is called to: * handle the error, and * handle the tpid being returned as an "out" parameter rather than return code. Coverity issue: 445518 Fixes: 86eb05d6350b ("net/i40e: add flow validate function") Signed-off-by: Vladimir Medvedkin Acked-by: Bruce Richardson --- drivers/net/i40e/i40e_flow.c | 77 ++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 882152bd4a..be82fac8f2 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -1263,27 +1263,31 @@ i40e_flow_parse_attr(const struct rte_flow_attr *attr, return 0; } -static uint16_t -i40e_get_outer_vlan(struct rte_eth_dev *dev) +static int +i40e_get_outer_vlan(struct rte_eth_dev *dev, uint16_t *tpid) { struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); int qinq = dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND; uint64_t reg_r = 0; uint16_t reg_id; - uint16_t tpid; + int ret; if (qinq) reg_id = 2; else reg_id = 3; - i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id), + ret = i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id), ®_r, NULL); + if (ret != I40E_SUCCESS) { + PMD_DRV_LOG(ERR, "Failed to read from L2 tag ctrl register [%d]", reg_id); + return -EIO; + } - tpid = (reg_r >> I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT) & 0xFFFF; + *tpid = (reg_r >> I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT) & 0xFFFF; - return tpid; + return 0; } /* 1. Last in item should be NULL as range is not supported. @@ -1303,6 +1307,8 @@ i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev, const struct rte_flow_item_eth *eth_spec; const struct rte_flow_item_eth *eth_mask; enum rte_flow_item_type item_type; + int ret; + uint16_t tpid; for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { if (item->last) { @@ -1361,8 +1367,23 @@ i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev, if (filter->ether_type == RTE_ETHER_TYPE_IPV4 || filter->ether_type == RTE_ETHER_TYPE_IPV6 || - filter->ether_type == RTE_ETHER_TYPE_LLDP || - filter->ether_type == i40e_get_outer_vlan(dev)) { + filter->ether_type == RTE_ETHER_TYPE_LLDP) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported ether_type in control packet filter."); + return -rte_errno; + } + + ret = i40e_get_outer_vlan(dev, &tpid); + if (ret != 0) { + rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Can not get the Ethertype identifying the L2 tag"); + return -rte_errno; + } + if (filter->ether_type == tpid) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -1370,6 +1391,7 @@ i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev, " control packet filter."); return -rte_errno; } + break; default: break; @@ -1641,6 +1663,7 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, bool outer_ip = true; uint8_t field_idx; int ret; + uint16_t tpid; memset(off_arr, 0, sizeof(off_arr)); memset(len_arr, 0, sizeof(len_arr)); @@ -1709,14 +1732,29 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, ether_type = rte_be_to_cpu_16(eth_spec->type); if (ether_type == RTE_ETHER_TYPE_IPV4 || - ether_type == RTE_ETHER_TYPE_IPV6 || - ether_type == i40e_get_outer_vlan(dev)) { + ether_type == RTE_ETHER_TYPE_IPV6) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "Unsupported ether_type."); return -rte_errno; } + ret = i40e_get_outer_vlan(dev, &tpid); + if (ret != 0) { + rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Can not get the Ethertype identifying the L2 tag"); + return -rte_errno; + } + if (ether_type == tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported ether_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; filter->input.flow.l2_flow.ether_type = eth_spec->type; @@ -1763,14 +1801,29 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, rte_be_to_cpu_16(vlan_spec->inner_type); if (ether_type == RTE_ETHER_TYPE_IPV4 || - ether_type == RTE_ETHER_TYPE_IPV6 || - ether_type == i40e_get_outer_vlan(dev)) { + ether_type == RTE_ETHER_TYPE_IPV6) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "Unsupported inner_type."); return -rte_errno; } + ret = i40e_get_outer_vlan(dev, &tpid); + if (ret != 0) { + rte_flow_error_set(error, EIO, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Can not get the Ethertype identifying the L2 tag"); + return -rte_errno; + } + if (ether_type == tpid) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "Unsupported ether_type."); + return -rte_errno; + } + input_set |= I40E_INSET_LAST_ETHER_TYPE; filter->input.flow.l2_flow.ether_type = vlan_spec->inner_type; -- 2.45.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-20 23:41:23.555254639 +0000 +++ 0024-net-i40e-check-register-read-for-outer-VLAN.patch 2024-11-20 23:41:22.752195468 +0000 @@ -1 +1 @@ -From c11c52dd5d2a19c97616ac32a1d4911c48f157d4 Mon Sep 17 00:00:00 2001 +From e4545205ccf909b5846666e253cb4458bbbc411c Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit c11c52dd5d2a19c97616ac32a1d4911c48f157d4 ] + @@ -19 +20,0 @@ -Cc: stable@dpdk.org @@ -28 +29 @@ -index c6857727e8..cd598431e1 100644 +index 882152bd4a..be82fac8f2 100644 @@ -121 +122 @@ - ether_type = rte_be_to_cpu_16(eth_spec->hdr.ether_type); + ether_type = rte_be_to_cpu_16(eth_spec->type); @@ -151 +152 @@ - eth_spec->hdr.ether_type; + eth_spec->type; @@ -153 +154 @@ - rte_be_to_cpu_16(vlan_spec->hdr.eth_proto); + rte_be_to_cpu_16(vlan_spec->inner_type); @@ -183 +184 @@ - vlan_spec->hdr.eth_proto; + vlan_spec->inner_type;