802.1Q VLAN implementation for Linux

#
802.1Q VLAN implementation for Linux

Updated February 26, 2000
Release: 0.0.10

This code should be considered BETA. MTU problems exist for many ethernet drivers, and people have reported ARP problems, though it works at least some of the time. Other than that, things seem fairly stable!

Join the vlan mailing list, After that, to post, send mail to vlan@scry.wanfear.com.

Though I have no real VLAN hardware of my own, I hear that the code has worked with these systems.

- Cisco Catalyst, 3Com Corebuilder, Netbuilder II
- Alteon ACENic Gigabit, 3Com 3c509, realtek RTL8029(AS), RTL8139, DEC DC21140 (tulip)

Performance: At lease on my low end machines, on a 10bt network, the performance with VLAN v/s ethernet devices seems very good. One machine has only 16MB of RAM, so that is the limiting factor. The file is a 17 MB binary, using ncftp to transport them from one machine to another. Use these numbers for comparison only! Here are the numbers:
Using VLAN interface: 911 kBps
Using Ethernet Interface: 930 kBps

Other VLAN related Resources.

- http://www.netlab.ohio-state.edu/~jain/refs/lsw_refs.htm
- ftp://p8021:-go_wildcats@p8021.hep.net/8021/q-drafts/d11/q-d11.pdf

Change Log

- Release 0.0.10 (gz) For Kernel: 2.2.13/14, 2.3.47 February 26, 2000:
  Added support for PRIORITY. The way it works is that the lower 3 bits of the skb->priority are set into the PRIORITY field in the VLAN header. No special handling is done with priority, but it should be handled by other switches and such. This has not been tested, but the default case (no priority in the skb) seems to work at least.

  The big change is that you can now aggregate several ethernet ports in a single VLAN. The packets will be transmitted in a round robin fashion. In order for this to work, you have to change the MAC addresses on all cards to the same thing, and put the cards in promiscious mode (because most drivers don't really honor the request to set the MAC all the way to the NIC. This works with two different speed NICs, but I think it will only be really useful if they are the same speed. Here is how I set them up in my test environment:

              ifdown eth1
              ifconfig eth1 hw ether 00:40:05:41:00:5e  # This is the MAC of eth0
              ifup eth1

              ifconfig eth1 promisc

              /usr/local/bin/vconfig add eth0 5
              /usr/local/bin/vconfig add_port eth1 5
              ifconfig vlan0005 192.168.2.1

        On my other machine, I have this:
              ifdown eth1
              ifconfig eth1 hw ether 00:48:54:66:68:68  # This is the MAC of eth0
              ifup eth1

              ifconfig eth1 promisc

              /usr/local/bin/vconfig add eth0 5
              /usr/local/bin/vconfig add_port eth1 5
              ifconfig vlan0005 192.168.2.3

  Note that there are now two patches, one for the 2.2 series, and one for the 2.3 series.

- Release 0.0.9 (gz) For Kernel: 2.2.13/14+ February 6, 2000:
  Changed the way vlan names are created: They now have the VID in the name. You can revert to the old behavior by changing an #define in the 802_18/vlan.h file. Changed the destruction process for vlans. Not sure if this fixed the kernel lock problem I found while adding/removing VLAN devices, and also hacking with DHCP, but the problem seemed to go away. Added patch to dhcp to allow it to work with VLANs. However, I don't grok DHCP as well as might be desired, so use at your own risk!! Added some debugging code (you have to compile it in if you need it)

- Release 0.0.8 (gz) For Kernel: 2.2.13+ December 22, 1999:
  Fixed #ifdef problem that caused symbols to not be compiled or found. Fixed minor warning. If it compiled for you last time, nothing worth having in this load I think.

- Release 0.0.7 (gz) For Kernel: 2.2.10+ December 5, 1999:
  Re-wrote the /proc code to never go above 4k buffers. This means that each port now has it's own file entry. Fixed crash bug with removing VLAN devices. Byte and pkt counters are now updated correctly, and are found in the /proc/net/vlan/<device> file.

- Release 0.0.6 (gz) For Kernel: 2.2.10+ October 20, 1999:
  Coded around an extraneous skb alloc/free so that there should be no extra buffer copying as compared to an ethernet interface, unless the vlan device spans more than one interface. Put #ifdef around all printk debugging calls, at least for non-control code (ie no more printk in the critical paths.)

- Release 0.0.5 (gz) For Kernel: 2.2.10 October 19, 1999:
  Got tcpdump working with VLAN pkts (use the -e option). Got basic VLAN functionality working, though problems remain, including a KERNEL CRASH that can be induced by ping -f on one of the vlan interfaces. My test setup consists of two linux boxes, each running my modified kernel. Since I have no third-party implementation to test against, it is likely the code is not too right yet!! Performance isn't all that great: Running a Cyrix 155 <-> a Cyrix 233, connected through a 10bt hub, I get 910 Mbps on regular ethernet, and only 650 Mbps on the VLAN device. This was using a 30 MB file.

- Release 0.0.4 &mbsp; Spetember 27, 1999:
  Little or no new code changes, but it is now in CVS. I'll be working on getting the bugs out of the setup...

- Release 0.0.3 March 29, 1999:
  Modified the VLAN code to be a protocol, instead of an unsightly hack into the ethernet code. Modified vconfig to be more useful, and got rid of all the l2switch stuff (too specialized, and too inflexible.)

To get started, you will want to download the vlan.tar.gz file (to your $HOME directory.) Unpack it with your favorite commands, for example: `tar -xvzf vlan.tar.gz` Alternatively, you can get it from the CVS Repository using something like this:

1. Install and configure cvs on your machine.
2. Specify the vlan repository:
   export CVSROOT=:pserver:anonymous@scry.wanfear.com:/home/cvs/vlan
3. Log in to the repository:
   cvs login (PASSWORD: anonymous)
4. Check out the source:
   mkdir vlan; cd vlan; cvs -z3 checkout vlan

Now, you should have a vlan directory in your home directory. Now, read the README or other docs to figure out what kernel it patches against. A list of mirrors are kept at www.kernel.org. Unzip and un-tar this in your home directory as well, which should create a linux directory in your $HOME directory. Example:`tar -xvzf linux-2.2.14.tar.gz`

Now add the VLAN kernel changes to the kernel. I finally figured out how to do patches that diff can handle (I think I did it right at least!). You will find the patch in the vlan directory. It will be called: vlan.patch, or something equally straight-foward. Apply the patch to your kernel:

NOTE: pick the correct patch for your kernel series. The 2.3 kernel is very unstable at this point.

`cd $HOME/linux
patch -p 1 < $HOME/vlan/[vlan.patch]`

Now, build the vconfig program in the $HOME/vlan directory:
`cd $HOME/vlan
make
`

Now, time to compile your new kernel! Use the `make xconfig` command in your $HOME/linux directory to select your kernel options. The option related to 802.1Q VLANs is found under the Networking options.

Assuming your kernel compiled cleanly (yell if it didn't and you think my code broke it!!), you are now ready to try it out!! Install your kernel in the normal manner (fix up your `/etc/lilo.conf` file appropriately and run `lilo` as root.) Reboot your computer and choose your new kernel.

As your computer comes back to life, there will be little sign that you are now 802.1Q capable, other than two lines spit out during the boot process. There should be a config programs in your $HOME/vlan directory: `vconfig`. vconfig is used to create and destroy VLAN devices. So, lets create a VLAN device on your first ethernet NIC. vconfig<return> will list a short spiel on how to use it. The command I usually use is:

`vconfig add eth0 5`

This attempts to create a VLAN device with VLAN-ID of 5 on the eth0 device. If you want to delete a VLAN, use something like:

`vconfig rem vlan0005`

You will also need to give it an ip, eg: `ifconfig -i vlan0005 192.168.2.1`
and configure it UP: `ifconfig -i vlan0005 up`

NOTE: it's hard to tell what a VLAN's ID is just by looking at it's listing that you get from: `ifconfig -a`. You can get more information if you look at the /proc/net/vlan/* files:

`cat /proc/net/vlan/config`

Please get in contact with me if you have suggestions, patches, or other comments.

Last modified: Sat Feb 26 23:53:56 MST 2000