From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 78621A04E4; Wed, 12 Aug 2020 05:20:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9F6C21C002; Wed, 12 Aug 2020 05:20:33 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id BDA66E07; Wed, 12 Aug 2020 05:20:31 +0200 (CEST) IronPort-SDR: wDeYrMyq/XL75ZOEec0DIAZV9pwu84FqMPfPqHfPufdWi92MTjFe+nEgFM4rB/oxJ/T3E7zMUs ojsVZkvGH/Tg== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="153845908" X-IronPort-AV: E=Sophos;i="5.76,302,1592895600"; d="scan'208";a="153845908" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 20:20:30 -0700 IronPort-SDR: WVGlZDXw0R7eJQo82VTbucCTlisESQnhPi3dqZMMXVJvpSZZGT4hgY3iClwI+dXEytWUsy1Zp2 4s8ACePoMM/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,302,1592895600"; d="scan'208";a="294924871" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([172.16.182.123]) by orsmga006.jf.intel.com with ESMTP; 11 Aug 2020 20:20:28 -0700 From: Wei Zhao To: dev@dpdk.org Cc: stable@dpdk.org, qi.z.zhang@intel.com, nannan.lu@intel.com, Wei Zhao Date: Wed, 12 Aug 2020 10:53:26 +0800 Message-Id: <20200812025326.21506-1-wei.zhao1@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200812005646.58732-1-wei.zhao1@intel.com> References: <20200812005646.58732-1-wei.zhao1@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3] net/ice: fix VF index check for DCF X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" The vf index in rte_flow command need to check in order that larger than actual number. Also change some error log for wrong action. Fixes: 829c3106812d ("net/ice: enable switch flow on DCF") Cc: stable@dpdk.org Signed-off-by: Wei Zhao --- v2: change error log v3: add new error log --- drivers/net/ice/ice_switch_filter.c | 36 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index c4b00b6a2..8579889f3 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -1405,6 +1405,16 @@ ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad, case RTE_FLOW_ACTION_TYPE_VF: rule_info->sw_act.fltr_act = ICE_FWD_TO_VSI; act_vf = action->conf; + + if (act_vf->id >= ad->real_hw.num_vfs && + !act_vf->original) { + rte_flow_error_set(error, + EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Invalid vf id"); + return -rte_errno; + } + if (act_vf->original) rule_info->sw_act.vsi_handle = ad->real_hw.avf.bus.func; @@ -1415,7 +1425,7 @@ ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad, rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, - "Invalid action type or queue number"); + "Invalid action type"); return -rte_errno; } } @@ -1467,11 +1477,11 @@ ice_switch_parse_action(struct ice_pf *pf, if ((act_qgrop->queue[0] + act_qgrop->queue_num) > dev->data->nb_rx_queues) - goto error; + goto error1; for (i = 0; i < act_qgrop->queue_num - 1; i++) if (act_qgrop->queue[i + 1] != act_qgrop->queue[i] + 1) - goto error; + goto error2; rule_info->sw_act.qgrp_size = act_qgrop->queue_num; break; @@ -1511,6 +1521,20 @@ ice_switch_parse_action(struct ice_pf *pf, actions, "Invalid action type or queue number"); return -rte_errno; + +error1: + rte_flow_error_set(error, + EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Invalid queue region indexes"); + return -rte_errno; + +error2: + rte_flow_error_set(error, + EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Discontinuous queue region"); + return -rte_errno; } static int @@ -1667,12 +1691,8 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad, else ret = ice_switch_parse_action(pf, actions, error, &rule_info); - if (ret) { - rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "Invalid input action"); + if (ret) goto error; - } if (meta) { *meta = sw_meta_ptr; -- 2.19.1