netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Petr Machata <petrm@nvidia.com>, Ido Schimmel <idosch@nvidia.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>,
	bridge@lists.linux.dev, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-6.1] net: bridge: Install FDB for bridge MAC on VLAN 0
Date: Sat, 25 Oct 2025 11:56:30 -0400	[thread overview]
Message-ID: <20251025160905.3857885-159-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>

From: Petr Machata <petrm@nvidia.com>

[ Upstream commit cd9a9562b2559973aa1b68c3af63021a2c5fd022 ]

Currently, after the bridge is created, the FDB does not hold an FDB entry
for the bridge MAC on VLAN 0:

 # ip link add name br up type bridge
 # ip -br link show dev br
 br               UNKNOWN        92:19:8c:4e:01:ed <BROADCAST,MULTICAST,UP,LOWER_UP>
 # bridge fdb show | grep 92:19:8c:4e:01:ed
 92:19:8c:4e:01:ed dev br vlan 1 master br permanent

Later when the bridge MAC is changed, or in fact when the address is given
during netdevice creation, the entry appears:

 # ip link add name br up address 00:11:22:33:44:55 type bridge
 # bridge fdb show | grep 00:11:22:33:44:55
 00:11:22:33:44:55 dev br vlan 1 master br permanent
 00:11:22:33:44:55 dev br master br permanent

However when the bridge address is set by the user to the current bridge
address before the first port is enslaved, none of the address handlers
gets invoked, because the address is not actually changed. The address is
however marked as NET_ADDR_SET. Then when a port is enslaved, the address
is not changed, because it is NET_ADDR_SET. Thus the VLAN 0 entry is not
added, and it has not been added previously either:

 # ip link add name br up type bridge
 # ip -br link show dev br
 br               UNKNOWN        7e:f0:a8:1a:be:c2 <BROADCAST,MULTICAST,UP,LOWER_UP>
 # ip link set dev br addr 7e:f0:a8:1a:be:c2
 # ip link add name v up type veth
 # ip link set dev v master br
 # ip -br link show dev br
 br               UNKNOWN        7e:f0:a8:1a:be:c2 <BROADCAST,MULTICAST,UP,LOWER_UP>
 # bridge fdb | grep 7e:f0:a8:1a:be:c2
 7e:f0:a8:1a:be:c2 dev br vlan 1 master br permanent

Then when the bridge MAC is used as DMAC, and br_handle_frame_finish()
looks up an FDB entry with VLAN=0, it doesn't find any, and floods the
traffic instead of passing it up.

Fix this by simply adding the VLAN 0 FDB entry for the bridge itself always
on netdevice creation. This also makes the behavior consistent with how
ports are treated: ports always have an FDB entry for each member VLAN as
well as VLAN 0.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/415202b2d1b9b0899479a502bbe2ba188678f192.1758550408.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

YES
- `net/bridge/br.c:39-55` now invokes `br_fdb_change_mac_address(br,
  dev->dev_addr)` during the bridge master’s `NETDEV_REGISTER` notifier,
  immediately installing the bridge’s own MAC into the FDB for VLAN 0.
  Without this early call, a user who sets the bridge MAC to its current
  value before enslaving any port leaves `addr_assign_type` at
  `NET_ADDR_SET`, so later events never repopulate the missing VLAN‑0
  entry.
- When that entry is absent, `br_handle_frame_finish()`
  (`net/bridge/br_input.c:204-235`) fails to resolve a local destination
  for frames addressed to the bridge on VLAN 0, falls into the
  `br_flood()` path, and never calls `br_pass_frame_up()`, so traffic to
  the bridge itself is effectively dropped in exactly the scenario
  described.
- The added call simply reuses the existing, well-tested helper in
  `net/bridge/br_fdb.c:501-536`, making bridge setup match the behavior
  already applied whenever the MAC really changes; it keeps bridge and
  port FDB handling consistent and generates the same notifications user
  space would see after a later MAC change.
- Risk is minimal: the new work executes under RTNL alongside existing
  registration bookkeeping, adds no new data structures or semantics,
  and on allocation failure merely falls back to the prior state. In
  contrast, the bug is user-visible and causes incorrect flooding
  instead of local delivery, so this qualifies as a focused, important
  fix suitable for stable backporting.

 net/bridge/br.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/bridge/br.c b/net/bridge/br.c
index c683baa3847f1..74706cb9283a2 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -37,6 +37,11 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
 	int err;
 
 	if (netif_is_bridge_master(dev)) {
+		struct net_bridge *br = netdev_priv(dev);
+
+		if (event == NETDEV_REGISTER)
+			br_fdb_change_mac_address(br, dev->dev_addr);
+
 		err = br_vlan_bridge_event(dev, event, ptr);
 		if (err)
 			return notifier_from_errno(err);
-- 
2.51.0


  parent reply	other threads:[~2025-10-25 16:16 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:53 ` [PATCH AUTOSEL 6.17-6.1] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.4] ipv6: np->rxpmtu race annotation Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.6] net: stmmac: Correctly handle Rx checksum offload errors Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.12] PCI/ERR: Update device error_state already after reset Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.1] selftests: net: replace sleeps in fcnal-test with waits Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.4] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8 Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-6.12] bnxt_en: Add Hyper-V VF ID Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.4] selftests/net: Ensure assert() triggers in psock_tpacket.c Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.4] net: When removing nexthops, don't call synchronize_net if it is not necessary Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17] netlink: specs: fou: change local-v6/peer-v6 check Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-6.1] smsc911x: add second read of EEPROM mac when possible corruption seen Sasha Levin
2025-10-28 12:53   ` Colin Foster
2025-11-04 13:55     ` Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.4] net: sh_eth: Disable WoL if system can not suspend Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17] bnxt_en: Add fw log trace support for 5731X/5741X chips Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.10] udp_tunnel: use netdev_warn() instead of netdev_WARN() Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] tcp: Update bind bucket state on port release Sasha Levin
2025-10-25 15:56 ` Sasha Levin [this message]
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] selftest: net: Fix error message if empty variable Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] net: phy: dp83640: improve phydev and driver removal handling Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] selftests: Disable dad for ipv6 in fcnal-test.sh Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.6] net: phy: clear link parameters on admin link down Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] net: Prevent RPS table overwrite of active flows Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.10] r8169: set EEE speed down ratio to 1 Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] rds: Fix endianness annotation for RDS_MPATH_HASH Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] net: stmmac: est: Drop frames causing HLBS error Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] net: ipv4: allow directed broadcast routes to use dst hint Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] net: dsa: felix: support phy-mode = "10g-qxgmii" Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] net: ipv6: fix field-spanning memcpy warning in AH output Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-6.12] net: dsa: microchip: Set SPI as bus interface during reset for KSZ8463 Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] net/mlx5e: Prevent entering switchdev mode with inconsistent netns Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-6.12] microchip: lan865x: add ndo_eth_ioctl handler to enable PHY ioctl support Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] Octeontx2-af: Broadcast XON on all channels Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] hinic3: Queue pair endianness improvements Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-6.12] tcp: use dst_dev_rcu() in tcp_fastopen_active_disable_ofo_check() Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17] selftests: net: lib.sh: Don't defer failed commands Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17] ptp_ocp: make ptp_ocp driver compatible with PTP_EXTTS_REQUEST2 Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-5.10] selftests: traceroute: Use require_command() Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-5.10] net: stmmac: Check stmmac_hw_setup() in stmmac_resume() Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-5.10] ipv6: Add sanity checks on ipv6_devconf.rpl_seg_enabled Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] net/mlx5e: Don't query FEC statistics when FEC is disabled Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] bng_en: make bnge_alloc_ring() self-unwind on failure Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.4] page_pool: Clamp pool size to max 16K pages Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] selftests: drv-net: hds: restore hds settings Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.12] selftests: traceroute: Return correct value on failure Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.4] bridge: Redirect to backup port when port is administratively down Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.12] net: devmem: expose tcp_recvmsg_locked errors Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] net: phy: clear EEE runtime state in PHY_HALTED/PHY_ERROR Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.12] selftests: mptcp: join: allow more time to send ADD_ADDR Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.10] net: phy: marvell: Fix 88e1510 downshift counter errata Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] selftests: net: make the dump test less sensitive to mem accounting Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.4] net: nfc: nci: Increase NCI_DATA_TIMEOUT to 3000 ms Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] hinic3: Fix missing napi->dev in netif_queue_set_napi Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.4] selftests: Replace sleep with slowwait Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-6.12] inet_diag: annotate data-races in inet_diag_bc_sk() Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.15] page_pool: always add GFP_NOWARN for ATOMIC allocations Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.4] net/cls_cgroup: Fix task_get_classid() during qdisc run Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.15] ptp: Limit time setting of PTP clocks Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251025160905.3857885-159-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bridge@lists.linux.dev \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).