[was] addition to ipfw (read vlans from bridge)..

Yar Tikhiy yar at comp.chem.msu.su
Fri Dec 29 03:33:46 PST 2006


On Tue, Dec 26, 2006 at 11:27:44AM -0800, Julian Elischer wrote:
> Yar Tikhiy wrote:
> 
> >>
> >>If what you are suggesting is that we pass into ipfw an 'offset'
> >>into the packet as well as the packet, then yes I like that idea,
> >>but I didn't see Andre suggest it.
> >
> >Do you consider only ideas by Andre? ;-)  By Andre's opinion I
> >meant this:
> >
> >	Please have the ipfw code examine the vlan tag in the mbuf instead of
> >	fiddling with the mbuf contents.
> 
> At the moment I plan the ipfw code to be unaware of vlan headers.
> the plan is:
>  Add an argument to ipfw which is the offset in the packet where
>  the IP header may be found. Change the L2 users of ipfw to
>  leave the packet alone, but calculate the correct offset to pass to
>  ipfw. IPFW will make no assumptions as to what packet contents come
>  before the offset. Bridge and L2 callers of ipfw will
>  set the offset to non-0 values where the IP callers will set it to
>  0. The non IP callers may make some MAC information available to the
>  ipfw code my some separate method, as it does at the moment. How this
>  is done will depend if we want to support Q-n-Q, and if so, how much..

Sounds very resonable to me.

> >If we want ipfw to know of L2, then examining the VLAN tag in it
> >is OK.  If not really, then ipfw (or any pfil filter) can get just
> >the offset of IP.
> 
> What vlan tag? what if it's from an interface with no VLAN capacity..
> What we need to do is make a convention so that vlan tags are always 
> created at the lowest layer, even if HW vlan tagging is not supported, 
> so that all packets look as if they have come from HW capable packets,
> and add code so that all non WH capable interfaces interpret Van tags at 
> the lowest level, that way vlan packets always look the same.

It depends.  As of now, a network interface driver passes up, e.g.,
to ether_input(), just what it has got.  I.e., a driver in VLAN_HWTAG
mode reads the tag from a hardware register and stores it in
m_pkthdr.ether_vtag while a driver unaware of VLANs just passes up
an 802.1q tagged frame it received.  Perhaps it's ether_input() that
should fix the things up for us so that we don't have to modify every
VLAN-ignorant driver.

However, converting the in-band tag to the out-of-band tag will
take 1 m_pullup() call and 1 bcopy() call and 1 m_adj() call per
tagged frame received:

if ((m->m_flags & M_VLANTAG) == 0) {
	m_pullup(m, sizeof(struct ether_vlan_header));
	evh = mtod(m, struct ether_vlan_header *);
	m->m_pkthdr.ether_vtag = ntohs(evh->evl_tag);
	m->m_flags |= M_VLANTAG;
	bcopy((char *)evh, (char *)evh + ETHER_VLAN_ENCAP_LEN,
	      ETHER_HDR_LEN - ETHER_TYPE_LEN);
	m_adj(m, ETHER_VLAN_ENCAP_LEN);
}

Now I cannot tell if there will be a noticable impact on performance
relative to the approach when we just do things conditionally
depending on M_VLANTAG being set or unset, e.g.:

if (m->m_flags & M_VLANTAG) {
	tag = m->m_pkthdr.ether_vtag;
} else {
	m_pullup(m, sizeof(struct ether_vlan_header));
	evh = mtod(m, struct ether_vlan_header *);
	tag = ntohs(evh->evl_tag);
}
/* now do things based on tag, e.g., filtering... */

> >Pardon, but you seem to mistake me for Max Laier. :-)  OTOH this is
> >a good chance for me to ask you a similar question: Did you recieve
> >my mail on m_copym() usage in the kernel?  I can resend it to you
> >if you didn't. ;-)  Honestly, I'd appreciate much if you dropped a
> >line on the topic.
> 
> sure.. My reader may have misfiled it under spam..
> 
> send it again..

Resent...  Thanks!

> >>>There is also work in progress to introduce nested VLANs AKA Q-n-Q.
> >>>They seem to present a challenge to the scheme you are implementing.
> >>not a permanent problem.. it could be modified to handle it.
> >>but I'll take it into account in the next version if
> >>you think it is a required feature.. what is the maximum
> >>nesting level?
> >
> >Infinity.  Why to introduce such a hard limit?
> 
> 
> Because an infinite limit complicates things?

Not necessarily.  It depends on what we are trying to do with the
tags.  E.g., if we want to find the IP header offset, computing it
by skipping over an unlimited number of VLAN headers won't be more
complex than skipping over just 1-2 of them as we need a loop
already.

> >  Well, 802.1ad allows
> >just two tags: the customer (C) tag and the service (S) tag, but
> >each gets its own ethertype.  C-TAG's is 81-00 while S-TAG's is
> >88-a8.  I don't think we support the different ethertypes yet, so
> >Q-n-Q is just the nesting of type 81-00 tags.  (802.1ad appears a
> >funny reading: it's essentially a patch against the 802.1q text!)
> >Cisco and Juniper boxes seem to have a limit of two tags as well.
> >While they may have a reason to (all those ASICs, you know,) we
> >don't have it.  Allowing for only two tags will tempt us into
> >duplicating code instead of developing fair algos and interfaces.
> >
> 
> yes but algorythmically doing something we may never be required
> to do may lead to unneeded code slowdown. I guess we can look at it
> and decide.

Sure.

-- 
Yar


More information about the freebsd-net mailing list