diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 58ea48e1221c5303c5dffc71c4077384988b9362..d5e7a1af346fe06b6ad8f8e091a3ad8a77e7d399 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -17,6 +17,7 @@ struct tcf_walker { int stop; int skip; int count; + bool nonempty; unsigned long cookie; int (*fn)(struct tcf_proto *, void *node, struct tcf_walker *); }; diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 6593c245f71427ab1976388e6689768012d5189c..97d9312c2ff90e2a907397fdeb9761e818d1ae2e 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -238,18 +238,23 @@ static void tcf_proto_put(struct tcf_proto *tp, bool rtnl_held, tcf_proto_destroy(tp, rtnl_held, extack); } -static int walker_noop(struct tcf_proto *tp, void *d, struct tcf_walker *arg) +static int walker_check_empty(struct tcf_proto *tp, void *d, + struct tcf_walker *arg) { - return -1; + if (tp) { + arg->nonempty = true; + return -1; + } + return 0; } static bool tcf_proto_is_empty(struct tcf_proto *tp, bool rtnl_held) { - struct tcf_walker walker = { .fn = walker_noop, }; + struct tcf_walker walker = { .fn = walker_check_empty, }; if (tp->ops->walk) { tp->ops->walk(tp, &walker, rtnl_held); - return !walker.stop; + return !walker.nonempty; } return true; }