]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: sched: cls_api: introduce tc_cls_bind_class() helper
authorZhengchao Shao <shaozhengchao@huawei.com>
Tue, 27 Sep 2022 12:48:54 +0000 (20:48 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 2 Oct 2022 15:07:17 +0000 (16:07 +0100)
All the bind_class callback duplicate the same logic, this patch
introduces tc_cls_bind_class() helper for common usage.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/pkt_cls.h

index d376c995d906953d5d4f180e05aa020c66cd4149..4cabb32a2ad944a22c2f19898499649b2d8f9347 100644 (file)
@@ -210,6 +210,18 @@ tcf_unbind_filter(struct tcf_proto *tp, struct tcf_result *r)
        __tcf_unbind_filter(q, r);
 }
 
+static inline void tc_cls_bind_class(u32 classid, unsigned long cl,
+                                    void *q, struct tcf_result *res,
+                                    unsigned long base)
+{
+       if (res->classid == classid) {
+               if (cl)
+                       __tcf_bind_filter(q, res, base);
+               else
+                       __tcf_unbind_filter(q, res);
+       }
+}
+
 struct tcf_exts {
 #ifdef CONFIG_NET_CLS_ACT
        __u32   type; /* for backward compat(TCA_OLD_COMPAT) */