patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Praveen Shetty <praveen.shetty@intel.com>
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	[thread overview]
Message-ID: <20240823111450.1738434-1-praveen.shetty@intel.com> (raw)
In-Reply-To: <20240731072303.1119177-1-praveen.shetty@intel.com>

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 <praveen.shetty@intel.com>

---
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


  parent reply	other threads:[~2024-08-23 11:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30  5:09 [PATCH v1] " Praveen Shetty
2024-07-31  7:23 ` [PATCH v2] " Praveen Shetty
2024-08-22 16:50   ` Bruce Richardson
2024-08-23  7:28     ` Shetty, Praveen
2024-08-23 11:14   ` Praveen Shetty [this message]
2024-08-26 15:32     ` [PATCH v3] " Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240823111450.1738434-1-praveen.shetty@intel.com \
    --to=praveen.shetty@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).