TC-ACTIONS(8)
๐ NAME ๐
okay so bestie, this is the page for actions โ independently defined actions in tc. yes that tc, the traffic control one, from the tc(8) manual. we're doing kernel networking today, sit down, hydrate. ๐
โจ SYNOPSIS โจ
tc [ TC_OPTIONS ] actions add | change | replace ACTSPEC
tc [ TC_OPTIONS ] actions get | delete ACTISPEC
tc [ TC_OPTIONS ] actions flush ACTNAMESPEC
tc [ TC_OPTIONS ] actions ls | list ACTNAMESPEC [ ACTFILTER ]
ACTSPEC := action ACTDETAIL [ INDEXSPEC ] [ COOKIESPEC ] [ FLAGS
] [ HWSTATSSPEC ] [ CONTROL ] [ SKIPSPEC ]
ACTISPEC := ACTNAMESPEC INDEXSPEC
ACTNAMESPEC := action ACTNAME
INDEXSPEC := index INDEX
ACTFILTER := since MSTIME
COOKIESPEC := cookie COOKIE
FLAGS := no_percpu
HWSTATSSPEC := hw_stats { immediate | delayed | disabled }
ACTDETAIL := ACTNAME ACTPARAMS
ACTNAME may be any valid action type: gact, mirred, bpf,
connmark, csum, police, etc.
MSTIME Time since last update.
CONTROL := { reclassify | pipe | drop | continue | ok }
SKIPSPEC := { skip_sw | skip_hw }
TC_OPTIONS These are the options that are specific to tc and not
only the options. Refer to tc(8) for more information.
fr fr, thatTC_OPTIONSline is telling you to go readtc(8)too, bestie. it's giving "see also but in the synopsis".
๐ฆ DESCRIPTION ๐ฆ
so the actions object in tc lets you define actions independently of a classifier (aka a filter). once you've made them, you can hand them out to one or more filters, and any packet that matches that classifier's criteria gets that action performed on it. iconic. ๐
every action type (mirred, police, etc.) gets its own table to store all the created actions in. so they don't mix, no drama, no crossover episodes. ๐
๐ OPERATIONS ๐
addโ Create a new action in that action's table.change,replaceโ Make modifications to an existing action.getโ Display the action with the specified index value. when you combine it with the-soption fortc, it displays the statistics for that action. โจdeleteโ Delete the action with the specified index value. heads up though: if the action is already associated with a classifier, it does not delete the classifier. the action leaves, the filter stays. they're not a package deal. ๐ls,listโ List all the actions in the specified table. combined with the-soption fortc? you get the statistics for all actions in that specified table. and combined with thesinceoption, it lets you do a millisecond time-filter since the last time an action was used in the datapath. obsessed.flushโ Delete all actions stored in the specified table. all of them. gone. ๐ซถ
๐ธ ACTION OPTIONS ๐ธ
quick vibe check: these options are available to all action types.
index INDEXโ Specify the table index value of an action.INDEXis a 32-bit value that is unique to the specific type of action referenced.
for add, change, and replace operations, the index is optional. when you're adding a new action, specifying an index value will assign the action to that index โ unless that index value has already been assigned, in which case, no. and if you omit the index value for an add operation, the kernel itself will assign a value to the new action. letting the kernel pick, very demure.
for get and delete operations, the index is required, because that's literally how you identify which specific action to display or delete. no index, no service. ๐
cookie COOKIEโ In addition to the specific action, mark the matching packet with the value specified byCOOKIE. theCOOKIEis a 128-bit value that will not be interpreted by the kernel whatsoever. so it's yours, it's free real estate โ use it as a correlating value for maintaining user state. the value you store is completely arbitrary, no specific format required, it just lives inside the action structure itself. ๐FLAGSโ Action-specific flags. currently the only supported flag isno_percpu, which indicates that the action is expected to have minimal software data-path traffic and doesn't need to allocate stat counters with the percpu allocator. this option is intended to be used by hardware-offloaded actions. ๐คhw_stats HW_STATSโ Specifies the type of HW stats of the new action. if you omit it, any stats counter type is going to be used, according to the driver and its resources.HW_STATSindicates the type, and any of these are valid:immediateโ Means that in dump, the user gets the current HW stats state from the device, queried at the dump time. fresh out the oven. โจdelayedโ Means that in dump, the user gets HW stats that might be out of date for some time, maybe a couple of seconds. this is the case when the driver polls stats updates periodically, or when it gets async stats updates from the device. it's giving "seen 2 seconds ago".disabledโ No HW stats are going to be available in dump. nada. zero. ๐
since MSTIMEโ When dumping a large number of actions, you can specify a millisecond time-filter,MSTIME.MSTIMEis a millisecond count since the last time a packet hit the action. for example, specifying"since 20000"implies dumping all actions that have seen packets in the last 20 seconds. super useful when the kernel has a huge number of actions and you only care about the recently used ones. main character actions only. ๐CONTROLโCONTROLindicates howtcshould proceed after executing the action. any of these are valid:reclassifyโ Restart the classification by jumping back to the first filter attached to the action's parent. ๐pipeโ Continue with the next action. this is the default control.dropโ Drop the packet without running any further actions. bye bestie ๐continueโ Continue the classification with the next filter.passโ Return to the calling qdisc for packet processing, and end classification of this packet.
SKIPSPECโ TheSKIPSPECindicates howtcshould proceed when executing the action. any of these are valid:skip_swโ Do not process action by software. and if hardware has no offload support for this action, the operation will fail. so like, know your hardware first. ๐ญskip_hwโ Do not process action by hardware.
๐ซถ SEE ALSO ๐ซถ
tc(8), tc-bpf(8), tc-connmark(8), tc-csum(8), tc-ife(8), tc-mirred(8), tc-nat(8), tc-pedit(8), tc-police(8), tc-simple(8), tc-skbedit(8), tc-skbmod(8), tc-tunnel_key(8), tc-vlan(8), tc-xt(8)
go read those too, iykyk, the whole friend group is worth knowing. ๐ง
and that's the page, bestie!! this one's from iproute2, dated 1 Aug 2017. mwah, slay, periodt. ๐โจ
๐ฆ where this page comes from
- 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
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- 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 deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms