All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>
To: netdev@vger.kernel.org
Cc: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
	linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Ariel Elior" <aelior@marvell.com>,
	"Manish Chopra" <manishc@marvell.com>
Subject: [PATCH net-next] net: qede: flower: validate control flags
Date: Wed, 24 Apr 2024 13:42:48 +0000	[thread overview]
Message-ID: <20240424134250.465904-1-ast@fiberby.net> (raw)

This driver currently doesn't support any flower control flags.

Implement check for control flags, such as can be set through
`tc flower ... ip_flags frag`.

Since qede_parse_flow_attr() are called by both qede_add_tc_flower_fltr()
and qede_flow_spec_to_rule(), as the latter doesn't having access to
extack, then flow_rule_*_control_flags() can't be used in this driver.

This patch therefore re-implements flow_rule_match_has_control_flags(),
but with error messaging via DP_NOTICE, instead of NL_SET_ERR_MSG_FMT_MOD.

So in case any control flags are masked, we call DP_NOTICE() and
return -EOPNOTSUPP.

Only compile-tested.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---

This is AFAICT the last driver which didn't validate these flags.

$ git grep FLOW_DISSECTOR_KEY_CONTROL drivers/
$ git grep 'flow_rule_.*_control_flags' drivers/

 drivers/net/ethernet/qlogic/qede/qede_filter.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index a5ac21a0ee33..40f72e700d8e 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1843,6 +1843,19 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
 		return -EPROTONOSUPPORT;
 	}
 
+	if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
+		struct flow_match_control match;
+
+		flow_rule_match_control(rule, &match);
+
+		if (match.mask->flags) {
+			DP_NOTICE(edev,
+				  "Unsupported match on control.flags %#x",
+				  match.mask->flags);
+			return -EOPNOTSUPP;
+		}
+	}
+
 	if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
 		struct flow_match_basic match;
 
-- 
2.43.0


             reply	other threads:[~2024-04-24 13:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 13:42 Asbjørn Sloth Tønnesen [this message]
2024-04-24 14:52 ` [PATCH net-next] net: qede: flower: validate control flags Jiri Pirko
2024-04-24 16:43   ` Asbjørn Sloth Tønnesen
2024-04-25  7:04     ` Jiri Pirko

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=20240424134250.465904-1-ast@fiberby.net \
    --to=ast@fiberby.net \
    --cc=aelior@marvell.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishc@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.