From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796529320; b=Ol/QdLvPx91GNK82gcdsN0KqJ+iuLS+4NNhVVIk6hMrHigGvvh/OB9yZPe82Xnyujenk HJbb0L0t7Nu3658vC5hISAClnD3u5IDajK7D8WQ4Zu7yiJO0yItpRD5+EGaf7JP5nt6WH TJyDYLmTQT+DBM9eHJO8o3DSoBMr20d+OaB0XgvE4+lohW7CDtbY3CESOlZjQ1L3TtBEZ WdzXU+6OU6No/nKKT1NaAOx5jaW5PdyxKqEzINDg6ElIkcvIUkAOnz5+dpJvHRvUsBfB6 wlsvcruUqJLBjXJirsLYuYRwevultxUFIPOYVIrYowiROcz38qfsAgCeUlr6/yTKc8w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796529320; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=hc+e8ibP2ASqMJHhXdcTSlj3qHPQ4e2NKKu4f8CQWso=; b=sc67aOhqnNDwZT/fQAemPnH6/uEfCiWe7kEDRxEzFC2fi0igN1uEryE759n2jtiJcyhk TT+ViwLgjmHgeZh+7KID0N8OAzd2ANXUnLm5bML15gur0QV8P4ZiBUystTDlaJ7yyN0fm jxVAVJiyNUFDfTTzyjMRs8uTzWqoc6a8KoqhEI3ANIDB7jos+Wgfdb5IR12+xfneGhGF8 W8B+Wyznbm5rvT1tkQM8fs7KH7Hi9KTCWt3utbxiAZN1qUjBsPWsKDZEiOlVnZaYj7hzX fclGnStTSLLfFhECvfZbcKBq29prDs2eiPU+SQxYpm1uwd7YO8+QnP0RkgK+EOLfdzQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Ncrq+o0k; arc=none smtp.remote-ip=209.85.160.199 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (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 0346E606A321 for ; Sun, 6 Dec 2026 03:55:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0346E606A321 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Ncrq+o0k Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-544019b1831so40732111cf.0 for ; Sat, 05 Dec 2026 19:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796529319; x=1797134119; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hc+e8ibP2ASqMJHhXdcTSlj3qHPQ4e2NKKu4f8CQWso=; b=Ncrq+o0kwsA7NtHfgBjPZejR7A6/F+RBX2RYtKOtolNimJo0whdqpPOE89huYr6Hw3 sNSVhSF0ZBltxjhWNvawsB3gk3T0mEvC+zxCP/BcfeLFM6FfXBimtl0s+9P8JnbmdIBR 6VoCCvaLcR89WXfubHhBHwMFfhZnVynxekHXH3Pydm1dAFj1K0fTTO1Mc7GUtD7QP7uz b0uEWpaWdje4geAcc+mlO3Ca8gjmFb8PFqJGEvdedYJtn+x3ZVKE510QCYq8I9x6JPBc nlORV7HpQM4qKj0ZmFB+hYcWAHPMUgQiXq16kT6R9H/quA1M7TPuUZ5J7C4RUgpWOufz W0hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796529319; x=1797134119; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hc+e8ibP2ASqMJHhXdcTSlj3qHPQ4e2NKKu4f8CQWso=; b=hOX1Xv/4n2CJ4YcJ1TP9WvFk3/pPfSKEFMQ0ydvaRkaUbesKgH5uReDLWD0Ng5af/7 J4ldsYuHl7tB58RYRIaW4Yhd9jivkab+ksTNse9Ksy4QYaynXtkkGlpYZJupIZhCB8uk RG4OW20DVo6hvc4YdRVy5o0AKtIW70lZEGMyYD8UfpQ+5H4CFAz3fsDW3pmpnA5rd/cW Pb+L3C6EDcKesD4ynHEQ+wJzjdC+ulvlx6bsU6S01G3q2VXU1ljSiDV2lNmptRUQ95Dm hCs1CN+Nz5IwQS0fLUtfsPdse3soHoxRmGB6ONES0IrqOy05yEzuMYSyZUD0HSzBAbJ1 2Lbg== X-Forwarded-Encrypted: i=1; AL+hErHrhc4rHLcac78gZ2DV2cgYNq5baAUncJkBgViLE77IGW+nuzSKUnHr6y+0M4H//k4QZYc8SjTc7A7qnIE=@vger.kernel.org X-Gm-Message-State: APuU4Z8o9i/QUdA5xT4lJgleiZMf4WKapAN/jXMuRb10byqHxkwoe+CS Z7xlJ/znzU1LI0ggMnM2LAhcjs7sdgM8azXUrD1lNWEkvAAGXQz9IeAlSDPBipGs/HOuE97hDSD 4O7D/8MzIJw== X-Received: from qtzz17-n1.prod.google.com ([2002:a05:622a:ab11:10b0:55e:2e27:f6b8]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:5448:b0:55b:df9e:369a with SMTP id d75a77b69052e-55e3859885dmr100642341cf.11.1796529318731; Sat, 05 Dec 2026 19:55:18 -0800 (PST) Date: Sat, 05 Dec 2026 22:55:18 -0500 In-Reply-To: <20261128165206.3248835-4-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261128165206.3248835-1-julius@bairaktaris.de> <20261128165206.3248835-4-julius@bairaktaris.de> Message-ID: Subject: Re: [PATCH net 3/6] net: dsa: tag_dsa: send a marked frame of an unbridged port from the CPU From: willemb@google.com To: Julius Bairaktaris , Andrew Lunn , Vladimir Oltean , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , "=?UTF-8?B?QWx2aW4gxaBpcHJhZ2E=?=" , Linus Walleij , Florian Fainelli , Pawel Dembicki , Tobias Waldekranz , Daniel Golle , Russell King , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Julius Bairaktaris wrote: > dsa_xmit_ll() sends a frame with offload_fwd_mark as a FORWARD frame on > behalf of the port's bridge, with the bridge number taken from > dsa_port_bridge_num_get(). The port need not be in a bridge: a frame > received on a bridged port keeps the mark through a tc mirred redirect > or an nft netdev fwd to a standalone port of the same switch, and a > frame that the bridge marked can still be queued for a port that has > left the bridge. The bridge number is 0 then, and the frame goes out as > FORWARD from device dst->last_switch, port 0, instead of FROM_CPU to the > port. The function also reads dp->bridge twice, once for the number and > once for the device. > Read dp->bridge once, and send FORWARD only while the port is in a > bridge; otherwise the frame goes FROM_CPU to the port, as a frame > without the mark does. > Found by an LLM review (Claude), and reproduced in QEMU with dsa_loop. > Fixes: d82f8ab0d874 ("net: dsa: tag_dsa: offload the bridge forwarding > process") > Signed-off-by: Julius Bairaktaris net/dsa/tag_dsa.c:143 (dsa_xmit_ll): The new guard `if (skb->offload_fwd_mark && bridge)` only verifies that the egress port belongs to a bridge; it fails to check bridge->tx_fwd_offload (or bridge->num != 0). In drivers/net/dsa/mv88e6xxx/chip.c:4008-4010 and 3071-3077, mv88e6xxx_setup() only sets ds->max_num_bridges and mv88e6xxx_port_bridge_join() only sets *tx_fwd_offload = true when mv88e6xxx_has_pvt(chip) is true. On all 7 non-PVT mv88e6xxx chips (MV88E6020, MV88E6071, MV88E6095, MV88E6131, MV88E6185, MV88E6220, MV88E6250), a bridged port has dp->bridge != NULL with bridge->num == 0 and bridge->tx_fwd_offload == false. Under the exact same tc mirred / nft netdev fwd redirect from any bridged ingress port (where dsa_default_offload_fwd_mark() sets skb->offload_fwd_mark = 1), dsa_xmit_ll() STILL takes the DSA_CMD_FORWARD branch and sets tag_dev = dst->last_switch + 0 (dst->last_switch), tag_port = 0, impersonating physical switch dst->last_switch port 0. Additionally, during dsa_port_bridge_join() on PVT chips, dp->bridge is published before mv88e6xxx_map_virtual_bridge_to_pvt() sets dp->bridge->tx_fwd_offload = true. dsa_xmit_ll() must check bridge && READ_ONCE(bridge->tx_fwd_offload) (and bridge->num != 0, with WRITE_ONCE() in dsa_port_bridge_join()). net/dsa/tag_dsa.c:139-143 (dsa_xmit_ll): skb->offload_fwd_mark carries no bridge/hwdom identity and is overloaded between RX ("already hardware-forwarded in ingress hwdom") and TX ("bridge requests TX forwarding offload"). Neither tcf_mirred_to_dev() (net/sched/act_mirred.c:254-335) nor nf_do_netdev_egress() (net/netfilter/nf_dup_netdev.c:17-41) clears skb->offload_fwd_mark when redirecting/mirroring to egress. Consequently, redirecting an RX frame from a bridged port on br0 (or any other switchdev NIC) to a bridged port on br1 causes dsa_xmit_ll() to transmit DSA_CMD_FORWARD on behalf of br1 (flooding and learning SA on br1) instead of DSA_CMD_FROM_CPU to the target port. Clearing skb->offload_fwd_mark on egress redirect (while keeping tagger RCU and tx_fwd_offload checks for concurrent bridge leave) fixes the root cause rather than only standalone targets.