Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Feb 2007 17:00:08 +0000
From:      Bruce M Simpson <bms@incunabulum.net>
To:        freebsd-net@freebsd.org
Subject:   [PATCH] Part 1 of low level 802.1p priority support
Message-ID:  <45CDFA18.3030102@incunabulum.net>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------000001090107000501060704
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Here is the first patch to bring in 802.1p Packet Priority to FreeBSD; 
this is to support Differentiated Services and Quality-of-Service. This 
builds on the M_VLANTAG support introduced by Andre last September.

This first stage enables FreeBSD to pass packets for 802.1q with VLAN 0 
to the main input path in the stack, which is the IEEE 
standards-compliant behaviour. With the attached patch and test packet, 
you can test this for yourself.

Currently this is limited to interfaces which support VLAN_HWTAGGING. To 
make the change universal, an architectural change is needed; some of 
the inline 802.1q processing needs to be moved from if_vlan.c to 
if_ethersubr.c.

To use this:
 1. Apply attached patch on a separate machine to be used as a test peer.
 2. Process attached hex dump with xxd from Vim distribution 
(editors/vim) to convert back to a binary pcap file.
 3. Configure test address on test peer, preferably using a separate 
physical LAN.
 4. Use ports/net-mgmt/tcpreplay to inject the traffic, with the 
appropriate IP and MAC addresses.
 5. Observe that you get an ICMP echo reply back WITHOUT 802.1q 
encapsulation.

Currently, the code deals only with receiving VLAN tags at a low level 
and does nothing about sending them.
This is just the low level stuff -- QoS is not magically happening right 
now.

Comments... testing... suggestions...

Regards,
BMS


--------------000001090107000501060704
Content-Type: text/x-patch;
 name="8021p-part1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="8021p-part1.diff"

? .swp
Index: if_ethersubr.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.222
diff -u -p -r1.222 if_ethersubr.c
--- if_ethersubr.c	24 Dec 2006 08:52:13 -0000	1.222
+++ if_ethersubr.c	10 Feb 2007 16:46:42 -0000
@@ -618,6 +618,7 @@ ether_demux(struct ifnet *ifp, struct mb
 	struct ether_header *eh;
 	int isr;
 	u_short ether_type;
+	uint16_t vlanid;
 #if defined(NETATALK)
 	struct llc *l;
 #endif
@@ -627,6 +628,7 @@ ether_demux(struct ifnet *ifp, struct mb
 
 	KASSERT(ifp != NULL, ("ether_demux: NULL interface pointer"));
 
+	vlanid = 0;
 	eh = mtod(m, struct ether_header *);
 	ether_type = ntohs(eh->ether_type);
 
@@ -708,36 +710,44 @@ post_stats:
 	 */
 	if (m->m_flags & M_VLANTAG) {
 		/*
-		 * If no VLANs are configured, drop.
+		 * Deal with numbered 802.1q VLANs, by passing frames for
+		 * specifically numbered VLANs to the VLAN input handler.
 		 */
-		if (ifp->if_vlantrunk == NULL) {
-			ifp->if_noproto++;
-			m_freem(m);
+		vlanid = EVL_VLANOFTAG(m->m_pkthdr.ether_vtag);
+		if (ifp->if_vlantrunk != NULL && vlanid != 0) {
+			KASSERT(vlan_input_p != NULL,
+			    ("ether_input: VLAN not loaded!"));
+			(*vlan_input_p)(ifp, m);
 			return;
 		}
 		/*
-		 * vlan_input() will either recursively call ether_input()
-		 * or drop the packet.
+		 * Drop frames with VLAN encapsulation if VLANs are not
+		 * configured on this interface, if and only if they did
+		 * not contain 802.1p priority information.
+		 * Such frames are preserved, because code further up the
+		 * stack may use the 802.1p information.
 		 */
-		KASSERT(vlan_input_p != NULL,("ether_input: VLAN not loaded!"));
-		(*vlan_input_p)(ifp, m);
-		return;
+		if (ifp->if_vlantrunk == NULL && vlanid != 0) {
+			ifp->if_noproto++;
+			m_freem(m);
+			return;
+		}
 	}
 
 	/*
 	 * Handle protocols that expect to have the Ethernet header
 	 * (and possibly FCS) intact.
 	 */
-	switch (ether_type) {
-	case ETHERTYPE_VLAN:
+	if (ether_type == ETHERTYPE_VLAN && vlanid != 0) {
 		if (ifp->if_vlantrunk != NULL) {
-			KASSERT(vlan_input_p,("ether_input: VLAN not loaded!"));
+			KASSERT(vlan_input_p,
+			    ("ether_input: VLAN not loaded!"));
 			(*vlan_input_p)(ifp, m);
 		} else {
 			ifp->if_noproto++;
 			m_freem(m);
+			return;
 		}
-		return;
 	}
 
 	/* Strip off Ethernet header. */

--------------000001090107000501060704
Content-Type: text/plain;
 name="8021qping.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="8021qping.txt"

0000000: d4c3 b2a1 0200 0400 0000 0000 0000 0000  ................
0000010: ffff 0000 0100 0000 51ed cd45 e444 0d00  ........Q..E.D..
0000020: 6600 0000 6600 0000 ffff ffff ffff 0010  f...f...........
0000030: c6bb 16f4 8100 0000 0800 4500 0054 258f  ..........E..T%.
0000040: 0000 4001 4110 0a00 0005 0a00 0006 0800  ..@.A...........
0000050: ca41 4154 0000 45cd ed51 000c ce3b 0809  .AAT..E..Q...;..
0000060: 0a0b 0c0d 0e0f 1011 1213 1415 1617 1819  ................
0000070: 1a1b 1c1d 1e1f 2021 2223 2425 2627 2829  ...... !"#$%&'()
0000080: 2a2b 2c2d 2e2f 3031 3233 3435 3637       *+,-./01234567

--------------000001090107000501060704--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45CDFA18.3030102>