Universal 32bit classifier in tc(8) Linux Universal 32bit classifier in tc(8) (NAME) tc-u32 - (SYNOPSIS) tc filter ... [ handle HANDLE ] u32 OPTION_LIST [ offset OFFSET ] [ hashkey HASHKEY ] [ classid CLASSID ] [ divisor uint_value ] [ order u32_value ] [ ht HANDLE ] [ sample SELECTOR [ divisor uint_value ] ] [ link HANDLE ] [ indev ifname ] [ skip_hw | skip_sw ] [ help ] HANDLE := { u12_hex_htid:[u8_hex_hash:[u12_hex_nodeid] | 0xu32_hex_value } OPTION_LIST := [ OPTION_LIST ] OPTION HASHKEY := [ mask u32_hex_value ] [ at 4*int_value ] CLASSID := { root | none | [u16_major]:u16_minor | u32_hex_value } OFFSET := [ plus int_value ] [ at 2*int_value ] [ mask u16_hex_value ] [ shift int_value ] [ eat ] OPTION := { match SELECTOR | action ACTION } SELECTOR := { u32 VAL_MASK_32 | u16 VAL_MASK_16 | u8 VAL_MASK_8 | ip IP | ip6 IP6 | { tcp | udp } TCPUDP | icmp ICMP | mark VAL_MASK_32 | ether ETHER } IP := { { src | dst } { default | any | all | ip_address [ / { prefixlen | netmask } ] } AT | { dsfield | ihl | protocol | precedence | icmp_type | icmp_code } VAL_MASK_8 | { sport | dport } VAL_MASK_16 | nofrag | firstfrag | df | mf } IP6 := { { src | dst } { default | any | all | ip6_address [/prefixlen ] } AT | priority VAL_MASK_8 | { protocol | icmp_type | icmp_code } VAL_MASK_8 | flowlabel VAL_MASK_32 | { sport | dport } VAL_MASK_16 } TCPUDP := { src | dst } VAL_MASK_16 ICMP := { type VAL_MASK_8 | code VAL_MASK_8 } ETHER := { src | dst } ether_address AT VAL_MASK_32 := u32_value u32_hex_mask [ AT ] VAL_MASK_16 := u16_value u16_hex_mask [ AT ] VAL_MASK_8 := u8_value u8_hex_mask [ AT ] AT := [ at [ nexthdr+ ] int_value ] (DESCRIPTION) (Universal/Ugly 32bit filter) . . . : . CLASSID action ( ) (link) . (hash table) : . (bucket) . . u32 : (1) divisor (handle) . . (2) link (1) hashkey . (3) (1). sample . u32 (priority) . . (VALUES) . (SYNOPSIS) / : u32 u16 u8 u16 (0xFFFF) . int . _hex_ . 0x 0 () () . : ip_address netmask IPv4 (dotted-quad) . ip6_address . prefixlen ( IPv4 IPv6) . . N*val val N : N . (OPTIONS) u32 : handle HANDLE (handle) . htid hash ( ) nodeid . (htid nodeid) (hash) . . 0x . offset OFFSET . link ht sample . plus at . mask / shift . nexthdr+ . eat : nexthdr+ . hashkey HASHKEY . . link . classid CLASSID CLASSID major minor . divisor u32_value (modulo) . sample . . order u32_value . handle . sample SELECTOR ht . . divisor . link HANDLE (delegate) . HANDLE htid hash nodeid . hashkey . indev ifname . (forwarded) . skip_sw . (offload) TC . skip_hw . help . (SELECTORS) u32 . u32 . u32 VAL_MASK_32 u16 VAL_MASK_16 u8 VAL_MASK_8 . ( u32 u16 u8). AND . . AT . ip IP ip6 IP6 IPv4 (ip) IPv6 (ip6) . IP/IP6 : src ADDR dst ADDR (Source) (Destination) ADDR . default any all . IP . IPv4 (netmask) . dsfield VAL_MASK_8 IPv4. DSCP/ECN . tos precedence. ihl VAL_MASK_8 IPv4. (Internet Header Length). u8_value . protocol VAL_MASK_8 (IPv4) (IPv6) TCP. icmp_type VAL_MASK_8 icmp_code VAL_MASK_8 icmp ipv6-icmp Type Code . IPv4 (extension headers) IPv6 . sport VAL_MASK_16 dport VAL_MASK_16 . ( ). IPv4 IPv6 . nofrag firstfrag df mf IPv4 (fragment offset). (nofrag) (firstfrag) Don't Fragment (df) More Fragments (mf) . priority VAL_MASK_8 IPv6. Traffic Class RFC 3168 ToS IPv4 : DSCP ECN . flowlabel VAL_MASK_32 IPv6. Flow Label. Flow Label . Version Traffic Class . tcp TCPUDP udp TCPUDP TCP UDP. TCPUDP : src VAL_MASK_16 . dst VAL_MASK_16 . icmp ICMP ICMP. ICMP : type VAL_MASK_8 Type ICMP. code VAL_MASK_8 Code ICMP. mark VAL_MASK_32 fwmark netfilter. ether ETHER (Ethernet). ETHER : src ether_address AT dst ether_address AT . : . tun ppp . (EXAMPLES) tc filter add dev eth0 parent 999:0 prio 99 protocol ip u32 \ match ip src 192.168.8.0/24 classid 1:1 qdisc 999:0 . 99 parent ( ). ip IP 192.168.8.0/24 (match). 1:1 . : filter parent 1: protocol ip pref 99 u32 filter parent 1: protocol ip pref 99 u32 \ fh 800: ht divisor 1 filter parent 1: protocol ip pref 99 u32 \ fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 \ match c0a80800/ffffff00 at 12 1: u32 ( divisor ). 800 . : 800 0 1:1 12 0xc0a808 ( ) . : tc filter add dev eth0 prio 99 handle 1: u32 divisor 256 1: 99 . : filter parent 1: protocol all pref 99 u32 filter parent 1: protocol all pref 99 u32 fh 1: ht divisor 256 filter parent 1: protocol all pref 99 u32 fh 800: ht divisor 1 ( 1:) . : tc filter add dev eth0 parent 1: prio 1 u32 \ link 1: hashkey mask 0x0000ff00 at 12 \ match ip src 192.168.0.0/16 u32 . link hashkey . IP . match C 192.168.0.0/16 . : tc filter add dev eth0 parent 1: prio 99 u32 \ ht 1: sample u32 0x00000800 0x0000ff00 at 12 \ match ip src 192.168.8.0/24 classid 1:1 sample : 0x08 . sample divisor . match () . . IPv4 IPv6 . nexthdr+ tcp udp nexthdr+ . . : tc filter add dev eth0 parent 1:0 protocol ip handle 1: \ u32 divisor 1 tc filter add dev eth0 parent 1:0 protocol ip \ u32 ht 1: \ match tcp src 22 FFFF \ classid 1:2 tc filter add dev eth0 parent 1:0 protocol ip \ u32 ht 800: \ match ip protocol 6 FF \ match u16 0 1fff at 6 \ offset at 0 mask 0f00 shift 6 \ link 1: : (1:) . TCP 1:2 . ht . : IPv4 (TCP) ( TCP DF TCP ) IHL IP ( ). link . (SEE ALSO) tc(8), cls_u32.txt http://linux-tc-notes.sourceforge.net iproute2 25 Sep 2015 Universal 32bit classifier in tc(8)