From: David Yang <mmyangfl@gmail.com>
To: netdev@vger.kernel.org
Cc: David Yang <mmyangfl@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net] net: dsa: motorcomm: Reject isolated redirect targets
Date: Fri, 27 Nov 2026 22:27:28 +0800 [thread overview]
Message-ID: <20261127142732.1337041-1-mmyangfl@gmail.com> (raw)
Port isolation takes after REDIR judgment, but software may deliver
such frames. Reject such offloading.
Triggered and verified on YT9215S.
Fixes: 8eb9e7520b17 ("net: dsa: yt921x: Add ACL support")
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/dsa/motorcomm/tc.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c
index e3f057ed580f..5713ae84ece7 100644
--- a/drivers/net/dsa/motorcomm/tc.c
+++ b/drivers/net/dsa/motorcomm/tc.c
@@ -1064,7 +1064,10 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
terminal = true;
break;
case FLOW_ACTION_REDIRECT: {
+ struct yt921x_port *pp = &priv->ports[port];
+ struct yt921x_port *to_pp;
struct dsa_port *to_dp;
+ struct dsa_port *dp;
to_dp = dsa_port_from_netdev(act->dev);
if (IS_ERR(to_dp) || to_dp->ds != &priv->ds) {
@@ -1072,6 +1075,27 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
goto fallback;
}
+ /* Port isolation takes after REDIR judgment, but
+ * software may deliver such frames.
+ *
+ * Bridge membership changes may break existing REDIR
+ * rules, but we cannot do anything here: driver can
+ * neither reject such changes (port_bridge_leave() is
+ * void), nor tell tc which one is invalidated.
+ */
+ dp = dsa_to_port(&priv->ds, port);
+ if (!dsa_port_bridge_same(dp, to_dp)) {
+ reason = "Redirect to another bridge";
+ goto fallback;
+ }
+
+ to_pp = &priv->ports[to_dp->index];
+ if ((to_dp->index == port && !pp->hairpin) ||
+ (pp->isolated && to_pp->isolated)) {
+ reason = "Redirect target is isolated";
+ goto fallback;
+ }
+
action[2] |= YT921X_ACL_ACTc_FWD_EN |
YT921X_ACL_ACTc_FWD_REDIR |
YT921X_ACL_ACTc_FWD_REDIR_DPORTn(to_dp->index);
--
2.53.0
reply other threads:[~2026-11-27 14:27 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=20261127142732.1337041-1-mmyangfl@gmail.com \
--to=mmyangfl@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).