{"id":3434,"date":"2022-12-20T17:02:40","date_gmt":"2022-12-20T20:02:40","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/cgroup-classifier-in-tc-man8\/"},"modified":"2022-12-20T17:02:40","modified_gmt":"2022-12-20T20:02:40","slug":"cgroup-classifier-in-tc-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/cgroup-classifier-in-tc-man8\/","title":{"rendered":"Cgroup classifier in tc (man8)"},"content":{"rendered":"<h1 align=\"center\">Cgroup classifier in tc<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">cgroup \u2212 control group based traffic control filter<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc filter<\/b> &#8230; <b>cgroup<\/b> [ <b>match<\/b> <i>EMATCH_TREE<\/i> ] [ <b>action<\/b> <i>ACTION_SPEC<\/i> ]<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>action<\/b> <i>ACTION_SPEC<\/i><\/p>\n<p style=\"margin-left:22%;\">Apply an action from the generic actions framework on matching packets.<\/p>\n<p style=\"margin-left:11%;\"><b>match<\/b> <i>EMATCH_TREE<\/i><\/p>\n<p style=\"margin-left:22%;\">Match packets using the extended match infrastructure. See <b>tc-ematch<\/b>(8) for a detailed description of the allowed syntax in <i>EMATCH_TREE<\/i>.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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 &#8220;foobar&#8221;:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">modprobe cls_cgroup <br \/> mkdir \/sys\/fs\/cgroup\/net_cls <br \/> mount -t cgroup -onet_cls net_cls \/sys\/fs\/cgroup\/net_cls <br \/> mkdir \/sys\/fs\/cgroup\/net_cls\/foobar<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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>\n<p style=\"margin-left:22%; margin-top: 1em\">echo 0x10002 > \/sys\/fs\/cgroup\/net_cls\/foobar\/net_cls.classid<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Finally some PIDs can be assigned to the given cgroup:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">echo 1234 > \/sys\/fs\/cgroup\/net_cls\/foobar\/tasks <br \/> echo 5678 > \/sys\/fs\/cgroup\/net_cls\/foobar\/tasks<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tc<\/b>(8), <b>tc-ematch<\/b>(8), <br \/> the file <i>Documentation\/cgroups\/net_cls.txt<\/i> of the Linux kernel tree<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  cgroup \u2212 control group based traffic control filter <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,560],"class_list":["post-3434","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-cgroup"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3434"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3434\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}