2

I have a tc filter rule:

tc filter add dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.3 flowid 1:14

if I try to 'change' this filter rule I get an error:

# tc filter change dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.2 flowid 1:14
# RTNETLINK answers: No such file or directory
# We have an error talking to the kernel

'replace' adds a new, but don't remove the old rule.

is the syntax of the replace/change command correct?

CentOS 6.4 iptables-1.4.7-9.el6.x86_64 iproute-2.6.32-23.el6.x86_64

a full script:

tc qdisc add dev eth0 root handle 1: htb

tc class add dev eth0 parent 1: classid 1:1 htb rate 1000Mbps

tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100Mbps
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 100Mbps
tc class add dev eth0 parent 1:1 classid 1:13 htb rate 100Mbps
tc class add dev eth0 parent 1:1 classid 1:14 htb rate 100Mbps

tc qdisc add dev eth0 parent 1:11 handle 10: netem delay 0ms
tc qdisc add dev eth0 parent 1:12 handle 20: netem delay 500ms
tc qdisc add dev eth0 parent 1:13 handle 30: netem delay 1000ms
tc qdisc add dev eth0 parent 1:14 handle 40: netem delay 1500ms

tc filter add dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.3 flowid 1:11
tc filter add dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.8 flowid 1:12
tc filter add dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.9 flowid 1:13
tc filter add dev eth0 protocol ip prio 1 u32 match ip dst 10.0.0.7 flowid 1:14
user174704
  • 33
  • 1
  • 5

1 Answers1

2

I think you have to use handle for that, like this:

sudo tc filter change dev eth0 pref 1 protocol ip handle 800::800 u32 match ip dst 10.0.0.5 flowid 1:15

— this way I can issue the same command with different ip dst and it applies successfully.

P. S. Handles are shown with tc show, or, I believe you can specify them when adding rules for the first time.

poige
  • 9,448
  • 2
  • 25
  • 52
  • thx @poige, it works now if I specify handle. I can modify only a filter parameters, not the match, right? `tc filter replace dev eth0 protocol ip prio 1 handle 800::807 u32 match ip dst 1.1.1.2 match ip dport 53 0xffff flowid 1:14` - doesn't change the IP address in the match expression. – user174704 May 22 '13 at 14:26