TC-CGROUP(8)
๐ CGROUP(8) โ Cgroup Classifier in tc(8) ๐
โจ NAME โจ
okay so the manual name here is cgroup ๐ and it's a control group based traffic control filter ๐
๐ฆ SYNOPSIS ๐ฆ
tc filter ... cgroup [ match EMATCH_TREE ] [ action ACTION_SPEC ]
๐ธ DESCRIPTION ๐ธ
okay bestie, this filter is basically a hint for tc ๐ง it tells tc to use the class ID of the net_cls control group that the process a packet came from belongs to, and to classify with that ๐ it's giving targeted โจ and obviously it only really matters for packets generated locally on the machine ๐
๐ OPTIONS ๐
action ACTION_SPECโ slap an action from the generic actions framework onto packets that match ๐ฅmatch EMATCH_TREEโ match packets using the extended match infrastructure ๐ check out tc-ematch(8) for the full scoop on what syntax is allowed inEMATCH_TREE๐ซถ
๐ง EXAMPLES ๐ง
ngl this part is the main event ๐ญ first you need a net_cls control group, and then you gotta give it a class and some process IDs. this makes a net_cls cgroup called "foobar" ๐:
modprobe cls_cgroup
mkdir /sys/fs/cgroup/net_cls
mount -t cgroup -onet_cls net_cls /sys/fs/cgroup/net_cls
mkdir /sys/fs/cgroup/net_cls/foobar
next up, to give the cgroup a class ID you make a file called net_cls.classid that holds the class ID as a hexadecimal, 64bit wide number ๐ the upper 32bits are for the major handle and the rest is the minor. so a class ID like ff:be gets written as 0xff00be (leading zeroes can be left off) โจ continuing the example, this gives foobar class ID 1:2:
echo 0x10002 > /sys/fs/cgroup/net_cls/foobar/net_cls.classid
last step, toss some PIDs into the cgroup:
echo 1234 > /sys/fs/cgroup/net_cls/foobar/tasks
echo 5678 > /sys/fs/cgroup/net_cls/foobar/tasks
and that's it!! just attach a cgroup filter to a qdisc and packets from PIDs 1234 and 5678 get pushed into class 1:2 ๐ iconic, periodt ๐
๐ฆ SEE ALSO ๐ฆ
tc(8), tc-ematch(8), and the file Documentation/cgroups/net_cls.txt of the Linux kernel tree ๐
iproute2 ยท 21 Oct 2015 ยท Cgroup classifier in tc(8) ๐ that's the source, version, and date for the receipts, bestie ๐ love you, mean it ๐ซถโจ
๐ฆ 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 jammy: iproute2 5.15.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2.2 ยท 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