[PATCH] net/sched: choke: trim backlog when the limit shrinks

From: Samuel Moelius

Date: Mon Jun 08 2026 - 20:10:26 EST


CHOKE accepts a new packet limit that is smaller than the current queue
length without trimming the existing backlog. The queue can remain
above its hard limit until later enqueue and dequeue activity eventually
brings it down.

Userspace expects a reduced limit to take effect immediately.

Drop excess packets when a configured CHOKE limit is reduced below the
current queue length.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@xxxxxxxxxxxxxxx>
---
net/sched/sch_choke.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index 2875bcdb18a4..c355c7a05da3 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -371,7 +371,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt,
return -EINVAL;

mask = roundup_pow_of_two(ctl->limit + 1) - 1;
- if (mask != q->tab_mask) {
+ if (mask != q->tab_mask || sch->q.qlen > ctl->limit) {
struct sk_buff **ntab;

ntab = kvzalloc_objs(struct sk_buff *, mask + 1);
@@ -390,7 +390,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt,
q->head = (q->head + 1) & q->tab_mask;
if (!skb)
continue;
- if (tail < mask) {
+ if (tail < ctl->limit) {
ntab[tail++] = skb;
continue;
}
--
2.43.0