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 0CFAE456EE; Wed, 31 Jul 2024 09:31:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2365040BA0; Wed, 31 Jul 2024 09:31:19 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by mails.dpdk.org (Postfix) with ESMTP id 61BAE4065D; Wed, 31 Jul 2024 09:23:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722410589; x=1753946589; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ba8Rd7GotXJx1ABt0XRU4XfGZgYBCDZZxkQZf7ntgcY=; b=IypPn+sGBYcmSdIz2vo2crgjvE4k7BAaeev0jxTktMTvOuaRN8UQcPiL zghBYwq70JPiOjuK93o4sFxHmkpUnomTbRH3IKiCe49RkcDDs8opz5xyO cUOBsN679vnr+Vy5FUI0qqIkMTVyAR2f1BciG8A5slC6wM2P9k3ikGXkN jIyabQAJXJ30pIODZqusFPOAeYI7yP2UZVd8NkyuPU/hKY6XUE5d5M1oD OOjNI+NwIEs7nEMWqfO7waXRDhl9wajpqGLkXI+78BkK1HOPGf1XIZiOU VbL6xha3VFjtaiV3/ZH19tAwAtfx1gFa7FcX6ySsh/sQI2a91gcZ5+rTr g==; X-CSE-ConnectionGUID: JzhKy7oKTju1T15pzCwAWQ== X-CSE-MsgGUID: wffM+aXBRs6fUyVKjvJ93Q== X-IronPort-AV: E=McAfee;i="6700,10204,11149"; a="20396261" X-IronPort-AV: E=Sophos;i="6.09,250,1716274800"; d="scan'208";a="20396261" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2024 00:23:07 -0700 X-CSE-ConnectionGUID: SVkizoQXQ4+grOo3V+Zi4w== X-CSE-MsgGUID: o47im5BrSDaeBrSgGI1OnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,250,1716274800"; d="scan'208";a="92108815" Received: from silpixa00401164.ir.intel.com ([10.55.128.62]) by orviesa001.jf.intel.com with ESMTP; 31 Jul 2024 00:23:06 -0700 From: Praveen Shetty To: bruce.richardson@intel.com Cc: dev@dpdk.org, stable@dpdk.org Subject: [PATCH v2] net/cpfl: fix cpfl parser issue Date: Wed, 31 Jul 2024 07:23:03 +0000 Message-Id: <20240731072303.1119177-1-praveen.shetty@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730050952.837611-1-praveen.shetty@intel.com> References: <20240730050952.837611-1-praveen.shetty@intel.com> 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 from recipe.json file as a string instead of unsigned integer. Fixes: 41f20298ee8c ("net/cpfl: parse flow offloading hint from JSON") Cc: stable@dpdk.org Signed-off-by: Praveen Shetty --- v2: * Fixed CI issues. --- drivers/net/cpfl/cpfl_flow_parser.c | 34 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/net/cpfl/cpfl_flow_parser.c b/drivers/net/cpfl/cpfl_flow_parser.c index 40569ddc6f..7800ad97ea 100644 --- a/drivers/net/cpfl/cpfl_flow_parser.c +++ b/drivers/net/cpfl/cpfl_flow_parser.c @@ -198,6 +198,8 @@ cpfl_flow_js_pattern_key_proto_field(json_t *ob_fields, for (i = 0; i < len; i++) { json_t *object; const char *name, *mask; + uint32_t mask_32b = 0; + int ret; object = json_array_get(ob_fields, i); name = cpfl_json_t_to_string(object, "name"); @@ -213,20 +215,28 @@ 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) { + ret = cpfl_json_t_to_uint32(object, "mask", &mask_32b); + if (ret < 0) { + PMD_DRV_LOG(ERR, "Cannot 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; + } else { ret = cpfl_json_t_to_uint32(object, "mask", &mask_32b); if (ret < 0) { PMD_DRV_LOG(ERR, "Can not parse uint32 'mask'."); -- 2.34.1