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 49D8A45849; Fri, 23 Aug 2024 13:15:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBCCA432FC; Fri, 23 Aug 2024 13:15:30 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id 2742F432F6; Fri, 23 Aug 2024 13:15:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724411730; x=1755947730; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KYAXArUBwokyHAvxQFszslViTSTcWQPuVhAI+dw0YRA=; b=Pzkhp4jyJcweRLPNWOSCSttV5+flywkLNRluyfYo00amnvJL6RhCqAkg g+qn4siHyzSIkP6DySxDCphxxjM3ZDMaG62l1Z7kb1JfNV4PhsGcP/tk8 +lc+n9FqXXrNMFjJmc1bZbLGEeS5Kc3JZphsO43VlVHKv/VxsKvzgzLh+ bPD/tMi7v1WWLylh0Fu+O7vebsXIf7dhkISZlNS+YCnk8Ov7n9MlEZHXA IHosQBxTetxJqyqcoZnC4iMqLHf8rQWu61gVZvQNUlOSnulWSDu0/Fuzd uNTrE4/ie+QIcDhfemI3owePpA+3Y3Rc7jc2qrSlSw0hbSnFLaOjBkib3 g==; X-CSE-ConnectionGUID: bWCasGU/Sj+yACaTMgCCyg== X-CSE-MsgGUID: aAI4VuxcS4OjIUBE4EDFfg== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="33440732" X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="33440732" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 04:15:07 -0700 X-CSE-ConnectionGUID: wFxGO9sFRT+thT3mKBmA5Q== X-CSE-MsgGUID: QMI9JwxkR7mJwO3ST85iWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="61916579" Received: from silpixa00401164.ir.intel.com ([10.55.128.62]) by fmviesa010.fm.intel.com with ESMTP; 23 Aug 2024 04:15:05 -0700 From: Praveen Shetty To: bruce.richardson@intel.com Cc: dev@dpdk.org, stable@dpdk.org Subject: [PATCH v3] net/cpfl: fix cpfl parser issue Date: Fri, 23 Aug 2024 11:14:50 +0000 Message-Id: <20240823111450.1738434-1-praveen.shetty@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731072303.1119177-1-praveen.shetty@intel.com> References: <20240731072303.1119177-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. v3: * Addressed review comments. --- 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..692b208a65 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 (rte_strscpy(js_field->fields[i].mask, + mask, CPFL_JS_STR_SIZE) < 0) { + PMD_DRV_LOG(ERR, "The 'mask' is too long."); + goto err; + } } - 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