From: "Matthew Wilcox (Oracle)" <wi...@infradead.org>

Propagate the skip_hw flag from the cls_bpf_prog structure into one of
the XArray mark bits which lets us skip examining the unwanted programs.

Signed-off-by: Matthew Wilcox (Oracle) <wi...@infradead.org>
---
 net/sched/cls_bpf.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 295baabdc683..4dcab41b25b5 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -33,6 +33,8 @@ struct cls_bpf_head {
        struct rcu_head rcu;
 };
 
+#define HW_FILTER      XA_MARK_1
+
 struct cls_bpf_prog {
        struct bpf_prog *filter;
        struct tcf_result res;
@@ -505,6 +507,11 @@ static int cls_bpf_change(struct net *net, struct sk_buff 
*in_skb,
                tcf_queue_work(&oldprog->rwork, cls_bpf_delete_prog_work);
        }
 
+       if (!tc_skip_hw(prog->gen_flags))
+               xa_set_mark(&head->progs, prog->handle, HW_FILTER);
+       else if (oldprog)
+               xa_clear_mark(&head->progs, prog->handle, HW_FILTER);
+
        *arg = prog;
        return 0;
 
@@ -648,10 +655,7 @@ static int cls_bpf_reoffload(struct tcf_proto *tp, bool 
add, flow_setup_cb_t *cb
        unsigned long handle;
        int err;
 
-       xa_for_each(&head->progs, handle, prog) {
-               if (tc_skip_hw(prog->gen_flags))
-                       continue;
-
+       xa_for_each_marked(&head->progs, handle, prog, HW_FILTER) {
                tc_cls_common_offload_init(&cls_bpf.common, tp, prog->gen_flags,
                                           extack);
                cls_bpf.command = TC_CLSBPF_OFFLOAD;
-- 
2.23.0.rc1

Reply via email to