From owner-freebsd-net@FreeBSD.ORG Fri Oct 14 19:29:35 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D173106566C for ; Fri, 14 Oct 2011 19:29:35 +0000 (UTC) (envelope-from rozhuk.im@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id AA90B8FC16 for ; Fri, 14 Oct 2011 19:29:34 +0000 (UTC) Received: by bkbzu17 with SMTP id zu17so87834bkb.13 for ; Fri, 14 Oct 2011 12:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=reply-to:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding:x-mailer:thread-index :content-language:x-cr-hashedpuzzle:x-cr-puzzleid; bh=8OQzlezcFlrbJbq423jvOiUxL0OZmoGiLs7II8JmIAo=; b=gQdl1eS6ModqpPsPYgFvT3NwwVlMXnFg0iEYV8Wgd7SE3v5ucih8iAIeeRTvgms97k 3YZWwYBcK2mE6SKRSK8E0z6ZBESoBrEOt8zlAD4/1lMaIN7Hi0kuRRSt1p069rn8F3wV disu5Mb99rhSGvJBEWOu9kWlyzawiAgd6GvC0= Received: by 10.204.140.206 with SMTP id j14mr7750010bku.55.1318619205015; Fri, 14 Oct 2011 12:06:45 -0700 (PDT) Received: from rimwks1x64 ([92.124.10.60]) by mx.google.com with ESMTPS id v16sm9367150bkd.6.2011.10.14.12.06.42 (version=SSLv3 cipher=OTHER); Fri, 14 Oct 2011 12:06:44 -0700 (PDT) From: rozhuk.im@gmail.com To: Date: Sat, 15 Oct 2011 04:06:40 +0900 Message-ID: <4e988844.1025cc0a.1e88.ffffb4b9@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcyKpGSMDXecgPCYSLqJMoGmDrfX0Q== Content-Language: ru x-cr-hashedpuzzle: yPs= AZWd BpEH C857 IFMp IqF7 Iurz JH9M J1Ro Lno+ MBAJ MnLX QyZv ThHs T5oF UaHM; 2; ZgByAGUAZQBiAHMAZAAtAG4AZQB0AEAAZgByAGUAZQBiAHMAZAAuAG8AcgBnADsAcgBvAHoAaAB1AGsALgBpAG0AQABnAG0AYQBpAGwALgBjAG8AbQA=; Sosha1_v1; 7; {2A6BAF07-A18B-4923-98A3-75073F6F8653}; cgBvAHoAaAB1AGsALgBpAG0AQABnAG0AYQBpAGwALgBjAG8AbQA=; Fri, 14 Oct 2011 19:06:35 GMT; UQBpAG4AUQAgAHMAdQBwAHAAbwByAHQAOgAgAGkAbQBwAGwAZQBtAGUAbgB0ACAAZABlAHQAYQBpAGwAcwAgAC0AIABuAGUAZQBkACAAaABlAGwAcAAhAA== x-cr-puzzleid: {2A6BAF07-A18B-4923-98A3-75073F6F8653} Cc: Rozhuk.IM@gmail.com Subject: QinQ support: implement details - need help! X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Rozhuk.IM@gmail.com List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2011 19:29:35 -0000 ... IEEE 802.1ad (802.1QinQ) specifies architecture and bridge protocols to provide separate instances of the MAC services to multiple independent = users of a Bridged Local Area Network in a manner that does not require cooperation among the users, and requires a minimum of cooperation = between the users and the provider of the MAC service. The idea is to provide, for example, the possibility for customers to = run their own VLANs inside service provider's provided VLAN. This way the service provider can just configure one VLAN for the customer and = customer can then treat that VLAN as if it was a trunk. ... http://en.wikipedia.org/wiki/802.1ad "Customer" VLAN - ether_type: 0x8100 Stored in: struct pkthdr { ... union { u_int16_t vt_vtag; /* Ethernet 802.1p+q vlan tag */ u_int16_t vt_nrecs; /* # of IGMPv3 records in this chain */ } PH_vt; SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ }; #define ether_vtag PH_vt.vt_vtag "Service Provider" VLAN - ether_type: 0x88a8/0x8100/0x9100 How I can store it in packet? How to store tag for QinQinQ? VLAN tags store implementation (IMHO) Ethernet packet: | Dst_MAC | Src_MAC | 802.1Q_Tag2 | 802.1Q_Tag1 | 802.1Q_Tag0 | Ether_type/size | Payload | 802.1Q Tag0 =3D "Customer" VLAN - ether_type: 0x8100, stored in pkthdr.PH_vt.vt_vtag (now) (IEEE 802.1Q) 802.1Q Tag1 =3D "Service Provider" / MetroTag... (IEEE 802.1ad) 802.1Q Tag2 =3D SomeTag... (QinQinQ) I found part of old code in /usr/src/sys/dev/mxge/if_mxge.c: ... /* save the tag */ #ifdef MXGE_NEW_VLAN_API=09 m->m_pkthdr.ether_vtag =3D ntohs(evl->evl_tag); #else { struct m_tag *mtag; mtag =3D m_tag_alloc(MTAG_VLAN, MTAG_VLAN_TAG, sizeof(u_int), M_NOWAIT); if (mtag =3D=3D NULL) return; VLAN_TAG_VALUE(mtag) =3D ntohs(evl->evl_tag); m_tag_prepend(m, mtag); } #endif m->m_flags |=3D M_VLANTAG; ... 1. Compact scheme: #define MTAG_VLAN_T0 1035328035 /* m_tag_cookie */ #define MTAG_VLAN_T1 (MTAG_VLAN_T0 + 1) #define MTAG_VLAN_T2 (MTAG_VLAN_T1 + 1) #define MTAG_VLAN_T3 (MTAG_VLAN_T2 + 1) Store vt_vtag in m_tag_id ng_vlan / if_vlan will use for tag/untag one of MTAG_VLAN_Tx = m_tag_cookie and tunable ether_type for vlan encapsulation: lower <-> ng_vlan(MTAG_VLAN_T0) <-> ng_vlan(MTAG_VLAN_T1) <-> ng_vlan(MTAG_VLAN_T2) <-> upper 2. OpenBSD compatible #ifdef #define MTAG_VLAN MTAG_ABI_COMPAT /* cookie */ #define MTAG_VLAN_TAG0 1035328035 #else #define MTAG_VLAN 1035328035 /* m_tag_cookie */ #define MTAG_VLAN_TAG0 0 /* tag of VLAN interface */ #endif #define MTAG_VLAN_TAG1 (MTAG_VLAN_TAG0 + 1) #define MTAG_VLAN_TAG2 (MTAG_VLAN_TAG1 + 1) #define MTAG_VLAN_TAG3 (MTAG_VLAN_TAG2 + 1) struct mv_tag { struct m_tag tag; u_int16_t vt_vtag; /* Ethernet 802.1p+q vlan tag */ }; ng_vlan / if_vlan will use for tag/untag one of MTAG_VLAN_TAGx m_tag_id = and tunable ether_type for vlan encapsulation: lower <-> ng_vlan(MTAG_VLAN_TAG0) <-> ng_vlan(MTAG_VLAN_TAG1) <-> ng_vlan(MTAG_VLAN_TAG2) <-> upper 3. Extended Same as 2, but struct mv_tag { struct m_tag tag; u_int16_t vt_vtag; /* Ethernet 802.1p+q vlan tag */ u_int16_t ether_type; /* Ethernet type for TAG */ }; Major question is: were store 802.1Q Tag0 =3D "Customer" VLAN (ether_type: 0x8100, IEEE = 802.1Q): in pkthdr.PH_vt.vt_vtag or in struct m_tag? ng_vlan modifications (I can make): + tunable ether_type for vlan encapsulation + tunable on/off encapsulation (to prevent network adapter = encapsulation) + tunable m_tag identifier for VLAN tag ...??? Any comments before I start? PS: Trick: kern.ipc.max_linkhdr should be increased via sysctl: 20 - 1 VLAN tag (.Q) 24 - 2 VLAN tags (QinQ) 28 - 3 VLAN tags (QinQinQ) 32 - 4 VLAN tags (...) =A0 -- Rozhuk Ivan =A0=20