From owner-freebsd-net@FreeBSD.ORG Sat Feb 10 17:00:10 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6798716A400 for ; Sat, 10 Feb 2007 17:00:10 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out5.smtp.messagingengine.com (out5.smtp.messagingengine.com [66.111.4.29]) by mx1.freebsd.org (Postfix) with ESMTP id 1DAEB13C474 for ; Sat, 10 Feb 2007 17:00:09 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id 521851AA07F for ; Sat, 10 Feb 2007 12:00:08 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by out1.internal (MEProxy); Sat, 10 Feb 2007 12:00:08 -0500 X-Sasl-enc: Ns+n6mBiogPGKvRRFtRfc5lr/Pm2EbgUd6HCjNy9kpIn 1171126807 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id C0501111CB for ; Sat, 10 Feb 2007 12:00:07 -0500 (EST) Message-ID: <45CDFA18.3030102@incunabulum.net> Date: Sat, 10 Feb 2007 17:00:08 +0000 From: Bruce M Simpson User-Agent: Thunderbird 1.5.0.9 (X11/20070125) MIME-Version: 1.0 To: freebsd-net@freebsd.org Content-Type: multipart/mixed; boundary="------------000001090107000501060704" Subject: [PATCH] Part 1 of low level 802.1p priority support X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2007 17:00:10 -0000 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--