1.\" $OpenBSD: vlan.4,v 1.31 2008/06/26 05:42:07 ray Exp $ 2.\" 3.\" Copyright (c) 2000 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Jason R. Thorpe of Zembu Labs, Inc. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd $Mdocdate: June 26 2008 $ 31.Dt VLAN 4 32.Os 33.Sh NAME 34.Nm vlan 35.Nd "IEEE 802.1Q encapsulation/decapsulation pseudo-device" 36.Sh SYNOPSIS 37.Cd "pseudo-device vlan" 38.Sh DESCRIPTION 39The 40.Nm 41Ethernet interface allows construction of virtual LANs when used in 42conjunction with IEEE 802.1Q-compliant Ethernet devices. 43.Pp 44A 45.Nm 46interface can be created at runtime using the 47.Ic ifconfig vlan Ns Ar N Ic create 48command or by setting up a 49.Xr hostname.if 5 50configuration file for 51.Xr netstart 8 . 52The interface itself can be configured with 53.Xr ifconfig 8 ; 54see its manual page for more information. 55.Pp 56This driver currently only supports 57802.1Q encapsulation over Ethernet (Ethernet protocol 0x8100). 58The 802.1Q header specifies the virtual LAN number, and thus allows an 59Ethernet switch (or other 802.1Q compliant network devices) to be aware of 60which LAN the frame is part of, and in the case of a switch, which 61port(s) the frame can go to. 62Frames transmitted through the vlan interface will be diverted to the specified 63physical interface with 802.1Q vlan encapsulation. 64Frames with 802.1Q encapsulation received by the parent interface with the 65correct vlan tag will be diverted to the associated 66.Nm 67pseudo-interface. 68.Pp 69Frame headers which normally contain the destination host, source host, and 70protocol, are altered with additional information. 71After the source host, 72a 32-bit 802.1Q header is included, 73comprising as follows: 7416 bits for the ether type (0x8100); 753 bits for the priority field; 761 bit for the canonical field (always 0); 77and 12 bits for the vlan identifier. 78The priority field may be altered via 79.Xr ifconfig 8 ; 80see the 81.Cm vlanprio 82option for more information. 83Following the vlan header is the actual ether type for the frame and length 84information. 85.Pp 86.Nm 87interfaces support the following unique 88.Xr ioctl 2 Ns s : 89.Bl -tag -width "SIOCSETVLANPRIO" -offset 3n 90.It SIOCGETVLAN 91Get the vlan tag and parent for a given vlan interface. 92.It SIOCGETVLANPRIO 93Get the vlan priority for a given vlan interface. 94.It SIOCSETVLAN 95Set the vlan tag and parent for a given vlan interface. 96.It SIOCSETVLANPRIO 97Set the vlan priority for a given vlan interface. 98.El 99.Pp 100.Nm 101interfaces use the following interface capabilities: 102.Bl -tag -width "IFCAP_VLAN_HWTAGGING" -offset 3n 103.It IFCAP_VLAN_MTU 104The parent interface can handle full sized frames, plus the size 105of the vlan tag. 106.It IFCAP_VLAN_HWTAGGING 107The parent interface will participate in the tagging of frames. 108.El 109.Sh DIAGNOSTICS 110.Bl -diag 111.It "vlan%d: initialized with non-standard mtu %d (parent %s)" 112The IFCAP_VLAN_MTU capability was not set on the parent interface. 113We assume in this event that the parent interface is not capable of handling 114frames larger than its MTU. 115This will generally result in a non-compliant 802.1Q implementation. 116.Pp 117Some Ethernet chips will either discard or truncate 118Ethernet frames that are larger than 1514 bytes. 119This causes a problem as 802.1Q tagged frames can be up to 1518 bytes. 120Most controller chips can be told not to discard large frames 121and/or to increase the allowed frame size. 122Refer to the hardware manual for your chip to do this. 123.El 124.Pp 125If the IFCAP_VLAN_MTU capability is set on a vlan parent, 126.Nm 127assumes that the Ethernet chip on the parent can handle 128oversized frames. 129Either the chip allows 1518 byte frames by default (such as 130.Xr rl 4 ) , 131the driver has instructed the chip to do so (such as 132.Xr fxp 4 133and 134.Xr dc 4 ) , 135or the driver also takes advantage of a hardware tagging capability, 136and thus oversized frames are never actually sent by 137.Ox 138(such as 139.Xr txp 4 140and 141.Xr ti 4 ) . 142.Sh SEE ALSO 143.Xr bridge 4 , 144.Xr inet 4 , 145.Xr ip 4 , 146.Xr netintro 4 , 147.Xr hostname.if 5 , 148.Xr ifconfig 8 , 149.Xr netstart 8 150.Rs 151.%T IEEE 802.1Q standard 152.%O http://standards.ieee.org/getieee802/802.1.html 153.Re 154.Sh AUTHORS 155Originally wollman@freebsd.org. 156.Sh BUGS 157The 802.1Q specification allows for operation over FDDI and Token Ring 158as well as Ethernet. 159This driver only supports such operation with Ethernet devices. 160.Pp 161When the IFCAP_VLAN_HWTAGGING capability is set on the parent interface, 162.Nm 163does not participate in the actual tagging of Ethernet frames. 164It simply passes the vlan ID on to the parent interface for tagging on transmit. 165The vlan tagged packet is not actually visible to 166.Ox . 167Thus, 168.Xr bpf 4 169will show untagged packets on the parent interface, although frames 170are actually being transmitted with tags on the wire. 171