Deleting the TC Filter Using the filter generation rules will clear all filters.
The correct method is mentioned on the mail list.
Unlike the class, you can simply replace add in the TC command with Del if you want to delete it after adding it. If the class is repeated, it will be prompted like an error occurs when adding a route.
But the filters are different. Filters with the same rules can be continuously added. After the rules are added, the kernel will use different handle numbers to distinguish them,
Delete a filter. You cannot simply replace the Add rule with Del. This will delete all filter rules, because you do not provide the most important handle number (handle) if no rule is provided, if 0 is 0, all rules will be deleted.
You must at least provide the following:
Dev
Parent (qdisc or Class)
Prio
Kind (filter type)
Handle
If a filter has been associated with a class, you will receive the prompt rtnetlink answers: device or resource busy if you delete this class.
Therefore, before deleting a class rule, you must first Delete the filter associated with this class. The following is an implementation of mine ($ id represents the class rule ID number)
handles=`tc filter list dev ${dev} |grep "flowid 1:${id}"|awk '{print $10}'`for handle in $handlesdotc filter delete dev ${dev} parent 1: protocol ip prio 1 handle ${handle} u32done
Use a loop because the filter may have multiple associated classes.
Author info:
From: Delete the filter of TC correctly.
URL: http://ihipop.info/2011/06/2471.html
Please reserve this link, thanks!
This work is licensed using the knowledge sharing signature-non-commercial use of the 3.0 unported license agreement.