应用 Linux tc、u32 过滤器掩码时出现非法“匹配”错误

应用 Linux tc、u32 过滤器掩码时出现非法“匹配”错误

我想对基于 TOS 的流量整形应用以下规则。所有规则均有效,但屏蔽 IP 标头的最终规则显示非法“匹配”错误

sudo tc qdisc del dev tun0 root handle 1: htb default 10
sudo tc qdisc add dev tun0 root handle 1: htb default 10
sudo tc filter add dev tun0 parent 1: prio 99 handle 1: u32 divisor 16
alias tclass='sudo tc class add dev tun0 parent 1:1'
tclass classid 1:16 htb rate 50kbit ceil 50kbit prio 1
tclass classid 1:10 htb rate 90mbit ceil 95mbit prio 2
tclass classid 1:12 htb rate 1mbit ceil 1mbit prio 3
sudo tc qdisc add dev tun0 parent 1:16 sfq perturb 60
sudo tc qdisc add dev tun0 parent 1:10 sfq perturb 60
sudo tc qdisc add dev tun0 parent 1:12 sfq perturb 60
alias tcfilter='sudo tc filter add dev tun0 parent 1: prio 99'
tcfilter u32 match u8 0 0 ht 1:0: classid 1:16
tcfilter u32 match u8 0 0 ht 1:1: classid 1:16
tcfilter u32 match u8 0 0 ht 1:2: classid 1:16
tcfilter u32 match u8 0 0 ht 1:3: classid 1:16
tcfilter u32 match u8 0 0 ht 1:4: classid 1:12
tcfilter u32 match u8 0 0 ht 1:5: classid 1:12
tcfilter u32 match u8 0 0 ht 1:6: classid 1:12
tcfilter u32 match u8 0 0 ht 1:7: classid 1:12
tcfilter u32 match u8 0 0 ht 1:8: classid 1:16
tcfilter u32 match u8 0 0 ht 1:9: classid 1:16
tcfilter u32 match u8 0 0 ht 1:a: classid 1:16
tcfilter u32 match u8 0 0 ht 1:b: classid 1:16
tcfilter u32 match u8 0 0 ht 1:c: classid 1:10
tcfilter u32 match u8 0 0 ht 1:d: classid 1:10
tcfilter u32 match u8 0 0 ht 1:e: classid 1:10
tcfilter u32 match u8 0 0 ht 1:f: classid 1:10
# up to this all commands work. But following command doesn't works
sudo tc filter add dev tun0 parent 1: prio 1 protocol ip u32 \
        link 1: hashkey mask 0x001e0000 match u8 0 0
Illegal "match"

更新 通过将所有指令放在一行中解决了该问题:

sudo tc filter add dev tun0 parent 1: prio 1 protocol ip u32 link 1: hashkey mask 0x001e0000 match u8 0 0

相关内容