Blame man/man8/tc-cgroup.8

Packit Service 3880ab
.TH "Cgroup classifier in tc" 8 " 21 Oct 2015" "iproute2" "Linux"
Packit Service 3880ab
Packit Service 3880ab
.SH NAME
Packit Service 3880ab
cgroup \- control group based traffic control filter
Packit Service 3880ab
.SH SYNOPSIS
Packit Service 3880ab
.in +8
Packit Service 3880ab
.ti -8
Packit Service 3880ab
.BR tc " " filter " ... " cgroup " [ " match
Packit Service 3880ab
.IR EMATCH_TREE " ] [ "
Packit Service 3880ab
.B action
Packit Service 3880ab
.IR ACTION_SPEC " ]"
Packit Service 3880ab
.SH DESCRIPTION
Packit Service 3880ab
This filter serves as a hint to
Packit Service 3880ab
.B tc
Packit Service 3880ab
that the assigned class ID of the net_cls control group the process the packet
Packit Service 3880ab
originates from belongs to should be used for classification. Obviously, it is
Packit Service 3880ab
useful for locally generated packets only.
Packit Service 3880ab
.SH OPTIONS
Packit Service 3880ab
.TP
Packit Service 3880ab
.BI action " ACTION_SPEC"
Packit Service 3880ab
Apply an action from the generic actions framework on matching packets.
Packit Service 3880ab
.TP
Packit Service 3880ab
.BI match " EMATCH_TREE"
Packit Service 3880ab
Match packets using the extended match infrastructure. See
Packit Service 3880ab
.BR tc-ematch (8)
Packit Service 3880ab
for a detailed description of the allowed syntax in
Packit Service 3880ab
.IR EMATCH_TREE .
Packit Service 3880ab
.SH EXAMPLES
Packit Service 3880ab
In order to use this filter, a net_cls control group has to be created first and
Packit Service 3880ab
class as well as process ID(s) assigned to it. The following creates a net_cls
Packit Service 3880ab
cgroup named "foobar":
Packit Service 3880ab
Packit Service 3880ab
.RS
Packit Service 3880ab
.EX
Packit Service 3880ab
modprobe cls_cgroup
Packit Service 3880ab
mkdir /sys/fs/cgroup/net_cls
Packit Service 3880ab
mount -t cgroup -onet_cls net_cls /sys/fs/cgroup/net_cls
Packit Service 3880ab
mkdir /sys/fs/cgroup/net_cls/foobar
Packit Service 3880ab
.EE
Packit Service 3880ab
.RE
Packit Service 3880ab
Packit Service 3880ab
To assign a class ID to the created cgroup, a file named
Packit Service 3880ab
.I net_cls.classid
Packit Service 3880ab
has to be created which contains the class ID to be assigned as a hexadecimal,
Packit Service 3880ab
64bit wide number. The upper 32bits are reserved for the major handle, the
Packit Service 3880ab
remaining hold the minor. So a class ID of e.g.
Packit Service 3880ab
.B ff:be
Packit Service 3880ab
has to be written like so:
Packit Service 3880ab
.B 0xff00be
Packit Service 3880ab
(leading zeroes may be omitted). To continue the above example, the following
Packit Service 3880ab
assigns class ID 1:2 to foobar cgroup:
Packit Service 3880ab
Packit Service 3880ab
.RS
Packit Service 3880ab
.EX
Packit Service 3880ab
echo 0x10002 > /sys/fs/cgroup/net_cls/foobar/net_cls.classid
Packit Service 3880ab
.EE
Packit Service 3880ab
.RE
Packit Service 3880ab
Packit Service 3880ab
Finally some PIDs can be assigned to the given cgroup:
Packit Service 3880ab
Packit Service 3880ab
.RS
Packit Service 3880ab
.EX
Packit Service 3880ab
echo 1234 > /sys/fs/cgroup/net_cls/foobar/tasks
Packit Service 3880ab
echo 5678 > /sys/fs/cgroup/net_cls/foobar/tasks
Packit Service 3880ab
.EE
Packit Service 3880ab
.RE
Packit Service 3880ab
Packit Service 3880ab
Now by simply attaching a
Packit Service 3880ab
.B cgroup
Packit Service 3880ab
filter to a
Packit Service 3880ab
.B qdisc
Packit Service 3880ab
makes packets from PIDs 1234 and 5678 be pushed into class 1:2.
Packit Service 3880ab
Packit Service 3880ab
.SH SEE ALSO
Packit Service 3880ab
.BR tc (8),
Packit Service 3880ab
.BR tc-ematch (8),
Packit Service 3880ab
.br
Packit Service 3880ab
the file
Packit Service 3880ab
.I Documentation/cgroups/net_cls.txt
Packit Service 3880ab
of the Linux kernel tree