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 4744C456EF; Tue, 30 Jul 2024 07:12:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C25AA4069F; Tue, 30 Jul 2024 07:12:25 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by mails.dpdk.org (Postfix) with ESMTP id 84AED402BB; Tue, 30 Jul 2024 07:10:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722316203; x=1753852203; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uJD8G7bUhMnmRTtqfymYCFi5/BR/3zj1/eSwxrtPFBQ=; b=CgdjEYGOiZ4J6kSjjn/zaQ6IZMI52VFy/4qURl58cUxsUX8UnaNbJp69 i3aP+516vD6R8yeJA8NyMGDyY4AZ+9TDh2q8lk1ON30jB98r6OGKB2Bvt ezOfX0Bd8C7GdOOTphPq26fPRoWzaNuWBbISVNQ3ROp+O1lQAY8qGTwTx Wk4O8WjWF69WTL9/RAPfX9NJYVOrlXzcPvnvRIEGwnlsQBZL33b1n+kQR 0LVgpucnagyXlpKyBXFIL3kZQmgCZiqhCbA+A93z33F+wNNh/WqqvTwMP hQAZttVlTFU/US6hZF3yXkYx03m88FSyvr1v+FL3gZSWFM9CFAmO1P9hV A==; X-CSE-ConnectionGUID: ZZYRTOsHRH+Ow0jxIOTrqA== X-CSE-MsgGUID: qtBwUyPtRkS20xKAubiunQ== X-IronPort-AV: E=McAfee;i="6700,10204,11148"; a="31257230" X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="31257230" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2024 22:09:57 -0700 X-CSE-ConnectionGUID: EUIR8a+LTQahwZiBpArSUQ== X-CSE-MsgGUID: C49QRncBQs+RMj/yfgbofw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="54122662" Received: from silpixa00401164.ir.intel.com ([10.55.128.62]) by orviesa010.jf.intel.com with ESMTP; 29 Jul 2024 22:09:57 -0700 From: Praveen Shetty To: dev@dpdk.org, bruce.richardson@intel.com Cc: stable@dpdk.org Subject: [PATCH v1] net/cpfl: fix cpfl parser issue Date: Tue, 30 Jul 2024 05:09:52 +0000 Message-Id: <20240730050952.837611-1-praveen.shetty@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 CPFL parser was incorrectly parsing the mask value of the next_proto_id field as a string instead of unsigned integer. This patch will fix this issue. Fixes: 41f20298ee8c ("net/cpfl: parse flow offloading hint from JSON") Cc: stable@dpdk.org Signed-off-by: Praveen Shetty --- drivers/net/cpfl/cpfl_flow_parser.c | 31 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/cpfl/cpfl_flow_parser.c b/drivers/net/cpfl/cpfl_flow_parser.c index 40569ddc6f..9845bd1ad3 100644 --- a/drivers/net/cpfl/cpfl_flow_parser.c +++ b/drivers/net/cpfl/cpfl_flow_parser.c @@ -213,16 +213,29 @@ cpfl_flow_js_pattern_key_proto_field(json_t *ob_fields, if (js_field->type == RTE_FLOW_ITEM_TYPE_ETH || js_field->type == RTE_FLOW_ITEM_TYPE_IPV4) { - mask = cpfl_json_t_to_string(object, "mask"); - if (!mask) { - PMD_DRV_LOG(ERR, "Can not parse string 'mask'."); - goto err; - } - if (strlen(mask) > CPFL_JS_STR_SIZE - 1) { - PMD_DRV_LOG(ERR, "The 'mask' is too long."); - goto err; + /* Added a check for parsing mask value of the next_proto_id field. */ + if (strcmp(name, "next_proto_id") == 0) { + uint32_t mask_32b; + int ret; + ret = cpfl_json_t_to_uint32(object, "mask", &mask_32b); + if (ret < 0) { + PMD_DRV_LOG(ERR, "Can not parse uint32 'mask'."); + goto err; + } + js_field->fields[i].mask_32b = mask_32b; + } else { + mask = cpfl_json_t_to_string(object, "mask"); + if (!mask) { + PMD_DRV_LOG(ERR, "Can not parse string 'mask'."); + goto err; + } + if (strlen(mask) > CPFL_JS_STR_SIZE - 1) { + PMD_DRV_LOG(ERR, "The 'mask' is too long."); + goto err; + } + rte_strscpy(js_field->fields[i].mask, mask, CPFL_JS_STR_SIZE - 1); } - strncpy(js_field->fields[i].mask, mask, CPFL_JS_STR_SIZE - 1); + } else { uint32_t mask_32b; int ret; -- 2.34.1