git: e24434f286fd - main - if_bridge: Use bridge's FIB for incoming unicasts
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 15 Nov 2026 18:45:08 UTC
The branch main has been updated by pouria:
URL: https://cgit.FreeBSD.org/src/commit/?id=e24434f286fdd2d6ba1924ecd7eadea6f563f08a
commit e24434f286fdd2d6ba1924ecd7eadea6f563f08a
Author: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-11-15 18:43:52 +0000
Commit: Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-11-15 18:43:52 +0000
if_bridge: Use bridge's FIB for incoming unicasts
A unicast frame for the bridge is handed to the stack with rcvif set
to the bridge, but it kept the FIB of the member it arrived on. With
the bridge in another FIB, replies were looked up in the wrong routing
table and dropped.
Set the FIB of the bridge on such frames. If member_ifaddrs is
enabled and the bridge inherited its MAC address from a member, keep
the old behaviour, since the frame may be for an address configured on
that member.
Reviewed by: zlei
Differential Revision: https://reviews.freebsd.org/D61517
---
sys/net/if_bridge.c | 3 +++
tests/sys/net/if_bridge_test.sh | 47 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 04d773a58b45..71830b0589a9 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -3024,6 +3024,9 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
} \
} \
m->m_pkthdr.rcvif = iface; \
+ if (!V_member_ifaddrs || \
+ ((iface) == bifp && sc->sc_ifaddr == NULL)) \
+ M_SETFIB(m, (iface)->if_fib); \
if ((iface) == ifp) { \
/* Skip bridge processing... src == dest */ \
return (m); \
diff --git a/tests/sys/net/if_bridge_test.sh b/tests/sys/net/if_bridge_test.sh
index 4b9293514176..a5fdd3471d7e 100755
--- a/tests/sys/net/if_bridge_test.sh
+++ b/tests/sys/net/if_bridge_test.sh
@@ -1459,6 +1459,52 @@ vlan_defuntagged_cleanup()
vnet_cleanup
}
+atf_test_case "bridge_fib" "cleanup"
+bridge_fib_head()
+{
+ atf_set descr 'unicast to a bridge uses the FIB of the bridge'
+ atf_set require.user root
+}
+
+bridge_fib_body()
+{
+ vnet_init
+ vnet_init_bridge
+
+ epair=$(vnet_mkepair)
+
+ vnet_mkjail jbridge ${epair}a
+ vnet_mkjail jmember ${epair}b
+
+ sysctl -j jbridge net.link.bridge.member_ifaddrs=0
+ sysctl -j jbridge net.fibs=2
+
+ # The member stays in FIB 0, the bridge is in FIB 1, so the only
+ # route to 192.0.2.0/24 is in FIB 1.
+ bridge=$(ifconfig -j jbridge bridge create)
+ ifconfig -j jbridge ${bridge} fib 1
+ ifconfig -j jbridge ${bridge} addm ${epair}a
+ ifconfig -j jbridge ${epair}a up
+ ifconfig -j jbridge ${bridge} 192.0.2.1/24 up
+
+ ifconfig -j jmember ${epair}b 192.0.2.2/24 up
+
+ # Sanity check: the route only exists in the FIB of the bridge.
+ atf_check -s exit:0 -o ignore \
+ route -j jbridge -n get -fib 1 192.0.2.2
+ atf_check -s not-exit:0 -o ignore -e ignore \
+ route -j jbridge -n get -fib 0 192.0.2.2
+
+ # The echo reply is routed using the FIB of the received request, so
+ # this fails if the request is left in the FIB of the member.
+ atf_check -s exit:0 -o ignore jexec jmember ping -c 3 -t 1 192.0.2.1
+}
+
+bridge_fib_cleanup()
+{
+ vnet_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "bridge_transmit_ipv4_unicast"
@@ -1489,4 +1535,5 @@ atf_init_test_cases()
atf_add_test_case "vlan_untagged"
atf_add_test_case "vlan_defuntagged"
atf_add_test_case "bridge_svi_in_bridge"
+ atf_add_test_case "bridge_fib"
}