Score:0

Where does u32 packet classifier start

sc flag

I have a functioning traffic classifier that uses raw packet offsets to match on the source and/or destination MAC addresses of the packet. The filter uses negative offsets as the default appears to be offset=0 is the beginning of the IP packet. The means the contents of the Ethernet header are just prior to that.

Example, for MAC 12:34:56:78:90:ab :

tc filter add dev <iface> protocol ip parent 1:0 prio 1 u32 \
    match u16 0x0800 0xffff at -2 \
    match u32 0x90ab 0xffff at -12 \
    match u16 0x12345678 0xffffffff at -14 \
    flowid 1:10

The network link is now going to be carrying 802.1Q VLAN traffic alongside the non-VLAN stuff. protocol ip prevents this traffic from matching. The question is, how do I construct a similar rule for VLAN traffic? I am trying to do a negative offset again to search for the "Ethertype" value of 0x8100 for DotQ traffic, just to confirm that my assumptions about offset, but can't seem to find it or at least can't seem to match on it. The example below does not successfully match DotQ traffic:

tc filter add dev <iface> parent 1:0 prio 1 u32 \
    match u16 0x8100 0xffff at -6 flowid 1:10

I have been unable to find any documentation on the tc system that specifies what offset=0 represents. Is it unconditionally the IP header start, or does protocol ip affect this?

Score:0
us flag

My guess is that protocol IP uses EtherType field to determine what is the Layer 3 protocol. Since VLAN tag is inserted before EtherType field as indicated in https://en.wikipedia.org/wiki/IEEE_802.1Q, it doesn't match as an IP packet.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.