dpdk: fix generic flow input parsing in FDIR 86/36086/1
authorTing Xu <ting.xu@intel.com>
Thu, 5 May 2022 09:12:50 +0000 (09:12 +0000)
committerTing Xu <ting.xu@intel.com>
Thu, 5 May 2022 09:27:36 +0000 (09:27 +0000)
This patch fixes the issue that in DPDK FDIR generic flow parsing, the
inputs will be changed during processing, which will lead to a failure
in vnet flow when creating generic flow rules.

Type: fix

Signed-off-by: Ting Xu <ting.xu@intel.com>
Change-Id: I107735a305ff48593d66746e0cd642c76ad5700d

build/external/patches/dpdk_22.03/0001-net-ice-fix-raw-flow-input-pattern-value-change-i.patch [new file with mode: 0644]

diff --git a/build/external/patches/dpdk_22.03/0001-net-ice-fix-raw-flow-input-pattern-value-change-i.patch b/build/external/patches/dpdk_22.03/0001-net-ice-fix-raw-flow-input-pattern-value-change-i.patch
new file mode 100644 (file)
index 0000000..755f5bc
--- /dev/null
@@ -0,0 +1,96 @@
+From 794d99b8abeeb401a374489a9e3c629d023c271f Mon Sep 17 00:00:00 2001
+From: Ting Xu <ting.xu@intel.com>
+Date: Fri, 4 Mar 2022 07:26:28 +0000
+Subject: [PATCH v2] net/ice: fix raw flow input pattern value change in FDIR
+
+When parsing raw flow pattern in FDIR, the input parameter spec and
+mask are used directly and the original value will be changed. It
+will cause error if these values are used in other functions. In this
+patch, temporary variables are created to store the spec and mask.
+
+Fixes: 25be39cc1760 ("net/ice: enable protocol agnostic flow offloading in FDIR")
+
+Cc: stable@dpdk.org
+
+Signed-off-by: Ting Xu <ting.xu@intel.com>
+---
+ drivers/net/ice/ice_fdir_filter.c | 25 +++++++++++++++++++------
+ 1 file changed, 19 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
+index 7954c6d8ea..5ff1afac90 100644
+--- a/drivers/net/ice/ice_fdir_filter.c
++++ b/drivers/net/ice/ice_fdir_filter.c
+@@ -1868,10 +1868,11 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
+                               break;
+                       /* convert raw spec & mask from byte string to int */
+-                      unsigned char *tmp_spec =
++                      unsigned char *spec_pattern =
+                               (uint8_t *)(uintptr_t)raw_spec->pattern;
+-                      unsigned char *tmp_mask =
++                      unsigned char *mask_pattern =
+                               (uint8_t *)(uintptr_t)raw_mask->pattern;
++                      uint8_t *tmp_spec, *tmp_mask;
+                       uint16_t udp_port = 0;
+                       uint16_t tmp_val = 0;
+                       uint8_t pkt_len = 0;
+@@ -1883,8 +1884,18 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
+                               pkt_len)
+                               return -rte_errno;
++                      tmp_spec = rte_zmalloc(NULL, pkt_len / 2, 0);
++                      if (!tmp_spec)
++                              return -rte_errno;
++
++                      tmp_mask = rte_zmalloc(NULL, pkt_len / 2, 0);
++                      if (!tmp_mask) {
++                              rte_free(tmp_spec);
++                              return -rte_errno;
++                      }
++
+                       for (i = 0, j = 0; i < pkt_len; i += 2, j++) {
+-                              tmp = tmp_spec[i];
++                              tmp = spec_pattern[i];
+                               if (tmp >= 'a' && tmp <= 'f')
+                                       tmp_val = tmp - 'a' + 10;
+                               if (tmp >= 'A' && tmp <= 'F')
+@@ -1893,7 +1904,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
+                                       tmp_val = tmp - '0';
+                               tmp_val *= 16;
+-                              tmp = tmp_spec[i + 1];
++                              tmp = spec_pattern[i + 1];
+                               if (tmp >= 'a' && tmp <= 'f')
+                                       tmp_spec[j] = tmp_val + tmp - 'a' + 10;
+                               if (tmp >= 'A' && tmp <= 'F')
+@@ -1901,7 +1912,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
+                               if (tmp >= '0' && tmp <= '9')
+                                       tmp_spec[j] = tmp_val + tmp - '0';
+-                              tmp = tmp_mask[i];
++                              tmp = mask_pattern[i];
+                               if (tmp >= 'a' && tmp <= 'f')
+                                       tmp_val = tmp - 'a' + 10;
+                               if (tmp >= 'A' && tmp <= 'F')
+@@ -1910,7 +1921,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
+                                       tmp_val = tmp - '0';
+                               tmp_val *= 16;
+-                              tmp = tmp_mask[i + 1];
++                              tmp = mask_pattern[i + 1];
+                               if (tmp >= 'a' && tmp <= 'f')
+                                       tmp_mask[j] = tmp_val + tmp - 'a' + 10;
+                               if (tmp >= 'A' && tmp <= 'F')
+@@ -1953,6 +1964,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
+                       filter->parser_ena = true;
++                      rte_free(tmp_spec);
++                      rte_free(tmp_mask);
+                       break;
+               }
+-- 
+2.17.1
+