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-next v2 3/5] net: dsa: motorcomm: Reject isolated redirect targets
Date: Sun, 29 Nov 2026 19:55:50 +0800 [thread overview]
Message-ID: <20261129115556.1669188-4-mmyangfl@gmail.com> (raw)
In-Reply-To: <20261129115556.1669188-1-mmyangfl@gmail.com>
Port isolation takes after REDIR judgment, but software delivers such
frames. Either route such rules to the software, or reject offloading.
Fixes: 8eb9e7520b17 ("net: dsa: yt921x: Add ACL support")
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/dsa/motorcomm/tc.c | 34 ++++++++++++++++++++++++++++++++--
drivers/net/dsa/motorcomm/tc.h | 6 +++++-
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c
index e3f057ed580f..20edfd53b230 100644
--- a/drivers/net/dsa/motorcomm/tc.c
+++ b/drivers/net/dsa/motorcomm/tc.c
@@ -1030,6 +1030,7 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
const struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
const struct flow_action *flow_action = &rule->action;
struct netlink_ext_ack *extack = cls->common.extack;
+ struct yt921x_port *pp = &priv->ports[port];
const struct flow_action_entry *act;
u32 *action = ruleext->r.action;
bool seen_priority = false;
@@ -1041,6 +1042,8 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
int res;
memset(action, 0, 3 * sizeof(*action));
+ ruleext->r.sw_assisting = false;
+
flow_action_for_each(i, act, flow_action) {
/* The flow action entry carries no mirred control, so there
* is no way to tell whether software would continue past a
@@ -1072,6 +1075,20 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
goto fallback;
}
+ /* Port isolation takes after REDIR judgment, but
+ * software delivers such frames.
+ */
+ if (pp->isolation_mask & BIT(to_dp->index)) {
+ if (cls->common.skip_sw) {
+ if (to_dp->index == port)
+ reason = "Redirect to self, which is not hairpinning";
+ else
+ reason = "Redirect target isolated, or not in the same bridge";
+ goto fallback;
+ }
+ ruleext->r.sw_assisting = true;
+ }
+
action[2] |= YT921X_ACL_ACTc_FWD_EN |
YT921X_ACL_ACTc_FWD_REDIR |
YT921X_ACL_ACTc_FWD_REDIR_DPORTn(to_dp->index);
@@ -1301,8 +1318,20 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask)
aclrule = aclblk->rules[binid];
/* Write actions */
- res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid),
- aclrule ? aclrule->action : zeros);
+ if (!aclrule || !aclrule->sw_assisting) {
+ res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid),
+ aclrule ? aclrule->action : zeros);
+ } else {
+ u32 action[3];
+
+ memcpy(action, aclrule->action, sizeof(action));
+ action[2] &= ~YT921X_ACL_ACTc_FWD_REDIR_DPORTS_M &
+ ~YT921X_ACL_ACTc_FWD_M;
+ action[2] |= YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_TRAP;
+
+ res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid), action);
+ }
+
if (res)
return res;
@@ -1502,6 +1531,7 @@ yt921x_acl_add(struct yt921x_priv *priv,
~YT921X_ACL_ACTc_FWD_M;
aclrule->action[2] |= YT921X_ACL_ACTc_FWD_EN |
YT921X_ACL_ACTc_FWD_TRAP;
+ aclrule->sw_assisting = false;
}
if (meterid < YT921X_METER_NUM)
aclrule->action[0] |= YT921X_ACL_ACTa_METER_ID(meterid);
diff --git a/drivers/net/dsa/motorcomm/tc.h b/drivers/net/dsa/motorcomm/tc.h
index cc53f148d690..81c29a8eec5a 100644
--- a/drivers/net/dsa/motorcomm/tc.h
+++ b/drivers/net/dsa/motorcomm/tc.h
@@ -349,7 +349,11 @@ struct yt921x_acl_rule {
enum tc_setup_type type;
u32 action[3];
- bool sw_assisted;
+ bool sw_assisted:1;
+ /* not a TRAP rule, but installed as trapped as some conditions are not
+ * met
+ */
+ bool sw_assisting:1;
u8 mask;
struct yt921x_acl_entry entries[YT921X_ACL_ENT_PER_BLK];
--
2.53.0
next prev parent reply other threads:[~2026-11-29 11:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 11:55 [PATCH net-next v2 0/5] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-11-29 11:55 ` [PATCH net-next v2 1/5] net: dsa: motorcomm: Remove local cpu_ports_mask David Yang
2026-11-29 11:55 ` [PATCH net-next v2 2/5] net: dsa: motorcomm: Cache port isolation masks David Yang
2026-11-29 11:55 ` David Yang [this message]
2026-11-29 11:55 ` [PATCH net-next v2 4/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes David Yang
2026-11-29 11:55 ` [PATCH net-next v2 5/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules David Yang
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=20261129115556.1669188-4-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