{
    "mode": "man",
    "parameter": "tc-cgroup",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/tc-cgroup/8/json",
    "generated": "2026-07-05T16:03:32Z",
    "synopsis": "tc filter ... cgroup [ match EMATCHTREE ] [ action ACTIONSPEC ]",
    "sections": {
        "NAME": {
            "content": "cgroup - control group based traffic control filter\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "tc filter ... cgroup [ match EMATCHTREE ] [ action ACTIONSPEC ]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This  filter  serves  as a hint to tc that the assigned class ID of the netcls control group\nthe process the packet originates from belongs to should be used  for  classification.  Obvi‐\nously, it is useful for locally generated packets only.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "action ACTIONSPEC\nApply an action from the generic actions framework on matching packets.\n\nmatch EMATCHTREE\nMatch packets using the extended match infrastructure. See tc-ematch(8) for a detailed\ndescription of the allowed syntax in EMATCHTREE.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "In order to use this filter, a netcls control group has to be created  first  and  class  as\nwell as process ID(s) assigned to it. The following creates a netcls cgroup named \"foobar\":\n\nmodprobe clscgroup\nmkdir /sys/fs/cgroup/netcls\nmount -t cgroup -onetcls netcls /sys/fs/cgroup/netcls\nmkdir /sys/fs/cgroup/netcls/foobar\n\nTo  assign  a  class ID to the created cgroup, a file named netcls.classid has to be created\nwhich contains the class ID to be assigned as a hexadecimal, 64bit  wide  number.  The  upper\n32bits are reserved for the major handle, the remaining hold the minor. So a class ID of e.g.\nff:be has to be written like so: 0xff00be (leading zeroes may be omitted).  To  continue  the\nabove example, the following assigns class ID 1:2 to foobar cgroup:\n\necho 0x10002 > /sys/fs/cgroup/netcls/foobar/netcls.classid\n\nFinally some PIDs can be assigned to the given cgroup:\n\necho 1234 > /sys/fs/cgroup/netcls/foobar/tasks\necho 5678 > /sys/fs/cgroup/netcls/foobar/tasks\n\nNow  by  simply attaching a cgroup filter to a qdisc makes packets from PIDs 1234 and 5678 be\npushed into class 1:2.\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "tc(8), tc-ematch(8),\nthe file Documentation/cgroups/netcls.txt of the Linux kernel tree\n\n\n\niproute2                                     21 Oct 2015                  Cgroup classifier in tc(8)",
            "subsections": []
        }
    },
    "summary": "cgroup - control group based traffic control filter",
    "flags": [],
    "examples": [
        "In order to use this filter, a netcls control group has to be created  first  and  class  as",
        "well as process ID(s) assigned to it. The following creates a netcls cgroup named \"foobar\":",
        "modprobe clscgroup",
        "mkdir /sys/fs/cgroup/netcls",
        "mount -t cgroup -onetcls netcls /sys/fs/cgroup/netcls",
        "mkdir /sys/fs/cgroup/netcls/foobar",
        "To  assign  a  class ID to the created cgroup, a file named netcls.classid 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.",
        "ff:be has to be written like so: 0xff00be (leading zeroes may be omitted).  To  continue  the",
        "above example, the following assigns class ID 1:2 to foobar cgroup:",
        "echo 0x10002 > /sys/fs/cgroup/netcls/foobar/netcls.classid",
        "Finally some PIDs can be assigned to the given cgroup:",
        "echo 1234 > /sys/fs/cgroup/netcls/foobar/tasks",
        "echo 5678 > /sys/fs/cgroup/netcls/foobar/tasks",
        "Now  by  simply attaching a cgroup filter to a qdisc makes packets from PIDs 1234 and 5678 be",
        "pushed into class 1:2."
    ],
    "see_also": [
        {
            "name": "tc",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc/8/json"
        },
        {
            "name": "tc-ematch",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc-ematch/8/json"
        },
        {
            "name": "tc",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tc/8/json"
        }
    ]
}