man-pages/man8/tc-cgroup.8.html
2021-03-31 01:06:50 +01:00

143 lines
3.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Cgroup classifier in tc</TITLE>
</HEAD><BODY>
<H1>Cgroup classifier in tc</H1>
Section: Linux (8)<BR>Updated: 21 Oct 2015<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<P>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
cgroup - control group based traffic control filter
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<BR>
<B>tc</B> <B>filter</B> ... <B>cgroup</B> [ <B>match</B>
<I>EMATCH_TREE</I> ] [
<B>action</B>
<I>ACTION_SPEC</I> ]
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
This filter serves as a hint to
<B>tc</B>
that the assigned class ID of the net_cls control group the process the packet
originates from belongs to should be used for classification. Obviously, it is
useful for locally generated packets only.
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<DL COMPACT>
<DT id="1"><B>action</B><I> ACTION_SPEC</I>
<DD>
Apply an action from the generic actions framework on matching packets.
<DT id="2"><B>match</B><I> EMATCH_TREE</I>
<DD>
Match packets using the extended match infrastructure. See
<B><A HREF="/cgi-bin/man/man2html?8+tc-ematch">tc-ematch</A></B>(8)
for a detailed description of the allowed syntax in
<I>EMATCH_TREE</I>.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>EXAMPLES</H2>
In order to use this filter, a net_cls control group has to be created first and
class as well as process ID(s) assigned to it. The following creates a net_cls
cgroup named &quot;foobar&quot;:
<P>
<DL COMPACT><DT id="3"><DD>
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
</DL>
<P>
To assign a class ID to the created cgroup, a file named
<I>net_cls.classid</I>
has to be created which contains the class ID to be assigned as a hexadecimal,
64bit wide number. The upper 32bits are reserved for the major handle, the
remaining hold the minor. So a class ID of e.g.
<B>ff:be</B>
has to be written like so:
<B>0xff00be</B>
(leading zeroes may be omitted). To continue the above example, the following
assigns class ID 1:2 to foobar cgroup:
<P>
<DL COMPACT><DT id="4"><DD>
echo 0x10002 &gt; /sys/fs/cgroup/net_cls/foobar/net_cls.classid
</DL>
<P>
Finally some PIDs can be assigned to the given cgroup:
<P>
<DL COMPACT><DT id="5"><DD>
echo 1234 &gt; /sys/fs/cgroup/net_cls/foobar/tasks
echo 5678 &gt; /sys/fs/cgroup/net_cls/foobar/tasks
</DL>
<P>
Now by simply attaching a
<B>cgroup</B>
filter to a
<B>qdisc</B>
makes packets from PIDs 1234 and 5678 be pushed into class 1:2.
<P>
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?8+tc">tc</A></B>(8),
<B><A HREF="/cgi-bin/man/man2html?8+tc-ematch">tc-ematch</A></B>(8),
<BR>
the file
<I>Documentation/cgroups/net_cls.txt</I>
of the Linux kernel tree
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="9"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="10"><A HREF="#lbAF">EXAMPLES</A><DD>
<DT id="11"><A HREF="#lbAG">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:06:17 GMT, March 31, 2021
</BODY>
</HTML>