Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[platform/kernel/linux-starfive.git] / net / sched / sch_hfsc.c
index 61d5259..3554085 100644 (file)
@@ -116,7 +116,6 @@ struct hfsc_class {
        struct net_rate_estimator __rcu *rate_est;
        struct tcf_proto __rcu *filter_list; /* filter list */
        struct tcf_block *block;
-       unsigned int    filter_cnt;     /* filter count */
        unsigned int    level;          /* class level in hierarchy */
 
        struct hfsc_sched *sched;       /* scheduler data */
@@ -1098,8 +1097,11 @@ hfsc_delete_class(struct Qdisc *sch, unsigned long arg,
        struct hfsc_sched *q = qdisc_priv(sch);
        struct hfsc_class *cl = (struct hfsc_class *)arg;
 
-       if (cl->level > 0 || cl->filter_cnt > 0 || cl == &q->root)
+       if (cl->level > 0 || qdisc_class_in_use(&cl->cl_common) ||
+           cl == &q->root) {
+               NL_SET_ERR_MSG(extack, "HFSC class in use");
                return -EBUSY;
+       }
 
        sch_tree_lock(sch);
 
@@ -1227,7 +1229,7 @@ hfsc_bind_tcf(struct Qdisc *sch, unsigned long parent, u32 classid)
        if (cl != NULL) {
                if (p != NULL && p->level <= cl->level)
                        return 0;
-               cl->filter_cnt++;
+               qdisc_class_get(&cl->cl_common);
        }
 
        return (unsigned long)cl;
@@ -1238,7 +1240,7 @@ hfsc_unbind_tcf(struct Qdisc *sch, unsigned long arg)
 {
        struct hfsc_class *cl = (struct hfsc_class *)arg;
 
-       cl->filter_cnt--;
+       qdisc_class_put(&cl->cl_common);
 }
 
 static struct tcf_block *hfsc_tcf_block(struct Qdisc *sch, unsigned long arg,