OSDN Git Service

net/sched: wrap open coded Qdics class filter counter
authorPedro Tammela <pctammela@mojatatu.com>
Fri, 28 Jul 2023 15:35:33 +0000 (12:35 -0300)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 1 Aug 2023 08:47:24 +0000 (10:47 +0200)
commit8798481b667fa7c9bbd5aa843bf1557ada699964
tree164b3ceb99342adfe3cfa8da837947ccfa784704
parent05e1d8bdb276068069d3de65e488700280029e20
net/sched: wrap open coded Qdics class filter counter

The 'filter_cnt' counter is used to control a Qdisc class lifetime.
Each filter referecing this class by its id will eventually
increment/decrement this counter in their respective
'add/update/delete' routines.
As these operations are always serialized under rtnl lock, we don't
need an atomic type like 'refcount_t'.

It also means that we lose the overflow/underflow checks already
present in refcount_t, which are valuable to hunt down bugs
where the unsigned counter wraps around as it aids automated tools
like syzkaller to scream in such situations.

Wrap the open coded increment/decrement into helper functions and
add overflow checks to the operations.

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/sch_generic.h
net/sched/sch_drr.c
net/sched/sch_hfsc.c
net/sched/sch_htb.c
net/sched/sch_qfq.c