net: dsa: motorcomm: ACL fixup
David Yang
maintainerv4 cover net: dsa: motorcomm: ACL fixup
Various ACL defects. Found by LLM and manually verified (on YT9215).
v4:
- reject action following redirect action
v3: https://lore.kernel.org/r/[email protected]
- also unset reason initializer
- fix action resolver again
v2: https://lore.kernel.org/r/[email protected]
- withdraw patch 2 as it needs another test run on the device
- fix patch 3 to align with software behavior
v1: https://lore.kernel.org/r/[email protected]
David Yang (3):
net: dsa: motorcomm: Fix extack message on unsupported TC actions
net: dsa: motorcomm: Resolve the flower action list to one ACL verdict
net: dsa: motorcomm: Delete the ACL rule of the port being unbound
drivers/net/dsa/motorcomm/tc.c | 88 ++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 41 deletions(-)
Signature · 1 line
2.53.0
David Yang
maintainerPATCH v4 1/3 net: dsa: motorcomm: Fix extack message on unsupported TC actions
No extack reasons were given to unsupported TC actions. Set a reason on the default path before falling back, and drop the now-redundant initializer of reason, so the compiler warns on any future path that uses it without assigning one.
--- drivers/net/dsa/motorcomm/tc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/motorcomm/tc.c +2 -1
@@ -1034,8 +1034,8 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,const struct flow_action_entry *act;u32 *action = ruleext->r.action;bool seen_priority = false; -const char *reason =NULL ;bool seen_police = false; +const char *reason;unsigned int i;int res;
@@ -1122,6 +1122,7 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,break ; }default : + reason ="Unsupported by HW" ; fallback:if (cls->common.skip_sw) { NL_SET_ERR_MSG_FMT_MOD(extack,
Signature · 1 line
2.53.0
David Yang
maintainerPATCH v4 2/3 net: dsa: motorcomm: Resolve the flower action list to one ACL verdict
In reply to David YangThe hardware resolves one forward decision per ACL rule, but the translation accumulated every action, so a later action silently changed the verdict of the ones before it: an action drop action trap filter with skip_sw trapped packets to the CPU instead of dropping them.
Resolve the list against its first terminal action, and ask for software assistance if any action follows the redirect action.
--- drivers/net/dsa/motorcomm/tc.c | 72 +++++++++++++++++----------------- 1 file changed, 37 insertions(+), 35 deletions(-)
drivers/net/dsa/motorcomm/tc.c +37 -35
@@ -1030,55 +1030,54 @@ 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; -enum flow_action_id redir_act =NUM_FLOW_ACTIONS ;const struct flow_action_entry *act;u32 *action = ruleext->r.action;bool seen_priority = false;bool seen_police = false; +bool terminal = false; +bool redir = false;const char *reason;unsigned int i;int res;memset (action,0 ,3 *sizeof (*action)); -flow_action_for_each (i, act, flow_action) +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 +* redirect and apply the actions after it. Leave the list to +* software instead of guessing a hardware verdict. +*/ +if (redir) { + reason ="Action after redirect" ; + goto fallback; + } +switch (act->id) {case FLOW_ACTION_ACCEPT : + action[2 ] |= YT921X_ACL_ACTc_FWD_EN | + YT921X_ACL_ACTc_FWD_FWD; + terminal = true; +break ;case FLOW_ACTION_DROP : -case FLOW_ACTION_REDIRECT : -if (redir_act !=NUM_FLOW_ACTIONS && - redir_act != act->id) { - reason ="Different redirect actions" ; + action[2 ] |= YT921X_ACL_ACTc_FWD_EN | + YT921X_ACL_ACTc_FWD_REDIR; + terminal = true; +break ; +case FLOW_ACTION_REDIRECT : { +struct dsa_port *to_dp; + + to_dp =dsa_port_from_netdev (act->dev); +if (IS_ERR (to_dp) || to_dp->ds != &priv->ds) { + reason ="Redirect to non-local port" ; goto fallback; } - redir_act = act->id; - -switch (act->id) { -case FLOW_ACTION_ACCEPT : - action[2 ] |= YT921X_ACL_ACTc_FWD_EN | - YT921X_ACL_ACTc_FWD_FWD; -break ; -case FLOW_ACTION_DROP : - action[2 ] |= YT921X_ACL_ACTc_FWD_EN | - YT921X_ACL_ACTc_FWD_REDIR; -break ; -case FLOW_ACTION_REDIRECT : { -struct dsa_port *to_dp; - to_dp =dsa_port_from_netdev (act->dev); -if (IS_ERR (to_dp) || to_dp->ds != &priv->ds) { - reason ="Redirect to non-local port" ; - goto fallback; - } - - action[2 ] |= YT921X_ACL_ACTc_FWD_EN | - YT921X_ACL_ACTc_FWD_REDIR | -YT921X_ACL_ACTc_FWD_REDIR_DPORTn (to_dp->index); -break ; - } -default : -break ; - } + action[2 ] |= YT921X_ACL_ACTc_FWD_EN | + YT921X_ACL_ACTc_FWD_REDIR | +YT921X_ACL_ACTc_FWD_REDIR_DPORTn (to_dp->index); + redir = true;break ; + }case FLOW_ACTION_PRIORITY :if (seen_priority) { action[0 ] &= ~YT921X_ACL_ACTa_PRIO_EN;
@@ -1132,15 +1131,18 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext, } fallthrough;case FLOW_ACTION_TRAP : - redir_act =FLOW_ACTION_TRAP ; - 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; + terminal = true;break ; } +if (terminal) +break ; + } + ruleext->r.sw_assisted = !cls->common.skip_sw;return 0 ; }
Signature · 1 line
2.53.0
David Yang
maintainerPATCH v4 3/3 net: dsa: motorcomm: Delete the ACL rule of the port being unbound
In reply to David YangA flower filter on a block shared across ports is offloaded as one hardware rule per port, all carrying the same classifier cookie. Deletion looked a rule up by cookie alone and could take another port's copy: with skip_sw, a filter silently stopped being enforced on a still-bound port, while the detached port kept enforcing it.
Delete the rule matching the port being unbound instead.
--- drivers/net/dsa/motorcomm/tc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/dsa/motorcomm/tc.c +8 -5
@@ -1226,7 +1226,7 @@ static u16 yt921x_acl_activated_ports(const struct yt921x_priv *priv)static unsigned int yt921x_acl_find (const struct yt921x_priv *priv,enum tc_setup_type type, -unsigned long tag) +unsigned long tag,u16 ports_mask) {for (unsigned int blkid =0 ; blkid <YT921X_ACL_BLK_NUM ; blkid++) {const struct yt921x_acl_blk *aclblk = priv->acl_blks[blkid];
@@ -1236,7 +1236,10 @@ yt921x_acl_find(const struct yt921x_priv *priv, enum tc_setup_type type,for (unsigned int i =0 ; i <YT921X_ACL_ENT_PER_BLK ; i++)if (aclblk->rules[i] && aclblk->rules[i]->tag == tag && - aclblk->rules[i]->type == type) + aclblk->rules[i]->type == type && +FIELD_GET (YT921X_ACL_KEYb_SPORTS_M, + aclblk->rules[i]->entries[0 ].key[1 ]) == + ports_mask)return YT921X_ACL_ENT_PER_BLK * blkid + i; }
@@ -1364,7 +1367,7 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask)static int yt921x_acl_del (struct yt921x_priv *priv,enum tc_setup_type type, -unsigned long tag) +unsigned long tag,u16 ports_mask) {struct yt921x_acl_rule *aclrule;struct yt921x_acl_blk *aclblk;
@@ -1378,7 +1381,7 @@ yt921x_acl_del(struct yt921x_priv *priv, enum tc_setup_type type,int res;int ret; - entid =yt921x_acl_find (priv, type, tag); + entid =yt921x_acl_find (priv, type, tag, ports_mask);if (entid ==UINT_MAX )return -ENOENT ;
@@ -1553,7 +1556,7 @@ yt921x_dsa_cls_flower_del(struct dsa_switch *ds, int port,int res;mutex_lock (&priv->reg_lock); - res =yt921x_acl_del (priv,TC_SETUP_CLSFLOWER , cls->cookie); + res =yt921x_acl_del (priv,TC_SETUP_CLSFLOWER , cls->cookie,BIT (port));mutex_unlock (&priv->reg_lock);return res;
Signature · 1 line
2.53.0
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 12 lines · On Tue, 10 Nov 2026 18:48:52 +0800 you wrote:
Various ACL defects. Found by LLM and manually verified (on YT9215).
v4:
- reject action following redirect action
v3: https://lore.kernel.org/r/[email protected]
- also unsetreasoninitializer
- fix action resolver again
v2: https://lore.kernel.org/r/[email protected]
- withdraw patch 2 as it needs another test run on the device
- fix patch 3 to align with software behavior
v1: https://lore.kernel.org/r/[email protected]
Quoted 1 line
[...]
Here is the summary with links:
- [net,v4,1/3] net: dsa: motorcomm: Fix extack message on unsupported TC actions
https://git.kernel.org/netdev/net/c/7adbc7112dd7 - [net,v4,2/3] net: dsa: motorcomm: Resolve the flower action list to one ACL verdict https://git.kernel.org/netdev/net/c/96a4b015fe66 - [net,v4,3/3] net: dsa: motorcomm: Delete the ACL rule of the port being unbound https://git.kernel.org/netdev/net/c/4e80af24f9f3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html