【问题标题】:cgroups and tc/netem: Not sure how to make them work togethercgroups 和 tc/netem:不知道如何让它们一起工作
【发布时间】:2014-05-19 07:44:20
【问题描述】:

我在使用 cgroupstc 时遇到问题。

我正在尝试为特定进程添加延迟。下面的代码不起作用。但我不知道哪里出了问题(甚至什么是对的)。

# Set up net_cls to make 
modprobe cls_cgroup
mount -t cgroup -o net_cls none /sys/fs/cgroup/net_cls

# Create a new CGroup called 'high-latency'
mkdir /sys/fs/cgroup/high-latency
# All packets originating from this CG have their packers
# marked as class 1:11 / 0x1_0011
echo 0x100011 > /sys/fs/cgroup/high-latency/net_cls.classid

# Delete old rules, just in case
tc qdisc del dev eth0 root

# New root
tc qdisc add dev eth0 handle 1: root htb
# Class for filtered packets 1:11 == 0x10011
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100Mbps
# Apply delay to class 1:11
tc qdisc add dev eth0 parent 1:11 handle 10: netem delay 1000ms

# Don't understand this line at all! Why does tc need to know
# about 'cgroup', when net_cls is already putting them in class 1:11
tc filter add dev eth0 parent 1:11 protocol ip prio 10 handle 1: cgroup

# Add my process to the cgroup
echo 1234 > /sys/fs/cgroup/high-latency/tasks

另外一个有趣的是,运行这个之后,cat /sys/fs/cgroup/high-latency/tasks 打印一大堆进程(全部?),包括 pid 1。

知道我做错了什么,更重要的是 - 在尝试使用 tc 和 cgroups 时我可以使用哪些调试工具?

【问题讨论】:

    标签: linux trafficshaping cgroups


    【解决方案1】:

    不能一起工作。 您可以通过cgroup 对数据包进行分类,然后需要通过netfilter 将流量重定向到网络接口。

    【讨论】:

      猜你喜欢
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-09
      • 2010-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多