[v1] net/cpfl: fix cpfl parser issue

Message ID 20240730050952.837611-1-praveen.shetty@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers
Series [v1] net/cpfl: fix cpfl parser issue |

Checks

Context Check Description
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing warning Testing issues
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Praveen Shetty July 30, 2024, 5:09 a.m. UTC
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 <praveen.shetty@intel.com>
---
 drivers/net/cpfl/cpfl_flow_parser.c | 31 ++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)
  

Patch

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;