vlan patch

Gleb Smirnoff glebius at FreeBSD.org
Thu Oct 20 00:00:58 PDT 2005


  Andrew,

On Wed, Oct 19, 2005 at 11:25:59PM +1300, Andrew Thompson wrote:
A> It has always bugged me how the vlan code traverses the linked-list for
A> each incoming packet to find the right ifvlan, I have this patch which
A> attempts to fix this.
A>   
A> What it does is replace the linear search for the vlan with a constant
A> time lookup. It does this by allocating an array for each vlan enabled
A> parent interface so the tag can be directly indexed.
A>   
A> This has an overhead of ~16kb on 32bit, this is not too bad as there is
A> usually only one physical interface when using a large number of vlans.
A>   
A> I have measured a 1.6% pps increase with 100 vlans, and 8% with 500, and
A> yes, some people use this many in production.
A>   
A> It also has the benefit of enforcing unique vlan tags per parent which   
A> the current code doesn't do.

Although the memory overhead is not noticable on modern i386 and amd64
PCs I don't think that we should waste so much memory. We should keep
in mind the existence of embedded architectures with little memory.

In most cases people use 10 - 30 VLANs. I suggest to use a hash, like it
is already done in ng_vlan(4). This hash makes every sixteenth VLAN to fall
into same slot. Since most people allocate VLAN ids contiguously the hash
distribution should be good.

Moreover, I suggest Yar and Ruslan to work together and make the hash code
shared between vlan(4) and ng_vlan(4), not copy-and-pasted.

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE


More information about the freebsd-net mailing list