1Flower filter in tc(8) Linux Flower filter in tc(8)
2
3
4
6 flower - flow based traffic control filter
7
9 tc filter ... flower [ MATCH_LIST ] [ action ACTION_SPEC ] [ classid
10 CLASSID ] [ hw_tc TCID ]
11
12
13 MATCH_LIST := [ MATCH_LIST ] MATCH
14
15 MATCH := { indev ifname | verbose | skip_sw | skip_hw | { dst_mac |
16 src_mac } MASKED_LLADDR | vlan_id VID | vlan_prio PRIORITY |
17 vlan_ethtype { ipv4 | ipv6 | ETH_TYPE } | cvlan_id VID |
18 cvlan_prio PRIORITY | cvlan_ethtype { ipv4 | ipv6 | ETH_TYPE }
19 | mpls_label LABEL | mpls_tc TC | mpls_bos BOS | mpls_ttl TTL |
20 ip_proto { tcp | udp | sctp | icmp | icmpv6 | IP_PROTO } |
21 ip_tos MASKED_IP_TOS | ip_ttl MASKED_IP_TTL | { dst_ip | src_ip
22 } PREFIX | { dst_port | src_port } { MASKED_NUMBER |
23 min_port_number-max_port_number } | tcp_flags MASKED_TCP_FLAGS
24 | type MASKED_TYPE | code MASKED_CODE | { arp_tip | arp_sip }
25 IPV4_PREFIX | arp_op { request | reply | OP } | { arp_tha |
26 arp_sha } MASKED_LLADDR | enc_key_id KEY-ID | { enc_dst_ip |
27 enc_src_ip } { ipv4_address | ipv6_address } | enc_dst_port
28 port_number | enc_tos TOS | enc_ttl TTL | geneve_opts OPTIONS |
29 ip_flags IP_FLAGS
30
32 The flower filter matches flows to the set of keys specified and
33 assigns an arbitrarily chosen class ID to packets belonging to them.
34 Additionally (or alternatively) an action from the generic action
35 framework may be called.
36
38 action ACTION_SPEC
39 Apply an action from the generic actions framework on matching
40 packets.
41
42 classid CLASSID
43 Specify a class to pass matching packets on to. CLASSID is in
44 the form X:Y, while X and Y are interpreted as numbers in hexa‐
45 decimal format.
46
47 hw_tc TCID
48 Specify a hardware traffic class to pass matching packets on to.
49 TCID is in the range 0 through 15.
50
51 indev ifname
52 Match on incoming interface name. Obviously this makes sense
53 only for forwarded flows. ifname is the name of an interface
54 which must exist at the time of tc invocation.
55
56 verbose
57 Enable verbose logging, including offloading errors when not
58 using skip_sw flag.
59
60 skip_sw
61 Do not process filter by software. If hardware has no offload
62 support for this filter, or TC offload is not enabled for the
63 interface, operation will fail.
64
65 skip_hw
66 Do not process filter by hardware.
67
68 dst_mac MASKED_LLADDR
69 src_mac MASKED_LLADDR
70 Match on source or destination MAC address. A mask may be
71 optionally provided to limit the bits of the address which are
72 matched. A mask is provided by following the address with a
73 slash and then the mask. It may be provided in LLADDR format, in
74 which case it is a bitwise mask, or as a number of high bits to
75 match. If the mask is missing then a match on all bits is
76 assumed.
77
78 vlan_id VID
79 Match on vlan tag id. VID is an unsigned 12bit value in decimal
80 format.
81
82 vlan_prio PRIORITY
83 Match on vlan tag priority. PRIORITY is an unsigned 3bit value
84 in decimal format.
85
86 vlan_ethtype VLAN_ETH_TYPE
87 Match on layer three protocol. VLAN_ETH_TYPE may be either
88 ipv4, ipv6 or an unsigned 16bit value in hexadecimal format. To
89 match on QinQ packet, it must be 802.1Q or 802.1AD.
90
91 cvlan_id VID
92 Match on QinQ inner vlan tag id. VID is an unsigned 12bit value
93 in decimal format.
94
95 cvlan_prio PRIORITY
96 Match on QinQ inner vlan tag priority. PRIORITY is an unsigned
97 3bit value in decimal format.
98
99 cvlan_ethtype VLAN_ETH_TYPE
100 Match on QinQ layer three protocol. VLAN_ETH_TYPE may be either
101 ipv4, ipv6 or an unsigned 16bit value in hexadecimal format.
102
103 mpls_label LABEL
104 Match the label id in the outermost MPLS label stack entry.
105 LABEL is an unsigned 20 bit value in decimal format.
106
107 mpls_tc TC
108 Match on the MPLS TC field, which is typically used for packet
109 priority, in the outermost MPLS label stack entry. TC is an
110 unsigned 3 bit value in decimal format.
111
112 mpls_bos BOS
113 Match on the MPLS Bottom Of Stack field in the outermost MPLS
114 label stack entry. BOS is a 1 bit value in decimal format.
115
116 mpls_ttl TTL
117 Match on the MPLS Time To Live field in the outermost MPLS label
118 stack entry. TTL is an unsigned 8 bit value in decimal format.
119
120 ip_proto IP_PROTO
121 Match on layer four protocol. IP_PROTO may be tcp, udp, sctp,
122 icmp, icmpv6 or an unsigned 8bit value in hexadecimal format.
123
124 ip_tos MASKED_IP_TOS
125 Match on ipv4 TOS or ipv6 traffic-class - eight bits in hexadec‐
126 imal format. A mask may be optionally provided to limit the
127 bits which are matched. A mask is provided by following the
128 value with a slash and then the mask. If the mask is missing
129 then a match on all bits is assumed.
130
131 ip_ttl MASKED_IP_TTL
132 Match on ipv4 TTL or ipv6 hop-limit - eight bits value in deci‐
133 mal or hexadecimal format. A mask may be optionally provided to
134 limit the bits which are matched. Same logic is used for the
135 mask as with matching on ip_tos.
136
137 dst_ip PREFIX
138 src_ip PREFIX
139 Match on source or destination IP address. PREFIX must be a
140 valid IPv4 or IPv6 address, depending on the protocol option to
141 tc filter, optionally followed by a slash and the prefix length.
142 If the prefix is missing, tc assumes a full-length host match.
143
144 dst_port { MASKED_NUMBER | MIN_VALUE-MAX_VALUE }
145 src_port { MASKED_NUMBER | MIN_VALUE-MAX_VALUE }
146 Match on layer 4 protocol source or destination port number,
147 with an optional mask. Alternatively, the mininum and maximum
148 values can be specified to match on a range of layer 4 protocol
149 source or destination port numbers. Only available for ip_proto
150 values udp, tcp and sctp which have to be specified in before‐
151 hand.
152
153 tcp_flags MASKED_TCP_FLAGS
154 Match on TCP flags represented as 12bit bitfield in in hexadeci‐
155 mal format. A mask may be optionally provided to limit the bits
156 which are matched. A mask is provided by following the value
157 with a slash and then the mask. If the mask is missing then a
158 match on all bits is assumed.
159
160 type MASKED_TYPE
161 code MASKED_CODE
162 Match on ICMP type or code. A mask may be optionally provided to
163 limit the bits of the address which are matched. A mask is pro‐
164 vided by following the address with a slash and then the mask.
165 The mask must be as a number which represents a bitwise mask If
166 the mask is missing then a match on all bits is assumed. Only
167 available for ip_proto values icmp and icmpv6 which have to be
168 specified in beforehand.
169
170 arp_tip IPV4_PREFIX
171 arp_sip IPV4_PREFIX
172 Match on ARP or RARP sender or target IP address. IPV4_PREFIX
173 must be a valid IPv4 address optionally followed by a slash and
174 the prefix length. If the prefix is missing, tc assumes a full-
175 length host match.
176
177 arp_op ARP_OP
178 Match on ARP or RARP operation. ARP_OP may be request, reply or
179 an integer value 0, 1 or 2. A mask may be optionally provided
180 to limit the bits of the operation which are matched. A mask is
181 provided by following the address with a slash and then the
182 mask. It may be provided as an unsigned 8 bit value representing
183 a bitwise mask. If the mask is missing then a match on all bits
184 is assumed.
185
186 arp_sha MASKED_LLADDR
187 arp_tha MASKED_LLADDR
188 Match on ARP or RARP sender or target MAC address. A mask may
189 be optionally provided to limit the bits of the address which
190 are matched. A mask is provided by following the address with a
191 slash and then the mask. It may be provided in LLADDR format, in
192 which case it is a bitwise mask, or as a number of high bits to
193 match. If the mask is missing then a match on all bits is
194 assumed.
195
196 enc_key_id NUMBER
197 enc_dst_ip PREFIX
198 enc_src_ip PREFIX
199 enc_dst_port NUMBER
200 enc_tos NUMBER
201 enc_ttl NUMBER
202
203
204 ct_state CT_STATE
205 ct_zone CT_MASKED_ZONE
206 ct_mark CT_MASKED_MARK
207 ct_label CT_MASKED_LABEL
208 Matches on connection tracking info
209
210 CT_STATE
211 Match the connection state, and can ne combination of
212 [{+|-}flag] flags, where flag can be one of
213
214 trk - Tracked connection.
215
216 new - New connection.
217
218 est - Established connection.
219
220 Example: +trk+est
221
222 CT_MASKED_ZONE
223 Match the connection zone, and can be masked.
224
225 CT_MASKED_MARK
226 32bit match on the connection mark, and can be masked.
227
228 CT_MASKED_LABEL
229 128bit match on the connection label, and can be masked.
230
231 geneve_opts OPTIONS
232 Match on IP tunnel metadata. Key id NUMBER is a 32 bit tunnel
233 key id (e.g. VNI for VXLAN tunnel). PREFIX must be a valid IPv4
234 or IPv6 address optionally followed by a slash and the prefix
235 length. If the prefix is missing, tc assumes a full-length host
236 match. Dst port NUMBER is a 16 bit UDP dst port. Tos NUMBER is
237 an 8 bit tos (dscp+ecn) value, ttl NUMBER is an 8 bit time-to-
238 live value. geneve_opts OPTIONS must be a valid list of comma-
239 separated geneve options where each option consists of a key
240 optionally followed by a slash and corresponding mask. If the
241 masks is missing, tc assumes a full-length match. The options
242 can be described in the form
243 CLASS:TYPE:DATA/CLASS_MASK:TYPE_MASK:DATA_MASK, where CLASS is
244 represented as a 16bit hexadecimal value, TYPE as an 8bit hexa‐
245 decimal value and DATA as a variable length hexadecimal value.
246
247 ip_flags IP_FLAGS
248 IP_FLAGS may be either frag, nofrag, firstfrag or nofirstfrag
249 where frag and nofrag could be used to match on fragmented pack‐
250 ets or not, respectively. firstfrag and nofirstfrag can be used
251 to further distinguish fragmented packet. firstfrag can be used
252 to indicate the first fragmented packet. nofirstfrag can be used
253 to indicates subsequent fragmented packets or non-fragmented
254 packets.
255
257 As stated above where applicable, matches of a certain layer implicitly
258 depend on the matches of the next lower layer. Precisely, layer one and
259 two matches (indev, dst_mac and src_mac) have no dependency, MPLS and
260 layer three matches (mpls_label, mpls_tc, mpls_bos, mpls_ttl, ip_proto,
261 dst_ip, src_ip, arp_tip, arp_sip, arp_op, arp_tha, arp_sha and
262 ip_flags) depend on the protocol option of tc filter, layer four port
263 matches (dst_port and src_port) depend on ip_proto being set to tcp,
264 udp or sctp, and finally ICMP matches (code and type) depend on
265 ip_proto being set to icmp or icmpv6.
266
267 There can be only used one mask per one prio. If user needs to specify
268 different mask, he has to use different prio.
269
271 tc(8), tc-flow(8)
272
273
274
275iproute2 22 Oct 2015 Flower filter in tc(8)