Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
	Pieter Jansen van Vuuren  <pieter.jansenvanvuuren@netronome.com>
Subject: [PATCH net-next] nfp: flower: fix masks for tcp and ip flags fields
Date: Thu, 14 Feb 2019 14:37:16 -0800	[thread overview]
Message-ID: <20190214223716.25491-1-jakub.kicinski@netronome.com> (raw)

From: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>

Check mask fields of tcp and ip flags when setting the corresponding mask
flag used in hardware.

Fixes: 8f2566225ae2 ("flow_offload: add flow_rule and flow_match")
Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: John Hurley <john.hurley@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 .../net/ethernet/netronome/nfp/flower/match.c | 35 +++++++++++--------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c
index 1279fa5da9e1..e03c8ef2c28c 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/match.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/match.c
@@ -172,46 +172,51 @@ nfp_flower_compile_ip_ext(struct nfp_flower_ip_ext *ext,
 	}
 
 	if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_TCP)) {
+		u16 tcp_flags, tcp_flags_mask;
 		struct flow_match_tcp match;
-		u16 tcp_flags;
 
 		flow_rule_match_tcp(rule, &match);
 		tcp_flags = be16_to_cpu(match.key->flags);
+		tcp_flags_mask = be16_to_cpu(match.mask->flags);
 
-		if (tcp_flags & TCPHDR_FIN) {
+		if (tcp_flags & TCPHDR_FIN)
 			ext->flags |= NFP_FL_TCP_FLAG_FIN;
+		if (tcp_flags_mask & TCPHDR_FIN)
 			msk->flags |= NFP_FL_TCP_FLAG_FIN;
-		}
-		if (tcp_flags & TCPHDR_SYN) {
+
+		if (tcp_flags & TCPHDR_SYN)
 			ext->flags |= NFP_FL_TCP_FLAG_SYN;
+		if (tcp_flags_mask & TCPHDR_SYN)
 			msk->flags |= NFP_FL_TCP_FLAG_SYN;
-		}
-		if (tcp_flags & TCPHDR_RST) {
+
+		if (tcp_flags & TCPHDR_RST)
 			ext->flags |= NFP_FL_TCP_FLAG_RST;
+		if (tcp_flags_mask & TCPHDR_RST)
 			msk->flags |= NFP_FL_TCP_FLAG_RST;
-		}
-		if (tcp_flags & TCPHDR_PSH) {
+
+		if (tcp_flags & TCPHDR_PSH)
 			ext->flags |= NFP_FL_TCP_FLAG_PSH;
+		if (tcp_flags_mask & TCPHDR_PSH)
 			msk->flags |= NFP_FL_TCP_FLAG_PSH;
-		}
-		if (tcp_flags & TCPHDR_URG) {
+
+		if (tcp_flags & TCPHDR_URG)
 			ext->flags |= NFP_FL_TCP_FLAG_URG;
+		if (tcp_flags_mask & TCPHDR_URG)
 			msk->flags |= NFP_FL_TCP_FLAG_URG;
-		}
 	}
 
 	if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
 		struct flow_match_control match;
 
 		flow_rule_match_control(rule, &match);
-		if (match.key->flags & FLOW_DIS_IS_FRAGMENT) {
+		if (match.key->flags & FLOW_DIS_IS_FRAGMENT)
 			ext->flags |= NFP_FL_IP_FRAGMENTED;
+		if (match.mask->flags & FLOW_DIS_IS_FRAGMENT)
 			msk->flags |= NFP_FL_IP_FRAGMENTED;
-		}
-		if (match.key->flags & FLOW_DIS_FIRST_FRAG) {
+		if (match.key->flags & FLOW_DIS_FIRST_FRAG)
 			ext->flags |= NFP_FL_IP_FRAG_FIRST;
+		if (match.mask->flags & FLOW_DIS_FIRST_FRAG)
 			msk->flags |= NFP_FL_IP_FRAG_FIRST;
-		}
 	}
 }
 
-- 
2.19.2


             reply	other threads:[~2019-02-14 22:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 22:37 Jakub Kicinski [this message]
2019-02-17 23:29 ` [PATCH net-next] nfp: flower: fix masks for tcp and ip flags fields David Miller

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=20190214223716.25491-1-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=pieter.jansenvanvuuren@netronome.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
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