Skip to contentSkip to conversation

net/ice: fix pattern check logic in FDIR

PATCH Superseded Junfeng Guo 2 participants 4 messages Feb 8, 2022 – Feb 11, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: fix pattern check logic in FDIR

Mask for IPv4/UDP/TCP/SCTP addr/port are not supported in current code. Thus we need to check the pattern with non-zero spec value. If the spec is non-zero value but its mask is not full-mask, this Flow Director rule is not supported and will return failed.

Fixes 54be6102ef97 ("net/ice: fix pattern check for FDIR parser")
---
 drivers/net/ice/ice_fdir_filter.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/ice/ice_fdir_filter.c +10 -10
index 287032a6a7..a6311b78fe 100644
@@ -2038,10 +2038,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for IPv4 src/dst addrs not supported */
-			if (!ipv4_mask->hdr.src_addr &&
+			if (ipv4_spec->hdr.src_addr &&
 				ipv4_mask->hdr.src_addr != UINT32_MAX)
 				return -rte_errno;
-			if (!ipv4_mask->hdr.dst_addr &&
+			if (ipv4_spec->hdr.dst_addr &&
 				ipv4_mask->hdr.dst_addr != UINT32_MAX)
 				return -rte_errno;
 
@@ -2187,10 +2187,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for TCP src/dst ports not supported */
-			if (!tcp_mask->hdr.src_port &&
+			if (tcp_spec->hdr.src_port &&
 				tcp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!tcp_mask->hdr.dst_port &&
+			if (tcp_spec->hdr.dst_port &&
 				tcp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
@@ -2234,16 +2234,16 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for UDP src/dst ports not supported */
-			if (!udp_mask->hdr.src_port &&
+			if (udp_mask->hdr.src_port &&
 				udp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!udp_mask->hdr.dst_port &&
+			if (udp_mask->hdr.dst_port &&
 				udp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
-			if (udp_mask->hdr.src_port == UINT16_MAX)
+			if (udp_spec->hdr.src_port == UINT16_MAX)
 				*input_set |= ICE_INSET_UDP_SRC_PORT;
-			if (udp_mask->hdr.dst_port == UINT16_MAX)
+			if (udp_spec->hdr.dst_port == UINT16_MAX)
 				*input_set |= ICE_INSET_UDP_DST_PORT;
 
 			/* Get filter info */
@@ -2279,10 +2279,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for SCTP src/dst ports not supported */
-			if (!sctp_mask->hdr.src_port &&
+			if (sctp_spec->hdr.src_port &&
 				sctp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!sctp_mask->hdr.dst_port &&
+			if (sctp_spec->hdr.dst_port &&
 				sctp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 net/ice: fix pattern check logic in FDIR

Mask for IPv4/UDP/TCP/SCTP addr/port are not supported in current code. Thus we need to check the pattern with non-zero spec value. If the spec is non-zero value but its mask is not full-mask, this Flow Director rule is not supported and will return failed.

Fixes 54be6102ef97 ("net/ice: fix pattern check for FDIR parser")
---
 drivers/net/ice/ice_fdir_filter.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ice/ice_fdir_filter.c +8 -8
index 287032a6a7..9e4a0f158f 100644
@@ -2038,10 +2038,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for IPv4 src/dst addrs not supported */
-			if (!ipv4_mask->hdr.src_addr &&
+			if (ipv4_spec->hdr.src_addr &&
 				ipv4_mask->hdr.src_addr != UINT32_MAX)
 				return -rte_errno;
-			if (!ipv4_mask->hdr.dst_addr &&
+			if (ipv4_spec->hdr.dst_addr &&
 				ipv4_mask->hdr.dst_addr != UINT32_MAX)
 				return -rte_errno;
 
@@ -2187,10 +2187,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for TCP src/dst ports not supported */
-			if (!tcp_mask->hdr.src_port &&
+			if (tcp_spec->hdr.src_port &&
 				tcp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!tcp_mask->hdr.dst_port &&
+			if (tcp_spec->hdr.dst_port &&
 				tcp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
@@ -2234,10 +2234,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for UDP src/dst ports not supported */
-			if (!udp_mask->hdr.src_port &&
+			if (udp_spec->hdr.src_port &&
 				udp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!udp_mask->hdr.dst_port &&
+			if (udp_spec->hdr.dst_port &&
 				udp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
@@ -2279,10 +2279,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for SCTP src/dst ports not supported */
-			if (!sctp_mask->hdr.src_port &&
+			if (sctp_spec->hdr.src_port &&
 				sctp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!sctp_mask->hdr.dst_port &&
+			if (sctp_spec->hdr.dst_port &&
 				sctp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 1/1 net/ice: fix pattern check logic in FDIR

Mask for IPv4/UDP/TCP/SCTP addr/port are not supported in current code. Thus we need to check each pattern mask. Only zero-mask and full-mask are allowed to pass the pattern parse, otherwise will return failure.

Fixes 54be6102ef97 ("net/ice: fix pattern check for FDIR parser")
---
 drivers/net/ice/ice_fdir_filter.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ice/ice_fdir_filter.c +8 -8
index 287032a6a7..ff1cee1195 100644
@@ -2038,10 +2038,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for IPv4 src/dst addrs not supported */
-			if (!ipv4_mask->hdr.src_addr &&
+			if (ipv4_mask->hdr.src_addr &&
 				ipv4_mask->hdr.src_addr != UINT32_MAX)
 				return -rte_errno;
-			if (!ipv4_mask->hdr.dst_addr &&
+			if (ipv4_mask->hdr.dst_addr &&
 				ipv4_mask->hdr.dst_addr != UINT32_MAX)
 				return -rte_errno;
 
@@ -2187,10 +2187,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for TCP src/dst ports not supported */
-			if (!tcp_mask->hdr.src_port &&
+			if (tcp_mask->hdr.src_port &&
 				tcp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!tcp_mask->hdr.dst_port &&
+			if (tcp_mask->hdr.dst_port &&
 				tcp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
@@ -2234,10 +2234,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for UDP src/dst ports not supported */
-			if (!udp_mask->hdr.src_port &&
+			if (udp_mask->hdr.src_port &&
 				udp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!udp_mask->hdr.dst_port &&
+			if (udp_mask->hdr.dst_port &&
 				udp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
@@ -2279,10 +2279,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			}
 
 			/* Mask for SCTP src/dst ports not supported */
-			if (!sctp_mask->hdr.src_port &&
+			if (sctp_mask->hdr.src_port &&
 				sctp_mask->hdr.src_port != UINT16_MAX)
 				return -rte_errno;
-			if (!sctp_mask->hdr.dst_port &&
+			if (sctp_mask->hdr.dst_port &&
 				sctp_mask->hdr.dst_port != UINT16_MAX)
 				return -rte_errno;
 
Signature · 1 line
2.25.1
Acked-by on v3 1/1 Applied
#3 lore raw
Quoted 10 lines

-----Original Message-----
From: Guo, Junfeng <[email protected]>
Sent: Tuesday, February 8, 2022 3:09 PM
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; [email protected]; Guo, Junfeng <[email protected]>
Subject: [PATCH v3] net/ice: fix pattern check logic in FDIR

Quoted 8 lines

Mask for IPv4/UDP/TCP/SCTP addr/port are not supported in current code. Thus we need to check each pattern mask. Only zero-mask and full-mask are allowed to pass the pattern parse, otherwise will return failure.

Fixes 54be6102ef97 ("net/ice: fix pattern check for FDIR parser")

Applied to dpdk-next-net-intel.

Thanks
Qi