Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178329705
D62446.1796504922.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D62446.1796504922.diff
View Options
diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c
--- a/sys/dev/netmap/netmap.c
+++ b/sys/dev/netmap/netmap.c
@@ -4297,6 +4297,13 @@
q = &kring->rx_queue;
+ m = nm_os_mbuf_vlan_encap(m);
+ if (m == NULL) {
+ if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
+ goto done;
+ }
+ len = MBUF_LEN(m);
+
// XXX reconsider long packets if we handle fragments
if (len > NETMAP_BUF_SIZE(na)) { /* too long for us */
nm_prerr("%s from_host, drop packet size %d > %d", na->name,
diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -314,6 +314,17 @@
return m->m_pkthdr.csum_flags & CSUM_TSO;
}
+struct mbuf *
+nm_os_mbuf_vlan_encap(struct mbuf *m)
+{
+ if ((m->m_flags & M_VLANTAG) == 0)
+ return (m);
+ m = ether_vlanencap(m, m->m_pkthdr.ether_vtag);
+ if (m != NULL)
+ m->m_flags &= ~M_VLANTAG;
+ return (m);
+}
+
static void
freebsd_generic_rx_handler(if_t ifp, struct mbuf *m)
{
diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c
--- a/sys/dev/netmap/netmap_generic.c
+++ b/sys/dev/netmap/netmap_generic.c
@@ -879,6 +879,12 @@
return 0;
}
+ m = nm_os_mbuf_vlan_encap(m);
+ if (m == NULL) {
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
+ return 1;
+ }
+
/* limit the size of the queue */
if (unlikely(!gna->rxsg && MBUF_LEN(m) > NETMAP_BUF_SIZE(na))) {
/* This may happen when GRO/LRO features are enabled for
diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h
--- a/sys/dev/netmap/netmap_kern.h
+++ b/sys/dev/netmap/netmap_kern.h
@@ -328,6 +328,13 @@
int nm_os_mbuf_has_seg_offld(struct mbuf *m);
int nm_os_mbuf_has_csum_offld(struct mbuf *m);
+/*
+ * A netmap slot holds frame data only. Before an mbuf is queued for a
+ * ring, move a VLAN tag kept in the packet header into the frame, or it
+ * is lost. Returns NULL if the mbuf was freed.
+ */
+struct mbuf *nm_os_mbuf_vlan_encap(struct mbuf *m);
+
#include "netmap_mbq.h"
extern NMG_LOCK_T netmap_global_lock;
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
@@ -1565,6 +1565,85 @@
vnet_cleanup
}
+# Two jails with addresses only on vlan 10, bridged by ${bridge}. Traffic
+# between them flows only if the bridge keeps the tag.
+vlan_netmap_setup()
+{
+ vnet_init
+ vnet_init_bridge
+ _vnet_check_req vlan
+
+ 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 up
+ atf_check -s exit:0 jexec one ifconfig ${epone}b.10 \
+ create 192.0.2.1/24 up
+ atf_check -s exit:0 jexec two ifconfig ${eptwo}b up
+ atf_check -s exit:0 jexec two ifconfig ${eptwo}b.10 \
+ create 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
+}
+
+atf_test_case "vlan_netmap" "cleanup"
+vlan_netmap_head()
+{
+ atf_set descr 'Tagged frames keep their tag through a bridge in netmap mode'
+ atf_set require.user root
+ atf_set require.kmods netmap
+}
+
+vlan_netmap_body()
+{
+ vlan_netmap_setup
+ netmap_bridge_start ${bridge}
+
+ atf_check -s exit:0 -o ignore jexec one ping -c 3 -t 5 192.0.2.2
+}
+
+vlan_netmap_cleanup()
+{
+ netmap_bridge_stop
+ vnet_cleanup
+}
+
+atf_test_case "vlan_netmap_svi" "cleanup"
+vlan_netmap_svi_head()
+{
+ atf_set descr 'Tagged traffic through a bridge with an SVI in netmap mode'
+ atf_set require.user root
+ atf_set require.kmods netmap
+}
+
+vlan_netmap_svi_body()
+{
+ vlan_netmap_setup
+
+ # vlan(4) copies the bridge's if_input when it is configured, so
+ # create it before netmap takes over the bridge's input.
+ svi=$(vnet_mkvlan)
+ atf_check -s exit:0 ifconfig ${svi} vlan 10 vlandev ${bridge}
+ atf_check -s exit:0 ifconfig ${svi} inet 192.0.2.3/24 up
+
+ netmap_bridge_start ${bridge}
+
+ # The SVI's frames reach netmap through the bridge's host ring.
+ atf_check -s exit:0 -o ignore ping -c 3 -t 5 192.0.2.2
+}
+
+vlan_netmap_svi_cleanup()
+{
+ netmap_bridge_stop
+ vnet_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "bridge_transmit_ipv4_unicast"
@@ -1597,4 +1676,6 @@
atf_add_test_case "bridge_svi_in_bridge"
atf_add_test_case "bridge_fib"
atf_add_test_case "netmap"
+ atf_add_test_case "vlan_netmap"
+ atf_add_test_case "vlan_netmap_svi"
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 5, 9:08 PM (23 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42241102
Default Alt Text
D62446.1796504922.diff (4 KB)
Attached To
Mode
D62446: netmap: Keep the VLAN tag of frames taken from the host stack
Attached
Detach File
Event Timeline