Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178329701
D62445.1796504916.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D62445.1796504916.diff
View Options
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -2873,21 +2873,25 @@
sc = bif->bif_sc;
if (sc == NULL) {
+ struct bridge_rtnode *brt;
+
/*
* This packet originated from the bridge itself, so it must
* have been transmitted by netmap. Derive the "source"
- * interface from the source address and drop the packet if the
+ * member from the source address and drop the packet if the
* source address isn't known.
*/
KASSERT((m->m_flags & M_BRIDGE_INJECT) != 0,
("%s: ifnet %p missing a bridge softc", __func__, ifp));
sc = if_getsoftc(ifp);
- ifp = bridge_rtlookup(sc, eh->ether_shost, vlan);
- if (ifp == NULL) {
+ brt = bridge_rtnode_lookup(sc, eh->ether_shost, vlan);
+ if (brt == NULL) {
if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1);
m_freem(m);
return (NULL);
}
+ bif = brt->brt_dst;
+ ifp = bif->bif_ifp;
m->m_pkthdr.rcvif = ifp;
}
bifp = sc->sc_ifp;
diff --git a/tests/sys/net/Makefile b/tests/sys/net/Makefile
--- a/tests/sys/net/Makefile
+++ b/tests/sys/net/Makefile
@@ -23,7 +23,7 @@
TESTS_SUBDIRS+= wg
TESTS_SUBDIRS+= routing
-# The netmap bridge application is used by if_wg tests.
+# The netmap bridge application is used by if_bridge and if_wg tests.
.PATH: ${SRCTOP}/tools/tools/netmap
PROGS+= bridge
LIBADD.bridge+= netmap
diff --git a/tests/sys/net/if_bridge_test.sh b/tests/sys/net/if_bridge_test.sh
--- a/tests/sys/net/if_bridge_test.sh
+++ b/tests/sys/net/if_bridge_test.sh
@@ -1505,6 +1505,66 @@
vnet_cleanup
}
+# Pass the bridge's traffic through tools/tools/netmap/bridge, between the
+# bridge port and its host rings, and wait for the bridge to be in netmap mode.
+netmap_bridge_start()
+{
+ $(atf_get_srcdir)/bridge -w 0 -i netmap:$1 -i netmap:$1^ &
+ echo $! > netmap_bridge.pid
+ for i in $(seq 50); do
+ if ifconfig $1 | grep -q NETMAP; then
+ return
+ fi
+ sleep 0.1
+ done
+ atf_fail "$1 did not enter netmap mode"
+}
+
+netmap_bridge_stop()
+{
+ if [ -f netmap_bridge.pid ]; then
+ kill $(cat netmap_bridge.pid)
+ fi
+}
+
+atf_test_case "netmap" "cleanup"
+netmap_head()
+{
+ atf_set descr 'Forward through a bridge in netmap mode'
+ atf_set require.user root
+ atf_set require.kmods netmap
+}
+
+netmap_body()
+{
+ vnet_init
+ vnet_init_bridge
+
+ epone=$(vnet_mkepair)
+ eptwo=$(vnet_mkepair)
+
+ vnet_mkjail one ${epone}b
+ vnet_mkjail two ${eptwo}b
+
+ atf_check -s exit:0 jexec one ifconfig ${epone}b 192.0.2.1/24 up
+ atf_check -s exit:0 jexec two ifconfig ${eptwo}b 192.0.2.2/24 up
+
+ bridge=$(vnet_mkbridge)
+ atf_check -s exit:0 ifconfig ${epone}a up
+ atf_check -s exit:0 ifconfig ${eptwo}a up
+ atf_check -s exit:0 ifconfig ${bridge} addm ${epone}a addm ${eptwo}a up
+
+ netmap_bridge_start ${bridge}
+
+ atf_check -s exit:0 -o ignore jexec one ping -c 3 -t 5 192.0.2.2
+}
+
+netmap_cleanup()
+{
+ netmap_bridge_stop
+ vnet_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "bridge_transmit_ipv4_unicast"
@@ -1536,4 +1596,5 @@
atf_add_test_case "vlan_defuntagged"
atf_add_test_case "bridge_svi_in_bridge"
atf_add_test_case "bridge_fib"
+ atf_add_test_case "netmap"
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 5, 9:08 PM (23 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42240566
Default Alt Text
D62445.1796504916.diff (3 KB)
Attached To
Mode
D62445: if_bridge: Fix a NULL dereference on frames injected by netmap
Attached
Detach File
Event Timeline