Delete the filter of TC correctly

Source: Internet
Author: User

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.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.