Show Table of Contents
A.9. net_prio
网络优先权(
net_prio
)子系统可以为各个 cgroup 中的应用程序动态配置每个网络接口的流量优先级。网络优先级是一个分配给网络流量的数值,可在系统内部和网络设备间使用。网络优先级用来区分发送、排队以及丢失的数据包。可使用 tc
命令设定网络优先级(使用 tc
命令设定网络优先权的方法将不在本指南中介绍,详情请参考 tc
manual page)。
通常程序会使用
SO_PRIORITY
插槽选项设定其流量的优先级。但应用程序常常没有设定优先级数值的代码,或者程序的流量是特定的,并且不提供确定的优先级。
在 cgroup 中使用
net_prio
子系统可让管理员将某个进程分配给具体的 cgroup,该 cgroup 会为指定网络接口的传出流量定义优先级。
- net_prio.prioidx
- 只读文件。它包含一个特有整数值,kernel 使用该整数值作为这个 cgroup 的内部代表。
- net_prio.ifpriomap
- 包含优先级图谱,这些优先级被分配给源于此群组进程的流量以及通过不同接口离开系统的流量。该图用
<network_interface> <priority>
的形式以成对列表表示:~]#
cat /cgroup/net_prio/iscsi/net_prio.ifpriomap
eth0 5 eth1 4 eth2 6net_prio.ifpriomap
文件的目录可以使用上述格式,通过将字符串回显至文件的方式来修改。例如:~]#
echo "eth0 5" > /cgroup/net_prio/iscsi/net_prio.ifpriomap
上述指令将强制设定任何源于iscsi
net_prio
cgroup 进程的流量和eth0
网络接口传出的流量的优先级为5
。父 cgroup 也有可写入的net_prio.ifpriomap
文件,可以设定系统默认优先级。
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.