Article View: linux.kernel.netdev
Article #26295Re: [PATCH net-next v3 4/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 11:15
Date: Thu, 03 Dec 2026 11:15
120 lines
12616 bytes
12616 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In yt921x_dsa_port_pre_bridge_flags()
(drivers/net/dsa/motorcomm/chip.c), the new per-port vetoes run before…
--
net: dsa: motorcomm: Reject bridge flags that break redirect rules
This commit adds a per-port acl_dst_cnts[] counter. yt921x_acl_add() and
yt921x_acl_del() update it for redirect rules that are not sw_assisted.
yt921x_dsa_port_pre_bridge_flags() then uses the counters to reject turning
off hairpin mode or turning on isolation when such rules would be blocked.
> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 6c6a87207bd5c..0bc5da2b80d7a 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -1448,6 +1448,37 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port,
> BR_MCAST_FLOOD | BR_ISOLATED))
> return -EINVAL;
>
> + if ((flags.mask & BR_HAIRPIN_MODE) && !(flags.val & BR_HAIRPIN_MODE) &&
> + pp->acl_dst_cnts[port]) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Cannot disable hairpin mode while there are hairpin redirect rules installed");
> + return -EINVAL;
> + }
> +
> + if ((flags.mask & BR_ISOLATED) && (flags.val & BR_ISOLATED)) {
[ ... ]
> + ports_mask = dsa_bridge_ports(ds, bdev);
> + for_each_set_bit(i, &ports_mask, YT921X_PORT_NUM) {
> + if (i == port || !priv->ports[i].isolated)
> + continue;
> +
> + if (pp->acl_dst_cnts[i] ||
> + priv->ports[i].acl_dst_cnts[port]) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Cannot isolate port while there are redirect rules installed");
> + return -EINVAL;
> + }
> + }
> + }
> +
> if ((flags.mask & BR_HAIRPIN_MODE) || (flags.mask & BR_ISOLATED)) {
> struct dsa_port *dp = dsa_to_port(ds, port);
> struct net_device *bdev;
[Severity: Medium]
Can these new per-port checks leave driver state half updated when the
bridge port is an offloaded LAG?
Right after these checks, the prepare phase already changes driver state:
if (flags.mask & BR_HAIRPIN_MODE)
pp->hairpin = flags.val & BR_HAIRPIN_MODE;
if (flags.mask & BR_ISOLATED)
pp->isolated = flags.val & BR_ISOLATED;
...
yt921x_isolation_calc_bridge(priv, ports_mask);
Take bond0 with lowers swpA and swpB on this switch. The bridge sends one
PRE_BRIDGE_FLAGS notification, and switchdev calls the driver once per
lower:
br_setport()
br_switchdev_set_port_flag()
__switchdev_handle_port_attr_set() /* loops over lowers */
dsa_user_port_attr_set()
dsa_port_pre_bridge_flags()
yt921x_dsa_port_pre_bridge_flags()
__switchdev_handle_port_attr_set() returns on the first hard error. It does
not undo the lowers that already succeeded.
Suppose swpA has no conflicting rules. Its call passes, sets pp->hairpin or
pp->isolated, and rewrites isolation_mask for every bridge member through
yt921x_isolation_calc_bridge().
Then suppose swpB fails one of the new acl_dst_cnts[] checks. br_setport()
returns the error, the bridge keeps its old flags, and the deferred
PORT_BRIDGE_FLAGS is never sent.
Nothing appears to roll back swpA's hairpin/isolated state or the cached
isolation_mask values. The next yt921x_isolation_commit() would write those
stale masks to hardware. That happens on a later successful hairpin or
isolated change, or on a bridge_join. Frames would then be dropped even
though the bridge configuration allows them.
The stale masks are also used by the tc parse path and by
yt921x_acl_recompute_rule(). The isolation check above also reads the stale
priv->ports[i].isolated, so isolation changes on other ports could be
rejected wrongly.
Retrying the same flag change would not fix it. The bridge sees no change in
its flags, so it never calls the driver.
Before this patch, the only failure in this function was the unsupported-flag
mask check. That check gives the same result for every lower, so it failed
on the first lower before any state changed.
The later patch in this series, "net: dsa: motorcomm: Recompute redirect
rules on bridge changes", does not touch pre_bridge_flags. Does this problem
still exist at the end of the series?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201081459.2104904-1-mmyangfl%40gmail.com
Technical Details
Message-ID:
<179629654283.3146.1293591640887633845@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376511-linux-kernel-netdev=dewy.ruReferences:
<20261201081459.2104904-5-mmyangfl@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376511-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v3 4/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules Date: Thu, 03 Dec 2026 11:15:42 +0000 Organization: Usenet Network Message-ID: <179629654283.3146.1293591640887633845@kernel.org> References: <20261201081459.2104904-5-mmyangfl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2470032"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:vDtU3dhvcNTErwzeLHwefivh6Ws= sha256:ekOB94rVaei5wwjqhiJ9vdYJeyAC/jw4ZF2im37wTSU= sha1:SHU0fbwAk0fo04ESDwFH3keii8c= sha256:tSBNaGx4BjT9E+MAWHoGp4dqaysdhqaa+vwe0td1ULs= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 66FDA1178A8; Thu, 3 Dec 2026 14:16:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.64 X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6CzLkQ6qNGHz; Thu, 3 Dec 2026 14:16:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376511-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 1F2D61178E8; Thu, 3 Dec 2026 14:15:52 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 6EE7F2214E; Thu, 3 Dec 2026 11:15:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796296545; b=NoGPVnxRGRDoHucrc4bGhkPHd8qh4Vt4NyzE+FmSVm88MJRPvn5fPrN4f3sDsf4vEyP/ UgrCO8rm9GrD1qGqq8y5BYavZIGBxpyOSDnip9wLniV2mz1th8nVbMa+9Wh0RtFbqaLeb pVQF+YromU8wcjXzULGadUlYUaYAh9hPHoz66sSW21CMHoq5F6z+rk7HhOMOyyqzfAJBJ 2797QuBQnT12dJgordJn3wUxYXIsIzZniBj1RxeyVjGhT9l1UzN9nviUC4xgNJiihJTjQ pwUyktH0oIR+E1LEPwAY4WhZl+cWvCmY/XY7bkLspwh2BpgT6qlWi3LCzdO6hBtG9NA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296545; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=8sBK+2Q82MHvYqiWkN0AXqrNqXvYDT57Yoxz5T0j7es=; b=DhQD9BNYGdnLVslylsJ6QJ8gYpYWip2aiBVgLdjqsgo0jIbKi74Q4O/v1SaS5LTXcjj+ YX3OzaKZz4DDaBhRel/jr6tXjAx18VZ4keeDaXZupDhzsECf1XPausZnzL8sePYeEJJTF IBG0OKBI7RyonlzmPvJsHDQrjGr/v+pF1FK7wqda45/KVlhZYREj5hVtB24qmmy/mMC0+ 3OJ6nH7FdoopR59hDYxxuIz9I/xsut0ngOmrsUp620iuaWafhbvgnqH66C45IzfzFY3ie F9Gkx7sU5SPLX28BkHMZIpuBzXwOSPRskSELoNuipllOxkHpKskyhZ58QJQxyZQBCDw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j7GGmSVJ; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F40BD606A6AF; Thu, 3 Dec 2026 11:15:44 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j7GGmSVJ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796296544; b=o+qKmCFIiU6j9z8cqUq3PkAVNoObNtyxd3/MBh9M549qEUeaA9rcAvda5w9oYHGthOFX qKm6oq0Ra+Azl0apqsFumazYYWv2EpFyMCJHZSBsh4R7rM0DmMKxZ/k4FxY3FRqogwva0 x+alawYfuaR2ITJTKoCiB0IasazGkDeQ3j3ZAb3CmIsUSLuTzooTBED57q49MQYeo7hSF +Bmh1NJjcVV7XYHWWScBMfu4Xb0Nz9Es35UI+aYiBMsTgEH1ABZzkSi4xJEO15SwbSCcA aE7AFI4FGfjesvoRiWIUjZZupPyATcXFIPSYRA/duYviGf4IqsBgfVunsSW+/X7OSqw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296544; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=8sBK+2Q82MHvYqiWkN0AXqrNqXvYDT57Yoxz5T0j7es=; b=jKaug4i9PWBLq1ddSJMNqX8iN60g1VEeKg0Ucc1i6E7fHuRU3wyDv/uEF+xs/Wdto1WT dE7oDmzGDPdFsNW/cTSMcRPTq1S2Veqeh/1B9sG4X3TphHrONhWP7gQmB1ItBHxJJj0ER iaedXkXLV959PDWWfq06pC2DAzYT+SfIFyrbK4sizzutZP95ajvjbpUTwN+8Q1ZNQOoeZ flPfC+kjxSLBfzy0ODrJByF/QvsQVBJ/hsP5HqRWFUfp/10aZh2MuTo9QPRwi0t5at7l/ lJ3NO4zxPq9x2+pbFr/gbSzp5zT4BhqV81z9N4rHpr7BinKLNKsYccIEzSdG9k/ZF4w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=j7GGmSVJ; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21A8A606A6A4 for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 11:15:43 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 458FA1F0092F; Thu, 3 Dec 2026 11:15:43 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796296543; bh=8sBK+2Q82MHvYqiWkN0AXqrNqXvYDT57Yoxz5T0j7es=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=j7GGmSVJ3vu+8ESua6fFeLA5JxMKd/DJ+jcgvtaqcgCwhgyrtYwgBLGlHhJEuOga+ qDuXVBSd5fxNmbHy6169xfuaSlMDJ9KowB2liJN6YvBMlkbzmmBErT+nk/ccoejel9 XFB7hVjUWjpLlm6UY2f5/oAupTCyjq6zP6WBonermbriGW64GUNcGEYdACXmlgHosL /NSIhtyQ/NxyNWNtqJfg8w4oZajP9b7+AO00zLdtcC7u1kBbQB3FWZfUZd0qmt4MAP 0CC9bvpibxRGJfcVlV+QhLRmdPFDR3F1iDUYJu3NUUfzBSUi+3YZaIZYTpisFhJMm8 dhDJOIvMus8hw== X-Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com X-In-Reply-To: <20261201081459.2104904-5-mmyangfl@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list