added support for cgroup based classification
This commit is contained in:
parent
8adc97b67c
commit
ce2de9f27b
2 changed files with 25 additions and 2 deletions
23
tc-cgroup.sh
Executable file
23
tc-cgroup.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Make sure only root can run our script
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "/sys/fs/cgroup/net_prio" ]; then
|
||||
echo "Your kernel needs to have the cls_prio cgroup loaded!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "/sys/fs/cgroup/net_prio/netem" ]; then
|
||||
cgcreate -g net_prio:netem
|
||||
|
||||
for i in $(ls /sys/class/net/);
|
||||
do
|
||||
echo "$i 15" > /sys/fs/cgroup/net_prio/netem/net_prio.ifpriomap
|
||||
done
|
||||
fi
|
||||
|
||||
cgexec -g net_prio:netem $@
|
4
tc.c
4
tc.c
|
@ -34,7 +34,7 @@ int tc_prio(struct nl_sock *sock, struct rtnl_link *link, struct rtnl_tc **tc)
|
|||
{
|
||||
/* This is the default priomap +1 for every entry.
|
||||
* The first band (value == 0) with the highest priority is reserved for the netem traffic */
|
||||
uint8_t map[] = { 2, 3, 3, 3, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 };
|
||||
uint8_t map[] = { 2, 3, 3, 3, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0 };
|
||||
|
||||
struct rtnl_qdisc *q = rtnl_qdisc_alloc();
|
||||
|
||||
|
@ -44,7 +44,7 @@ int tc_prio(struct nl_sock *sock, struct rtnl_link *link, struct rtnl_tc **tc)
|
|||
rtnl_tc_set_kind(TC_CAST(q), "prio");
|
||||
|
||||
rtnl_qdisc_prio_set_bands(q, 3+1);
|
||||
rtnl_qdisc_prio_set_priomap(q, map, sizeof(map) / sizeof(map[0]));
|
||||
rtnl_qdisc_prio_set_priomap(q, map, 7);
|
||||
|
||||
int ret = rtnl_qdisc_add(sock, q, NLM_F_CREATE);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue