kern/139268: patch to allow if_bridge to forward just VLAN-tagged (or untagged) packets

P Kern pak at cns.utoronto.ca
Thu Oct 1 00:00:08 UTC 2009


>Number:         139268
>Category:       kern
>Synopsis:       patch to allow if_bridge to forward just VLAN-tagged (or untagged) packets
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 01 00:00:08 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     P Kern
>Release:        7.2-RELEASE
>Organization:
University of Toronto  CNS
>Environment:
FreeBSD utcs 7.2-RELEASE FreeBSD 7.2-RELEASE #4: Thu Sep 24 03:59:57 UTC 2009     pak at utcs:/usr/src/sys/i386/compile/BUG  i386

>Description:
This patch to if_bridge(4) allows the use of the 'link0' or 'link1' interface options to control whether the bridge forwards all packets or just packets with VLAN tags or just packets without VLAN tags (vlan 0?).
Use 'ifconfig bridge0 link0' to make a bridge forward only untagged packets, leaving the tagged packets to be forwarded or processed separately, by other bridges or cloned interfaces.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- sys/net/if_bridge.c	2009/09/29 17:20:13	1.1
+++ sys/net/if_bridge.c	2009/09/29 17:45:14
@@ -2109,6 +2109,16 @@
 		return (m);
 
 	bifp = sc->sc_ifp;
+
+	if (m->m_flags & M_VLANTAG) {	/* packet has a valid VLAN tag */
+		if (bifp->if_flags & IFF_LINK0)
+			/* LINK0 == only bridge untagged packets. skip VLANs. */
+			return (m);
+	}
+	else if (bifp->if_flags & IFF_LINK1) {
+		/* LINK1 == only bridge VLAN-tagged packets. skip untagged. */
+		return (m);
+	}
 	vlan = VLANTAGOF(m);
 
 	/*
--- share/man/man4/if_bridge.4	2009/09/30 23:02:12	1.1
+++ share/man/man4/if_bridge.4	2009/09/30 23:24:25
@@ -126,6 +126,23 @@
 stream.
 This is useful for reconstructing the traffic for network taps
 that transmit the RX/TX signals out through two separate interfaces.
+.Pp
+The
+.Nm
+driver also supports two special link options:
+.Bl -tag -width link0
+.It Cm link0
+Forward only those packets that do
+.Cm not
+contain valid VLAN tags (ie. packets in vlan 0).
+This allows VLAN-tagged packets to be bridged or processed separately.
+.El
+.Bl -tag -width link1
+.It Cm link1
+Forward only those packets that do contain valid VLAN tags.
+This is the complement of
+.Cm link0.
+.El
 .Sh SPANNING TREE
 The
 .Nm


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list