8

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.

Neal
  • 270
  • 1
  • 2
  • 7

2 Answers2

5

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.

poige
  • 9,171
  • 2
  • 24
  • 50
Jak
  • 998
  • 9
  • 12
0

from the source /net/sched/cls_api.c it follows that one workaround is to use prio != 0

    if (prio == 0 && (protocol || t->tcm_handle || tca[TCA_KIND])) {
    NL_SET_ERR_MSG(extack, "Cannot flush filters with protocol, handle or kind set");
    return -ENOENT;
}