From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Thu, 3 Dec 2026 11:15:43 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 458FA1F0092F; Thu, 3 Dec 2026 11:15:43 +0000 (UTC) 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== Subject: Re: [PATCH net-next v3 4/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules From: netdev-bot+sashiko@kernel.org To: mmyangfl@gmail.com Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com Date: Thu, 03 Dec 2026 11:15:42 +0000 Message-ID: <179629654283.3146.1293591640887633845@kernel.org> In-Reply-To: <20261201081459.2104904-5-mmyangfl@gmail.com> References: <20261201081459.2104904-5-mmyangfl@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 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