1 .TH "Flow filter in tc" 8 "20 Oct 2015" "iproute2" "Linux"
4 flow \- flow based traffic control filter
12 .BR tc " " filter " ... " "flow map key "
13 .IR KEY " [ " OPS " ] [ " OPTIONS " ] "
21 .BR tc " " filter " ... " "flow hash keys "
24 .IR secs " ] [ " OPTIONS " ] "
29 .IR OPS " := [ " OPS " ] " OP
38 .IR EMATCH_TREE " ] [ "
43 .IR KEY_LIST " := [ " KEY_LIST " ] " KEY
47 .BR or " | " and " | " xor " | " rshift " | " addend " } "
55 .BR src " | " dst " | " proto " | " proto-src " | " proto-dst " | " iif " | "
56 .BR priority " | " mark " | " nfct " | " nfct-src " | " nfct-dst " | "
57 .BR nfct-proto-src " | " nfct-proto-dst " | " rt-classid " | " sk-uid " | "
58 .BR sk-gid " | " vlan-tag " | " rxhash " }"
62 classifier is meant to extend the
64 hashing capabilities without hard-coding new hash functions. It also allows
65 deterministic mappings of keys to classes.
68 .BI action " ACTION_SPEC"
69 Apply an action from the generic actions framework on matching packets.
72 An offset for the resulting class ID.
76 or a hexadecimal class ID in the form [\fIX\fB:\fR]\fIY\fR. \fIX\fR must
77 match qdisc's/class's major handle (if omitted, the correct value is chosen
78 automatically). If the whole \fBbaseclass\fR is omitted, \fIY\fR defaults
82 Number of buckets to use for sorting into. Keys are calculated modulo
85 .BI "hash keys " KEY-LIST
88 operation over the keys in
90 the result (modulo the
92 if given) is taken as class ID, optionally offset by the value of
94 It is possible to specify an interval (in seconds) after which
96 entropy source is recreated using the
101 Packet data identified by
103 is translated into class IDs to push the packet into. The value may be mangled by
105 before using it for the mapping. They are applied in the order listed here:
111 operation with numeric value
117 operation with numeric value
123 operation with numeric value
142 .BR or ", " and ", " xor " and " rshift
145 is assumed to be an unsigned, 32bit integer value. For the
149 may be much more complex: It may be prefixed by a minus ('-') sign to cause
150 subtraction instead of addition and for keys of
151 .BR src ", " dst ", " nfct-src " and " nfct-dst
152 it may be given in IP address notation. See below for an illustrating example.
155 .BI match " EMATCH_TREE"
156 Match packets using the extended match infrastructure. See
158 for a detailed description of the allowed syntax in
161 In mapping mode, a single key is used (after optional permutation) to build a
162 class ID. The resulting ID is deducible in most cases. In hashing more, a number
163 of keys may be specified which are then hashed and the output used as class ID.
164 This ID is not deducible in beforehand, and may even change over time for a
167 interval has been given.
169 The range of class IDs can be limited by the
171 option, which is used for a modulus.
174 Use source or destination address as key. In case of IPv4 and TIPC, this is the
175 actual address value. For IPv6, the 128bit address is folded into a 32bit value
176 by XOR'ing the four 32bit words. In all other cases, the kernel-internal socket
177 address is used (after folding into 32bits on 64bit systems).
180 Use the layer four protocol number as key.
183 Use the layer four source port as key. If not available, the kernel-internal
184 socket address is used instead.
187 Use the layer four destination port as key. If not available, the associated
188 kernel-internal dst_entry address is used after XOR'ing with the packet's
189 layer three protocol number.
192 Use the incoming interface index as key.
195 Use the packet's priority as key. Usually this is the IP header's DSCP/ECN
204 Use the associated conntrack entry address as key.
206 .BR nfct-src ", " nfct-dst ", " nfct-proto-src ", " nfct-proto-dst
207 These are conntrack-aware variants of
208 .BR src ", " dst ", " proto-src " and " proto-dst .
209 In case of NAT, these are basically the packet header's values before NAT was
213 Use the packet's destination routing table entry's realm as key.
218 For locally generated packets, use the user or group ID the originating socket
222 Use the packet's vlan ID as key.
225 Use the flow hash as key.
232 tc filter add ... flow hash \\
233 keys src,dst,proto,proto-src,proto-dst divisor 1024
236 Classic SFQ hash, but using information from conntrack to work properly in combination with NAT:
239 tc filter add ... flow hash \\
240 keys nfct-src,nfct-dst,proto,nfct-proto-src,nfct-proto-dst \\
244 Map destination IPs of 192.168.0.0/24 to classids 1-256:
247 tc filter add ... flow map \\
248 key dst addend -192.168.0.0 divisor 256
251 Alternative to the above:
254 tc filter add ... flow map \\
258 The same, but in reverse order:
261 tc filter add ... flow map \\
262 key dst and 0xff xor 0xff