| 1 |
.TH "ctinfo action in tc" 8 "4 Jun 2019" "iproute2" "Linux" |
| 2 |
.SH NAME |
| 3 |
ctinfo \- tc connmark processing action |
| 4 |
.SH SYNOPSIS |
| 5 |
.B tc ... action ctinfo |
| 6 |
[ |
| 7 |
.B dscp |
| 8 |
MASK [STATEMASK] ] [ |
| 9 |
.B cpmark |
| 10 |
[MASK] ] [ |
| 11 |
.B zone |
| 12 |
ZONE ] [ |
| 13 |
.B CONTROL |
| 14 |
] [ |
| 15 |
.B index |
| 16 |
<INDEX> |
| 17 |
] |
| 18 |
|
| 19 |
.SH DESCRIPTION |
| 20 |
CTINFO (Conntrack Information) is a tc action for retrieving data from |
| 21 |
conntrack marks into various fields. At present it has two independent |
| 22 |
processing modes which may be viewed as sub-functions. |
| 23 |
|
| 24 |
DSCP mode copies a DSCP stored in conntrack's connmark into the IPv4/v6 diffserv |
| 25 |
field. The copying may conditionally occur based on a flag also stored in the |
| 26 |
connmark. DSCP mode was designed to assist in restoring packet classifications on |
| 27 |
ingress, classifications which may then be used by qdiscs such as CAKE. It may be |
| 28 |
used in any circumstance where ingress classification needs to be maintained across |
| 29 |
links that otherwise bleach or remap according to their own policies. |
| 30 |
|
| 31 |
CPMARK (copymark) mode copies the conntrack connmark into the packet's mark field. Without |
| 32 |
additional parameters it is functionally completely equivalent to the existing |
| 33 |
connmark action. An optional mask may be specified to mask which bits of the |
| 34 |
connmark are restored. This may be useful when DSCP and CPMARK modes are combined. |
| 35 |
|
| 36 |
Simple statistics (tc -s) on DSCP restores and CPMARK copies are maintained where values for |
| 37 |
set indicate a count of packets altered for that mode. DSCP includes an error count |
| 38 |
where the destination packet's diffserv field was unwriteable. |
| 39 |
.SH PARAMETERS |
| 40 |
.SS DSCP mode parameters: |
| 41 |
.IP mask |
| 42 |
A mask of 6 contiguous bits indicating where the DSCP value is located in the 32 bit |
| 43 |
conntrack mark field. A mask must be provided for this mode. mask is a 32 bit |
| 44 |
unsigned value. |
| 45 |
.IP statemask |
| 46 |
A mask of at least 1 bit indicating where a conditional restore flag is located in the |
| 47 |
32 bit conntrack mark field. The statemask bit/s must NOT overlap the mask bits. The |
| 48 |
DSCP will be restored if the conntrack mark logically ANDed with the statemask yields |
| 49 |
a non-zero result. statemask is an optional unsigned 32 bit value. |
| 50 |
.SS CPMARK mode parameters: |
| 51 |
.IP mask |
| 52 |
Store the logically ANDed result of conntrack mark and mask into the packet's mark |
| 53 |
field. Default is 0xffffffff i.e. the whole mark field. mask is an optional unsigned 32 bit |
| 54 |
value |
| 55 |
.SS Overall action parameters: |
| 56 |
.IP zone |
| 57 |
Specify the conntrack zone when doing conntrack lookups for packets. |
| 58 |
zone is a 16bit unsigned decimal value. |
| 59 |
Default is 0. |
| 60 |
.IP CONTROL |
| 61 |
The following keywords allow one to control how the tree of qdisc, classes, |
| 62 |
filters and actions is further traversed after this action. |
| 63 |
.RS |
| 64 |
.TP |
| 65 |
.B reclassify |
| 66 |
Restart with the first filter in the current list. |
| 67 |
.TP |
| 68 |
.B pipe |
| 69 |
Continue with the next action attached to the same filter. |
| 70 |
.TP |
| 71 |
.B drop |
| 72 |
Drop the packet. |
| 73 |
.TP |
| 74 |
.B shot |
| 75 |
synonym for |
| 76 |
.B drop |
| 77 |
.TP |
| 78 |
.B continue |
| 79 |
Continue classification with the next filter in line. |
| 80 |
.TP |
| 81 |
.B pass |
| 82 |
Finish classification process and return to calling qdisc for further packet |
| 83 |
processing. This is the default. |
| 84 |
.RE |
| 85 |
.IP index |
| 86 |
Specify an index for this action in order to being able to identify it in later |
| 87 |
commands. index is a 32bit unsigned decimal value. |
| 88 |
.SH EXAMPLES |
| 89 |
Example showing conditional restoration of DSCP on ingress via an IFB |
| 90 |
.RS |
| 91 |
.EX |
| 92 |
|
| 93 |
#Set up the IFB interface |
| 94 |
.br |
| 95 |
tc qdisc add dev ifb4eth0 handle ffff: ingress |
| 96 |
|
| 97 |
#Put CAKE qdisc on it |
| 98 |
.br |
| 99 |
tc qdisc add dev ifb4eth0 root cake bandwidth 40mbit |
| 100 |
|
| 101 |
#Set interface UP |
| 102 |
.br |
| 103 |
ip link set dev ifb4eth0 up |
| 104 |
|
| 105 |
#Add 2 actions, ctinfo to restore dscp & mirred to redirect the packets to IFB |
| 106 |
.br |
| 107 |
tc filter add dev eth0 parent ffff: protocol all prio 10 u32 \\ |
| 108 |
match u32 0 0 flowid 1:1 action \\ |
| 109 |
ctinfo dscp 0xfc000000 0x01000000 \\ |
| 110 |
mirred egress redirect dev ifb4eth0 |
| 111 |
|
| 112 |
tc -s qdisc show dev eth0 ingress |
| 113 |
|
| 114 |
filter parent ffff: protocol all pref 10 u32 chain 0 |
| 115 |
filter parent ffff: protocol all pref 10 u32 chain 0 fh 800: ht divisor 1 |
| 116 |
filter parent ffff: protocol all pref 10 u32 chain 0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 not_in_hw |
| 117 |
match 00000000/00000000 at 0 |
| 118 |
action order 1: ctinfo zone 0 pipe |
| 119 |
index 2 ref 1 bind 1 dscp 0xfc000000 0x01000000 installed 72 sec used 0 sec DSCP set 1333 error 0 CPMARK set 0 |
| 120 |
Action statistics: |
| 121 |
Sent 658484 bytes 1833 pkt (dropped 0, overlimits 0 requeues 0) |
| 122 |
backlog 0b 0p requeues 0 |
| 123 |
|
| 124 |
action order 2: mirred (Egress Redirect to device ifb4eth0) stolen |
| 125 |
index 1 ref 1 bind 1 installed 72 sec used 0 sec |
| 126 |
Action statistics: |
| 127 |
Sent 658484 bytes 1833 pkt (dropped 0, overlimits 0 requeues 0) |
| 128 |
backlog 0b 0p requeues 0 |
| 129 |
.EE |
| 130 |
.RE |
| 131 |
|
| 132 |
Example showing conditional restoration of DSCP on egress |
| 133 |
|
| 134 |
This may appear nonsensical since iptables marking of egress packets is easy |
| 135 |
to achieve, however the iptables flow classification rules may be extensive |
| 136 |
and so some sort of set once and forget may be useful especially on cpu |
| 137 |
constrained devices. |
| 138 |
.RS |
| 139 |
.EX |
| 140 |
|
| 141 |
# Send unmarked connections to a marking chain which needs to store a DSCP |
| 142 |
and set statemask bit in the connmark |
| 143 |
.br |
| 144 |
iptables -t mangle -A POSTROUTING -o eth0 -m connmark \\ |
| 145 |
--mark 0x00000000/0x01000000 -g CLASS_MARKING_CHAIN |
| 146 |
|
| 147 |
# Apply marked DSCP to the packets |
| 148 |
.br |
| 149 |
tc filter add dev eth0 protocol all prio 10 u32 \\ |
| 150 |
match u32 0 0 flowid 1:1 action \\ |
| 151 |
ctinfo dscp 0xfc000000 0x01000000 |
| 152 |
|
| 153 |
tc -s filter show dev eth0 |
| 154 |
filter parent 800e: protocol all pref 10 u32 chain 0 |
| 155 |
filter parent 800e: protocol all pref 10 u32 chain 0 fh 800: ht divisor 1 |
| 156 |
filter parent 800e: protocol all pref 10 u32 chain 0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 not_in_hw |
| 157 |
match 00000000/00000000 at 0 |
| 158 |
action order 1: ctinfo zone 0 pipe |
| 159 |
index 1 ref 1 bind 1 dscp 0xfc000000 0x01000000 installed 7414 sec used 0 sec DSCP set 53404 error 0 CPMARK set 0 |
| 160 |
Action statistics: |
| 161 |
Sent 32890260 bytes 120441 pkt (dropped 0, overlimits 0 requeues 0) |
| 162 |
backlog 0b 0p requeues 0 |
| 163 |
.br |
| 164 |
.RE |
| 165 |
.SH SEE ALSO |
| 166 |
.BR tc (8), |
| 167 |
.BR tc-cake (8) |
| 168 |
.BR tc-connmark (8) |
| 169 |
.BR tc-mirred (8) |
| 170 |
.SH AUTHORS |
| 171 |
ctinfo was written by Kevin Darbyshire-Bryant. |