Linux - U32 selector
Welcome to the tutorial guide. The guide will provide a user with guidance and instructions on U32 selector.
Before proceeding further, it is a good idea to know what is U32 selector. The U32 selector defines which bits are to be matched in the packet header
It is a good idea to have a look at an examplye as provided below:
# tc filter add dev eth0 protocol ip parent 1:0 pref 10 u32 \
match u32 00100000 00ff0000 at 0 flowid 1:10
Please note that after leaving the first line, all the parameters explain the filter’s hash tables. If a user focuses on the selector line which contains the match keyword. This selector will match to IP headers, whose second byte will be 0×10 (0010). The 00ff number is the match mask, telling the filter exactly which bits to match. Here it’s 0xff, so the byte will match if it’s exactly 0×10. The at keyword means that the match is to be started at specified offset (in bytes) in this case it’s beginning of the packet. Translating all that to human language, the packet will match if its Type of Service field will have `low delay’ bits set. It is a good ideas to have a look at another rule which is:
# tc filter add dev eth0 protocol ip parent 1:0 pref 10 u32 \
match u32 00000016 0000ffff at nexthdr+0 flowid 1:10
The nexthdr option means next header encapsulated in the IP packet, i.e. header of upper-layer protocol. The match will also start here at the beginning of the next header. The match should occur in the second, 32-bit word of the header. In TCP and UDP protocols this field contains packet’s destination port. The number is given in big-endian format, i.e. older bits first, so we simply read 0×0016 as 22 decimal, which stands for SSH service if this was TCP.
If a user has read all the mentioned information then he/she will find the selector easy to read: match c0a80100 ffffff00 at 16. This is a three byte match at 17-th byte, counting from the IP header start. This will match for packets with destination address anywhere in 192.168.1/24 network.
If you followed the tutorial guide then you would have learnt about U32 selector.













