DPDK patches and discussions
 help / color / mirror / Atom feed
From: Simei Su <simei.su@intel.com>
To: qi.z.zhang@intel.com, qiming.yang@intel.com
Cc: dev@dpdk.org, beilei.xing@intel.com, Simei Su <simei.su@intel.com>
Subject: [dpdk-dev] [PATCH] net/ice: fix a error in ACL parser
Date: Fri, 23 Oct 2020 17:32:25 +0800
Message-ID: <20201023093225.250915-1-simei.su@intel.com> (raw)

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

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


                 reply	other threads:[~2020-10-23  9:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20201023093225.250915-1-simei.su@intel.com \
    --to=simei.su@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git