TC-CTINFO(8)
Hiii bestie ๐ this is the ctinfo action in tc(8) page, and it's giving connmark processing realness ๐ โจ
โจ NAME โจ
ctinfo, the tc connmark processing action ๐ฆ
โจ SYNOPSIS โจ
tc ... action ctinfo [ dscp MASK [STATEMASK] ] [ cpmark [MASK] ] [ zone
ZONE ] [ CONTROL ] [ index <INDEX> ]
โจ DESCRIPTION โจ
okay so CTINFO (Conntrack Information) is a tc action that grabs data out of conntrack marks and drops it into different fields ๐ง right now it has two independent processing modes, basically two little sub-functions that do their own thing ๐
DSCP mode copies a DSCP stored in conntrack's connmark into the IPv4/v6 diffserv field ๐ธ the copy can happen conditionally, based on a flag that's also stored in the connmark ๐ DSCP mode was built to help restore packet classifications on ingress, and those classifications can then be used by qdiscs like CAKE ๐ it's super useful any time ingress classification needs to survive across links that would otherwise bleach or remap stuff using their own policies ๐ซถ
CPMARK (copymark) mode copies the conntrack connmark into the packet's mark field โจ without any extra parameters it's functionally completely equivalent to the existing connmark action, so no cap it's the same energy ๐ you can add an optional mask to choose which bits of the connmark get restored ๐ฏ this can be really handy when DSCP and CPMARK modes are combined ๐ฅ
Simple statistics are kept for tc -s on DSCP restores and CPMARK copies ๐ the values shown for set are a count of packets altered by that mode ๐ญ DSCP also has an error count for when the destination packet's diffserv field was unwriteable ๐
โจ PARAMETERS โจ
DSCP mode parameters ๐
maskโ a mask of 6 contiguous bits showing where the DSCP value lives in the 32 bit conntrack mark field ๐ a mask must be provided for this mode ๐จmaskis a 32 bit unsigned valuestatemaskโ a mask of at least 1 bit showing where the conditional restore flag lives in the 32 bit conntrack mark field ๐ฆ the statemask bit/s must NOT overlap the mask bits, bestie ๐ โโ๏ธ the DSCP gets restored if the conntrack mark logically ANDed with the statemask gives a non-zero result ๐statemaskis an optional unsigned 32 bit value
CPMARK mode parameters ๐
maskโ stores the logically ANDed result of the conntrack mark and mask into the packet's mark field โจ the default is0xffffffff, i.e. the whole mark field ๐maskis an optional unsigned 32 bit value
Overall action parameters ๐
zoneโ picks the conntrack zone used when doing conntrack lookups for packets ๐ธzoneis a 16bit unsigned decimal value, and the default is0๐CONTROLโ these keywords control how the tree of qdisc, classes, filters and actions gets traversed after this action ๐ง the options are:reclassifyโ restarts with the first filter in the current list ๐pipeโ continues with the next action attached to the same filter ๐ซถdropโ drops the packet ๐shotโ synonym fordrop๐continueโ continues classification with the next filter in line โญpassโ finishes the classification process and returns to the calling qdisc for further packet processing ๐ this is the default, bestie โจ
indexโ gives this action an index so you can identify it in later commands ๐indexis a 32bit unsigned decimal value
โจ EXAMPLES โจ
Example showing conditional restoration of DSCP on ingress via an IFB ๐ฆ
#Set up the IFB interface
tc qdisc add dev ifb4eth0 handle ffff: ingress
#Put CAKE qdisc on it
tc qdisc add dev ifb4eth0 root cake bandwidth 40mbit
#Set interface UP
ip link set dev ifb4eth0 up
#Add 2 actions, ctinfo to restore dscp & mirred to redirect the packets to IFB
tc filter add dev eth0 parent ffff: protocol all prio 10 u32 \
match u32 0 0 flowid 1:1 action \
ctinfo dscp 0xfc000000 0x01000000 \
mirred egress redirect dev ifb4eth0
tc -s qdisc show dev eth0 ingress
filter parent ffff: protocol all pref 10 u32 chain 0
filter parent ffff: protocol all pref 10 u32 chain 0 fh 800: ht divisor 1
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
match 00000000/00000000 at 0
action order 1: ctinfo zone 0 pipe
index 2 ref 1 bind 1 dscp 0xfc000000 0x01000000 installed 72 sec used 0 sec DSCP set 1333 error 0 CPMARK set 0
Action statistics:
Sent 658484 bytes 1833 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
action order 2: mirred (Egress Redirect to device ifb4eth0) stolen
index 1 ref 1 bind 1 installed 72 sec used 0 sec
Action statistics:
Sent 658484 bytes 1833 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
Example showing conditional restoration of DSCP on egress ๐ท
This may look a little nonsensical, since marking egress packets with iptables is easy to do ๐ however iptables flow classification rules can get extensive, so some sort of set once and forget it can be useful, especially on CPU constrained devices ๐ซ
# Send unmarked connections to a marking chain which needs to store a DSCP
and set statemask bit in the connmark
iptables -t mangle -A POSTROUTING -o eth0 -m connmark \
--mark 0x00000000/0x01000000 -g CLASS_MARKING_CHAIN
# Apply marked DSCP to the packets
tc filter add dev eth0 protocol all prio 10 u32 \
match u32 0 0 flowid 1:1 action \
ctinfo dscp 0xfc000000 0x01000000
tc -s filter show dev eth0
filter parent 800e: protocol all pref 10 u32 chain 0
filter parent 800e: protocol all pref 10 u32 chain 0 fh 800: ht divisor 1
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
match 00000000/00000000 at 0
action order 1: ctinfo zone 0 pipe
index 1 ref 1 bind 1 dscp 0xfc000000 0x01000000 installed 7414 sec used 0 sec DSCP set 53404 error 0 CPMARK set 0
Action statistics:
Sent 32890260 bytes 120441 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
โจ SEE ALSO โจ
tc(8), tc-cake(8), tc-connmark(8), tc-mirred(8) ๐
โจ AUTHORS โจ
ctinfo was written by Kevin Darbyshire-Bryant ๐
Bestie, that's the whole tea โ๐ธ this page is from iproute2, last updated 4 Jun 2019, so go slay your ingress classification ๐๐งโจ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms