blob: ec182346dea29b0f0304011092ff6133df0c88cb [file] [log] [blame]
Rami Rosen077f02f2013-04-08 04:04:20 +00001Network classifier cgroup
2-------------------------
3
4The Network classifier cgroup provides an interface to
5tag network packets with a class identifier (classid).
6
7The Traffic Controller (tc) can be used to assign
8different priorities to packets from different cgroups.
Daniel Borkmann82a37132013-12-29 18:27:12 +01009Also, Netfilter (iptables) can use this tag to perform
10actions on such packets.
Rami Rosen077f02f2013-04-08 04:04:20 +000011
12Creating a net_cls cgroups instance creates a net_cls.classid file.
13This net_cls.classid value is initialized to 0.
14
15You can write hexadecimal values to net_cls.classid; the format for these
16values is 0xAAAABBBB; AAAA is the major handle number and BBBB
17is the minor handle number.
18Reading net_cls.classid yields a decimal result.
19
20Example:
21mkdir /sys/fs/cgroup/net_cls
22mount -t cgroup -onet_cls net_cls /sys/fs/cgroup/net_cls
23mkdir /sys/fs/cgroup/net_cls/0
24echo 0x100001 > /sys/fs/cgroup/net_cls/0/net_cls.classid
25 - setting a 10:1 handle.
26
27cat /sys/fs/cgroup/net_cls/0/net_cls.classid
281048577
29
30configuring tc:
31tc qdisc add dev eth0 root handle 10: htb
32
33tc class add dev eth0 parent 10: classid 10:1 htb rate 40mbit
34 - creating traffic class 10:1
35
36tc filter add dev eth0 parent 10: protocol ip prio 10 handle 1: cgroup
Daniel Borkmann82a37132013-12-29 18:27:12 +010037
38configuring iptables, basic example:
39iptables -A OUTPUT -m cgroup ! --cgroup 0x100001 -j DROP