net/ice: fix a error in ACL parser
diff mbox series

Message ID 20201023093225.250915-1-simei.su@intel.com
State Superseded
Delegated to: Qi Zhang
Headers show
Series
  • net/ice: fix a error in ACL parser
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Simei Su Oct. 23, 2020, 9:32 a.m. UTC
A ACL rule with only mask not spec is invalid. This patch corrects
incomplete implementation in parsing ACL pattern.

Fixes: d623d798c7e6 ("net/ice: support ACL filter in DCF")

Signed-off-by: Simei Su <simei.su@intel.com>
---
 drivers/net/ice/ice_acl_filter.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/ice/ice_acl_filter.c b/drivers/net/ice/ice_acl_filter.c
index ca483f0..0915d50 100644
--- a/drivers/net/ice/ice_acl_filter.c
+++ b/drivers/net/ice/ice_acl_filter.c
@@ -710,7 +710,8 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 					return -rte_errno;
 				}
 
-				if (ipv4_mask->hdr.src_addr) {
+				if (ipv4_spec->hdr.src_addr &&
+				    ipv4_mask->hdr.src_addr) {
 					filter->input.ip.v4.src_ip =
 						ipv4_spec->hdr.src_addr;
 					filter->input.mask.v4.src_ip =
@@ -719,7 +720,8 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 					input_set |= ICE_INSET_IPV4_SRC;
 				}
 
-				if (ipv4_mask->hdr.dst_addr) {
+				if (ipv4_spec->hdr.dst_addr &&
+				    ipv4_mask->hdr.dst_addr) {
 					filter->input.ip.v4.dst_ip =
 						ipv4_spec->hdr.dst_addr;
 					filter->input.mask.v4.dst_ip =
@@ -755,6 +757,7 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 				}
 
 				if (l3 == RTE_FLOW_ITEM_TYPE_IPV4 &&
+				    tcp_spec->hdr.src_port &&
 				    tcp_mask->hdr.src_port) {
 					input_set |= ICE_INSET_TCP_SRC_PORT;
 					filter->input.ip.v4.src_port =
@@ -764,6 +767,7 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 				}
 
 				if (l3 == RTE_FLOW_ITEM_TYPE_IPV4 &&
+				    tcp_spec->hdr.dst_port &&
 				    tcp_mask->hdr.dst_port) {
 					input_set |= ICE_INSET_TCP_DST_PORT;
 					filter->input.ip.v4.dst_port =
@@ -792,6 +796,7 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 				}
 
 				if (l3 == RTE_FLOW_ITEM_TYPE_IPV4 &&
+				    udp_spec->hdr.src_port &&
 				    udp_mask->hdr.src_port) {
 					input_set |= ICE_INSET_UDP_SRC_PORT;
 					filter->input.ip.v4.src_port =
@@ -801,6 +806,7 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 				}
 
 				if (l3 == RTE_FLOW_ITEM_TYPE_IPV4 &&
+				    udp_spec->hdr.dst_port &&
 				    udp_mask->hdr.dst_port) {
 					input_set |= ICE_INSET_UDP_DST_PORT;
 					filter->input.ip.v4.dst_port =
@@ -819,6 +825,7 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 
 			if (sctp_spec && sctp_mask) {
 				if (l3 == RTE_FLOW_ITEM_TYPE_IPV4 &&
+				    sctp_spec->hdr.src_port &&
 				    sctp_mask->hdr.src_port) {
 					input_set |= ICE_INSET_SCTP_SRC_PORT;
 					filter->input.ip.v4.src_port =
@@ -828,6 +835,7 @@  ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad,
 				}
 
 				if (l3 == RTE_FLOW_ITEM_TYPE_IPV4 &&
+				    sctp_spec->hdr.dst_port &&
 				    sctp_mask->hdr.dst_port) {
 					input_set |= ICE_INSET_SCTP_DST_PORT;
 					filter->input.ip.v4.dst_port =