Linux – deleting filters in tc

linuxnetworkingroutingtctraffic-shaping

I have added a filter in tc as follows:

tc filter add dev eth0 parent 1: protocol ip handle 6 fw flowid 1:6

This should be sending packets marked by iptables with '–set-mark 6' to class 1:6. The problem is, I can't figure out how to later delete this filter. Replacing 'add' with 'delete' doesn't work, I get a 'RTNETLINK answers: No such file or directory' error message. I've tried a number of other combinations to delete it, but none seem to work.

Thanks for any help.

Best Answer

The thing is when you issue filter add w/o exact preference/priority number, it gets assigned automatically, you can see it with:

tc filter show dev eth0

and it would get deleted as easy as

tc filter del dev eth0 prio nUmErIc

If you need more control you have to specify 'prio' exactly:

tc filter add dev eth0 parent 1: protocol ip prio 1 handle 6 fw flowid 1:6

In this way it's up to either you repeat all the gory details to remove filter or just use the former way.