|
|
049c96 |
From 5703331fbb7957ff959aeda921b7aa28a78d2eb8 Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Thu, 18 Feb 2016 15:45:21 +0100
|
|
|
049c96 |
Subject: [PATCH] tc: add a man page for flow filter
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1286711
|
|
|
049c96 |
Upstream Status: iproute2.git commit 334ddc9b4d526
|
|
|
049c96 |
|
|
|
049c96 |
commit 334ddc9b4d526d0fe4487464c1c4e0c0fcb35a30
|
|
|
049c96 |
Author: Phil Sutter <phil@nwl.cc>
|
|
|
049c96 |
Date: Fri Oct 23 19:47:10 2015 +0200
|
|
|
049c96 |
|
|
|
049c96 |
tc: add a man page for flow filter
|
|
|
049c96 |
|
|
|
049c96 |
Cc: Patrick McHardy <kaber@trash.net>
|
|
|
049c96 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
049c96 |
---
|
|
|
049c96 |
man/man8/tc-flow.8 | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
049c96 |
1 file changed, 265 insertions(+)
|
|
|
049c96 |
create mode 100644 man/man8/tc-flow.8
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/man/man8/tc-flow.8 b/man/man8/tc-flow.8
|
|
|
049c96 |
new file mode 100644
|
|
|
049c96 |
index 0000000..f1b7e2a
|
|
|
049c96 |
--- /dev/null
|
|
|
049c96 |
+++ b/man/man8/tc-flow.8
|
|
|
049c96 |
@@ -0,0 +1,265 @@
|
|
|
049c96 |
+.TH "Flow filter in tc" 8 "20 Oct 2015" "iproute2" "Linux"
|
|
|
049c96 |
+
|
|
|
049c96 |
+.SH NAME
|
|
|
049c96 |
+flow \- flow based traffic control filter
|
|
|
049c96 |
+.SH SYNOPSIS
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+Mapping mode:
|
|
|
049c96 |
+
|
|
|
049c96 |
+.RS
|
|
|
049c96 |
+.in +8
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.BR tc " " filter " ... " "flow map key "
|
|
|
049c96 |
+.IR KEY " [ " OPS " ] [ " OPTIONS " ] "
|
|
|
049c96 |
+.RE
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+Hashing mode:
|
|
|
049c96 |
+
|
|
|
049c96 |
+.RS
|
|
|
049c96 |
+.in +8
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.BR tc " " filter " ... " "flow hash keys "
|
|
|
049c96 |
+.IR KEY_LIST " [ "
|
|
|
049c96 |
+.B perturb
|
|
|
049c96 |
+.IR secs " ] [ " OPTIONS " ] "
|
|
|
049c96 |
+.RE
|
|
|
049c96 |
+
|
|
|
049c96 |
+.in +8
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.IR OPS " := [ " OPS " ] " OP
|
|
|
049c96 |
+
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.IR OPTIONS " := [ "
|
|
|
049c96 |
+.B divisor
|
|
|
049c96 |
+.IR NUM " ] [ "
|
|
|
049c96 |
+.B baseclass
|
|
|
049c96 |
+.IR ID " ] [ "
|
|
|
049c96 |
+.B match
|
|
|
049c96 |
+.IR EMATCH_TREE " ] [ "
|
|
|
049c96 |
+.B action
|
|
|
049c96 |
+.IR ACTION_SPEC " ]"
|
|
|
049c96 |
+
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.IR KEY_LIST " := [ " KEY_LIST " ] " KEY
|
|
|
049c96 |
+
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.IR OP " := { "
|
|
|
049c96 |
+.BR or " | " and " | " xor " | " rshift " | " addend " } "
|
|
|
049c96 |
+.I NUM
|
|
|
049c96 |
+
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.IR ID " := " X : Y
|
|
|
049c96 |
+
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.IR KEY " := { "
|
|
|
049c96 |
+.BR src " | " dst " | " proto " | " proto-src " | " proto-dst " | " iif " | "
|
|
|
049c96 |
+.BR priority " | " mark " | " nfct " | " nfct-src " | " nfct-dst " | "
|
|
|
049c96 |
+.BR nfct-proto-src " | " nfct-proto-dst " | " rt-classid " | " sk-uid " | "
|
|
|
049c96 |
+.BR sk-gid " | " vlan-tag " | " rxhash " }"
|
|
|
049c96 |
+.SH DESCRIPTION
|
|
|
049c96 |
+The
|
|
|
049c96 |
+.B flow
|
|
|
049c96 |
+classifier is meant to extend the
|
|
|
049c96 |
+.B SFQ
|
|
|
049c96 |
+hashing capabilities without hard-coding new hash functions. It also allows
|
|
|
049c96 |
+deterministic mappings of keys to classes.
|
|
|
049c96 |
+.SH OPTIONS
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI action " ACTION_SPEC"
|
|
|
049c96 |
+Apply an action from the generic actions framework on matching packets.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI baseclass " ID"
|
|
|
049c96 |
+An offset for the resulting class ID.
|
|
|
049c96 |
+.I ID
|
|
|
049c96 |
+may be
|
|
|
049c96 |
+.BR root ", " none
|
|
|
049c96 |
+or a hexadecimal class ID in the form [\fIX\fB:\fR]\fIY\fR. If \fIX\fR is
|
|
|
049c96 |
+omitted, it is assumed to be zero.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI divisor " NUM"
|
|
|
049c96 |
+Number of buckets to use for sorting into. Keys are calculated modulo
|
|
|
049c96 |
+.IR NUM .
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI "hash keys " KEY-LIST
|
|
|
049c96 |
+Perform a
|
|
|
049c96 |
+.B jhash2
|
|
|
049c96 |
+operation over the keys in
|
|
|
049c96 |
+.IR KEY-LIST ,
|
|
|
049c96 |
+the result (modulo the
|
|
|
049c96 |
+.B divisor
|
|
|
049c96 |
+if given) is taken as class ID, optionally offset by the value of
|
|
|
049c96 |
+.BR baseclass .
|
|
|
049c96 |
+It is possible to specify an interval (in seconds) after which
|
|
|
049c96 |
+.BR jhash2 's
|
|
|
049c96 |
+entropy source is recreated using the
|
|
|
049c96 |
+.B perturb
|
|
|
049c96 |
+parameter.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI "map key " KEY
|
|
|
049c96 |
+Packet data identified by
|
|
|
049c96 |
+.I KEY
|
|
|
049c96 |
+is translated into class IDs to push the packet into. The value may be mangled by
|
|
|
049c96 |
+.I OPS
|
|
|
049c96 |
+before using it for the mapping. They are applied in the order listed here:
|
|
|
049c96 |
+.RS
|
|
|
049c96 |
+.TP 4
|
|
|
049c96 |
+.BI and " NUM"
|
|
|
049c96 |
+Perform bitwise
|
|
|
049c96 |
+.B AND
|
|
|
049c96 |
+operation with numeric value
|
|
|
049c96 |
+.IR NUM .
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI or " NUM"
|
|
|
049c96 |
+Perform bitwise
|
|
|
049c96 |
+.B OR
|
|
|
049c96 |
+operation with numeric value
|
|
|
049c96 |
+.IR NUM .
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI xor " NUM"
|
|
|
049c96 |
+Perform bitwise
|
|
|
049c96 |
+.B XOR
|
|
|
049c96 |
+operation with numeric value
|
|
|
049c96 |
+.IR NUM .
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI rshift " NUM"
|
|
|
049c96 |
+Shift the value of
|
|
|
049c96 |
+.I KEY
|
|
|
049c96 |
+to the right by
|
|
|
049c96 |
+.I NUM
|
|
|
049c96 |
+bits.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI addend " NUM"
|
|
|
049c96 |
+Add
|
|
|
049c96 |
+.I NUM
|
|
|
049c96 |
+to the value of
|
|
|
049c96 |
+.IR KEY .
|
|
|
049c96 |
+
|
|
|
049c96 |
+.RE
|
|
|
049c96 |
+.RS
|
|
|
049c96 |
+For the
|
|
|
049c96 |
+.BR or ", " and ", " xor " and " rshift
|
|
|
049c96 |
+operations,
|
|
|
049c96 |
+.I NUM
|
|
|
049c96 |
+is assumed to be an unsigned, 32bit integer value. For the
|
|
|
049c96 |
+.B addend
|
|
|
049c96 |
+operation,
|
|
|
049c96 |
+.I NUM
|
|
|
049c96 |
+may be much more complex: It may be prefixed by a minus ('-') sign to cause
|
|
|
049c96 |
+subtraction instead of addition and for keys of
|
|
|
049c96 |
+.BR src ", " dst ", " nfct-src " and " nfct-dst
|
|
|
049c96 |
+it may be given in IP address notation. See below for an illustrating example.
|
|
|
049c96 |
+.RE
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BI match " EMATCH_TREE"
|
|
|
049c96 |
+Match packets using the extended match infrastructure. See
|
|
|
049c96 |
+.BR tc-ematch (8)
|
|
|
049c96 |
+for a detailed description of the allowed syntax in
|
|
|
049c96 |
+.IR EMATCH_TREE .
|
|
|
049c96 |
+.SH KEYS
|
|
|
049c96 |
+In mapping mode, a single key is used (after optional permutation) to build a
|
|
|
049c96 |
+class ID. The resulting ID is deducible in most cases. In hashing more, a number
|
|
|
049c96 |
+of keys may be specified which are then hashed and the output used as class ID.
|
|
|
049c96 |
+This ID is not deducible in beforehand, and may even change over time for a
|
|
|
049c96 |
+given flow if a
|
|
|
049c96 |
+.B perturb
|
|
|
049c96 |
+interval has been given.
|
|
|
049c96 |
+
|
|
|
049c96 |
+The range of class IDs can be limited by the
|
|
|
049c96 |
+.B divisor
|
|
|
049c96 |
+option, which is used for a modulus.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BR src ", " dst
|
|
|
049c96 |
+Use source or destination address as key. In case of IPv4 and TIPC, this is the
|
|
|
049c96 |
+actual address value. For IPv6, the 128bit address is folded into a 32bit value
|
|
|
049c96 |
+by XOR'ing the four 32bit words. In all other cases, the kernel-internal socket
|
|
|
049c96 |
+address is used (after folding into 32bits on 64bit systems).
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B proto
|
|
|
049c96 |
+Use the layer four protocol number as key.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B proto-src
|
|
|
049c96 |
+Use the layer four source port as key. If not available, the kernel-internal
|
|
|
049c96 |
+socket address is used instead.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B proto-dst
|
|
|
049c96 |
+Use the layer four destination port as key. If not available, the associated
|
|
|
049c96 |
+kernel-internal dst_entry address is used after XOR'ing with the packet's
|
|
|
049c96 |
+layer three protocol number.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B iif
|
|
|
049c96 |
+Use the incoming interface index as key.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B priority
|
|
|
049c96 |
+Use the packet's priority as key. Usually this is the IP header's DSCP/ECN
|
|
|
049c96 |
+value.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B mark
|
|
|
049c96 |
+Use the netfilter
|
|
|
049c96 |
+.B fwmark
|
|
|
049c96 |
+as key.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B nfct
|
|
|
049c96 |
+Use the associated conntrack entry address as key.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.BR nfct-src ", " nfct-dst ", " nfct-proto-src ", " nfct-proto-dst
|
|
|
049c96 |
+These are conntrack-aware variants of
|
|
|
049c96 |
+.BR src ", " dst ", " proto-src " and " proto-dst .
|
|
|
049c96 |
+In case of NAT, these are basically the packet header's values before NAT was
|
|
|
049c96 |
+applied.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B rt-classid
|
|
|
049c96 |
+Use the packet's destination routing table entry's realm as key.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B sk-uid
|
|
|
049c96 |
+.TQ
|
|
|
049c96 |
+.B sk-gid
|
|
|
049c96 |
+For locally generated packets, use the user or group ID the originating socket
|
|
|
049c96 |
+belongs to as key.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B vlan-tag
|
|
|
049c96 |
+Use the packet's vlan ID as key.
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+.B rxhash
|
|
|
049c96 |
+Use the flow hash as key.
|
|
|
049c96 |
+
|
|
|
049c96 |
+.SH EXAMPLES
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+Classic SFQ hash:
|
|
|
049c96 |
+
|
|
|
049c96 |
+.EX
|
|
|
049c96 |
+tc filter add ... flow hash \\
|
|
|
049c96 |
+ keys src,dst,proto,proto-src,proto-dst divisor 1024
|
|
|
049c96 |
+.EE
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+Classic SFQ hash, but using information from conntrack to work properly in combination with NAT:
|
|
|
049c96 |
+
|
|
|
049c96 |
+.EX
|
|
|
049c96 |
+tc filter add ... flow hash \\
|
|
|
049c96 |
+ keys nfct-src,nfct-dst,proto,nfct-proto-src,nfct-proto-dst \\
|
|
|
049c96 |
+ divisor 1024
|
|
|
049c96 |
+.EE
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+Map destination IPs of 192.168.0.0/24 to classids 1-257:
|
|
|
049c96 |
+
|
|
|
049c96 |
+.EX
|
|
|
049c96 |
+tc filter add ... flow map \\
|
|
|
049c96 |
+ key dst addend -192.168.0.0 divisor 256
|
|
|
049c96 |
+.EE
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+Alternative to the above:
|
|
|
049c96 |
+
|
|
|
049c96 |
+.EX
|
|
|
049c96 |
+tc filter add ... flow map \\
|
|
|
049c96 |
+ key dst and 0xff
|
|
|
049c96 |
+.EE
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
+The same, but in reverse order:
|
|
|
049c96 |
+
|
|
|
049c96 |
+.EX
|
|
|
049c96 |
+tc filter add ... flow map \\
|
|
|
049c96 |
+ key dst and 0xff xor 0xff
|
|
|
049c96 |
+.EE
|
|
|
049c96 |
+.SH SEE ALSO
|
|
|
049c96 |
+.BR tc (8),
|
|
|
049c96 |
+.BR tc-ematch (8),
|
|
|
049c96 |
+.BR tc-sfq (8)
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|