From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796529320; b=0DSojhyQmi75U/NijKIlR/dj1orbxHiQNtnKrF0YfSzu8aqJ1N1vZFJA9+GM//HfFonB qTpRUk3WXubJygsO53noTTAVgmiEv0BsQl0YiAQghhQFb32ArLFChIUGRB3MACWbJVdjL 9Ssvcx5E83eVCJJDw0C37JN/PqzfgS0Gj2KR75rYZux/5ER/2zYCjo68jOmA9XUY1gez3 09pySamcU7KDSClQOTUH2H5ddV5DL3pS2udBWLhSsd+AdxFoIwfaBCtqUzZQvoPf6lKKq NQrqs/KZBuUX3Qesxjjw04MU+rTNYou+JRPbC4LTcBl+RcP+JMKQ2GF+QMhPsCbKMqg== 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=pXqD5Lo7HynprSEhthu4wXT8ADV1jsolasFu3HiEIfKd9zILI/UnNLx7lJkFrF+YHw6m sAPlN/8CY8s0YUTKH+kjkinXDi9JNytmt9HuD1ANyvjwDa9eUYkU+2iOKNwN9ImC1pUbf mvSZYTGfdLjdtpnUKixyYWK/QSl8HkW1wB7o57AXEntHv8lT9ifDFFdq43nTIXHSJxWrf MERM7RxwZ+Toio02rQMZZMd4CoxyBnvL7TR+5mXqUPkkY+rDE+R4K4nfr4JKJcGKBsN/0 OVS3DhRvG6sUvXLgNTanPhfV81I+mkj1c/DENNyTUTiLkVB90ZWH/wj0Cv0Grp0/BvQ== 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.197 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (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 D1C09606A31F for ; Sun, 6 Dec 2026 03:55:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D1C09606A31F 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-f197.google.com with SMTP id d75a77b69052e-5363b06bcb2so37445221cf.2 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=Wi5f5VeQZbtOMo9ckObstOO4IZdXoFG89TxkxgoFIMHFC193m+gaEMhmg3+rgfRZnx wztw6Mae/2aB5GtG+2Ri0Mg73D6dHJKzzMaD5KVzVXI30FshgYCoe6fsmM0+4D7uzFI7 nrfdbm6yortFkG3MI4yD5FRls8W7wBcbpYwBQnn0+AIKgrLXk9EAffUrjj0GGaLt8DUx //y4IGI5HP3xxpTyAhE+ZdfyIvKcSk9iddaS28RD0fqo0SaX3iEeIdVLheojP5vs43dz EyiRXlkeCYI7bAfacHm82N5TOOcD8FPoDHCJEPTdvpd3V2JQz0QqmUCXsOWNpXzCNoZj 3f0Q== X-Forwarded-Encrypted: i=1; AL+hErEOaxV9UL2cKCCfW7iy0kJAxqQJXgsQBUo5ha24FZZ6b+tjoExJV8X3OyhU65oZmCIY0FsCx64=@vger.kernel.org X-Gm-Message-State: APuU4Z/dKjz1oIA+MkTDuBQV3GNQ2LrX2C3QaxPHPVCI/8ZEjJJYL4Tb 9hszHkaGJt8RBcEq6N2G6tN4ODoD3h6zstnyHQfveL6dYVRf1H3THy6LqMmCzRWrY5XpK0S6JER wRqn3kHe9UQ== 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: netdev@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.