From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796523678; b=k2dHt96//TmEAviX66BUGZZTA+DzEX7H2pXI9tPWsYMi7NBOverlvSllWgxPA5ljYid+ 0cDq9HWusK1/mGB8bbUXN2v6B9RTEBYojcOwooERmjJNS7/ZJqBB/dIJDuzVc020pyrxP RTNolTvaDNMzYVkF/+HRsL5TQRN0tXihPKwcSIWy7GupSJpk4Br4s0LLCFbLrNl9VuxW3 M0xNg7IWv5t98cR5bIxQQN7SInaeojYyUStJIBqeozmMfjLwnC/pfJikzNH0u4XJ7Kz/6 8aH2/lHZ4EerzPShkpO9/DEAw7Is4mpyRogcrLN6EIFPRilmd4Fd1RroZeW3yWYi5mw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796523678; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Rn5790dU4vaxlEEcFEyRSXba5cU4ZPMMDWXGDTQX2Gg=; b=PeENEMWLiZwmFOWcNxxeaZwRPYuzfkfpMF6fOYyfx5eGGHOAIwQJCbNsEhw5jP+91jHL LVaXZdZgrrNDH3LE9W+p0Jlx52crHt48RdDOXeYxYoBEeeS6bOXdmLWZJqZ46PwLEVfg5 qfSgvTg4MBmxDMTsGLIfdoX2cHRrW1ltF+wvveBruxAhrNOXSWwiWvOvH9NpSVxCo5N6p 6Dm5UKRrgwe9iPsuxOQPoGijVVMAprrWNTwOfnyblURRydNxLtvv/qIrwjtMI5cp5/MP/ ZnkuI501pCWdnacpTo/PUJ+BUnpPoBqE6SFJG09/iPV3AZEXwy2hXkmiqwhAOtaNNWg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vRsJv5J5; arc=none smtp.remote-ip=209.85.216.52 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 751DE606A333 for ; Sun, 6 Dec 2026 02:21:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 751DE606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=vRsJv5J5 Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-3b501791bb5so1089966a91.1 for ; Sat, 05 Dec 2026 18:21:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796523678; x=1797128478; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Rn5790dU4vaxlEEcFEyRSXba5cU4ZPMMDWXGDTQX2Gg=; b=vRsJv5J5Sh3xPNRTbH12duZg/UCv4hGF8Oz0xF068EP197OAs4a3EtCP0H2e9gXMkT 8coJfBlKGnTMwP2g6YBFs0gJYchQ4F7sqOW9nLzPZH/lG/4qMyIn1hf3HhUqEvMM36tm XAtaf/pCjRZP7Pfxj5pJvSPtvYfNJ4BCjlR4Oh+NNSx2SLyh+EyNWqnVdLu4OkRi54YG YdaohLoCE3zDw+hwG1BzjNPjbqGQ8i91V7p2xWRumyjled/HsilA8cbYGXSBT1qmzqWE jjjqFNKND7Exj6OirUj1pmVhC+SJFidLu3IynyMv8lzEOtA+2+1VZNZ1i9fup29AkRSW vSVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796523678; x=1797128478; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Rn5790dU4vaxlEEcFEyRSXba5cU4ZPMMDWXGDTQX2Gg=; b=ckfHwOBTB3UEZgO5IoDBleyEhNb/3b39mDBY/zjhc5HykKRvGmF3qPTC2V9SHRI/XO iwEPtpvVzPBmBjlMyTceSkPK7GE3KRAiS4bAR/uR/Zc24LDbkaGTalOX0r3uvraIAjXG E2mfWPaZSfx07z426ycM3kI/f109RPWjxDztlrgyIqZ5OtwSikB06LTRT+14cDMC+sUC 8CcRMH18Ahn8rcVUGj7cS4R7IfP8s2MtD9dYspTsk2dRluxL6KnZKokxYB8414Ji5Njw hResOBjBX1APyBYRw8alFjrRHGehVYJUjAn+6gBeJRd4Fih6YVlfPtK4uCJXXK0a+Dvc uTMQ== X-Gm-Message-State: AB4q+uGPqJcY9QUTAOppJvzAk3l0Ei2q4UJGhAEoU7zjJA/tIRFuf+/b +4gRzHymKkf8CK+bpTX+jGmciS5ZzqQmqE+Zz1zhtHfeXkB4IQOAnLFKLCWHVg== X-Gm-Gg: AZFdTZcYGO+9Bq4p0upXhChq8R+bPSj87inUyHaLPNPxJL6xvEkEB20PoLIxYmqnI8u extgSv5l83IVyEohJ8hu2MyByov3gR3OuthuumBEObp3iGkDSIDegjmWY3rnBMAtM2mZSdhq9ge o5vMPTPlhveXT2ynPRAEW32hWpnZ0j2YKL/u0ezlA+AwWEHB6oyUOdKDaPcRFXWFCZX46hNO9bB U2gMSqSrn4GB59ohYk5kqu607KU3wRhVM8t+cOfzDgo7PkH4Sx+3dv2ThGq4hhUe8TykQ4sYqPD L18+HmEJYmtTDkWcEysKhhg3W1do9L9D4M5pZnoL++fN44pLDs7UPdV2DXiTSlaldr+3wj2cx7M +BgWr8zNHxWpBYUe0mP05kBPx9nH5jNhAN6D31Ny3u0Lbtoxc/+OkjISjfYjVClWc/fJlirzU8T PaNcKVQMAqz9EwGVCjSB4ch6V/C+stoBt0Q8jeyHcSd8MPk/PLMld/f4uVtueVUwyoFTR08OQWC Y+z+i9k1wuHRLGbfjt1h/Ym77k3Uk33JpjhTgD9y591+rkf0ioPtpsbQrS6+i5Z6huT5InOg+od M/4cbpLYIDurHzHnvpSfu97OketjtBp0I9MTz/u6n3nSgSmTVX3CesY= X-Received: by 2002:a17:90b:3148:b0:3b5:a01a:2bde with SMTP id 98e67ed59e1d1-3b5e0600522mr5205534a91.20.1796523677827; Sat, 05 Dec 2026 18:21:17 -0800 (PST) Received: from d.home.yangfl.dn42 ([2a09:bac1:76a0:d30::1d0:db]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddc7157dsm10435971a91.15.2026.12.05.18.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 18:21:17 -0800 (PST) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman Subject: [PATCH net-next v5 4/7] net: dsa: motorcomm: Reject isolated redirect targets Date: Sun, 6 Dec 2026 10:20:35 +0800 Message-ID: <20261206022040.4020726-5-mmyangfl@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261206022040.4020726-1-mmyangfl@gmail.com> References: <20261206022040.4020726-1-mmyangfl@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- drivers/net/dsa/motorcomm/chip.c | 9 +++++++++ drivers/net/dsa/motorcomm/chip.h | 2 ++ drivers/net/dsa/motorcomm/tc.c | 34 ++++++++++++++++++++++++++++++-- drivers/net/dsa/motorcomm/tc.h | 6 +++++- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c index b15c1b821087..0fdef7d2c11d 100644 --- a/drivers/net/dsa/motorcomm/chip.c +++ b/drivers/net/dsa/motorcomm/chip.c @@ -1420,6 +1420,15 @@ yt921x_isolation_calc(struct yt921x_priv *priv, u16 *ports_maskp, *ports_maskp = ports_mask; } +u16 yt921x_isolation_calc_port(struct yt921x_priv *priv, int port) +{ + u16 isolation_masks[YT921X_PORT_NUM]; + u16 ports_mask = BIT(port); + + yt921x_isolation_calc(priv, &ports_mask, isolation_masks); + return isolation_masks[port]; +} + static int yt921x_isolation_commit(struct yt921x_priv *priv, u16 ports_mask, const u16 *isolation_masks) diff --git a/drivers/net/dsa/motorcomm/chip.h b/drivers/net/dsa/motorcomm/chip.h index 22381009db51..749fe12fa852 100644 --- a/drivers/net/dsa/motorcomm/chip.h +++ b/drivers/net/dsa/motorcomm/chip.h @@ -559,4 +559,6 @@ static inline u32 ethaddr_lo2_to_u32(const unsigned char *addr) return (addr[4] << 8) | addr[5]; } +u16 yt921x_isolation_calc_port(struct yt921x_priv *priv, int port); + #endif diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c index e3f057ed580f..597a986026d5 100644 --- a/drivers/net/dsa/motorcomm/tc.c +++ b/drivers/net/dsa/motorcomm/tc.c @@ -1041,6 +1041,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 +1074,21 @@ 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 (yt921x_isolation_calc_port(priv, port) & + 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); @@ -1135,6 +1152,7 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext, ~YT921X_ACL_ACTc_FWD_M; action[2] |= YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_TRAP; + ruleext->r.sw_assisting = false; terminal = true; break; } @@ -1301,8 +1319,19 @@ 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