From: Samuel Moelius <sam.moelius@trailofbits.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Samuel Moelius <sam.moelius@trailofbits.com>,
Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org (open list:TC subsystem),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] net/sched: codel: refresh CAN_BYPASS when limit changes
Date: Tue, 9 Jun 2026 00:12:14 +0000 [thread overview]
Message-ID: <20260609001013.1234755.d884b9e2028f.codel-limit-zero-bypass@trailofbits.com> (raw)
sch_codel and sch_fq_codel update their packet limit without refreshing
the queue bypass state. Changing the limit to zero can leave CAN_BYPASS
set from the previous configuration.
The enqueue path can then bypass limit enforcement even though the new
limit should prevent queued packets.
Recompute the bypass flag whenever the configured limit changes.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
net/sched/sch_codel.c | 17 ++++++++++++-----
net/sched/sch_fq_codel.c | 17 ++++++++++++-----
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/net/sched/sch_codel.c b/net/sched/sch_codel.c
index 317aae0ec7bd..b8de40e63822 100644
--- a/net/sched/sch_codel.c
+++ b/net/sched/sch_codel.c
@@ -97,6 +97,14 @@ static const struct nla_policy codel_policy[TCA_CODEL_MAX + 1] = {
[TCA_CODEL_CE_THRESHOLD]= { .type = NLA_U32 },
};
+static void codel_set_can_bypass(struct Qdisc *sch)
+{
+ if (sch->limit >= 1)
+ sch->flags |= TCQ_F_CAN_BYPASS;
+ else
+ sch->flags &= ~TCQ_F_CAN_BYPASS;
+}
+
static int codel_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
@@ -133,9 +141,11 @@ static int codel_change(struct Qdisc *sch, struct nlattr *opt,
((u64)interval * NSEC_PER_USEC) >> CODEL_SHIFT);
}
- if (tb[TCA_CODEL_LIMIT])
+ if (tb[TCA_CODEL_LIMIT]) {
WRITE_ONCE(sch->limit,
nla_get_u32(tb[TCA_CODEL_LIMIT]));
+ codel_set_can_bypass(sch);
+ }
if (tb[TCA_CODEL_ECN])
WRITE_ONCE(q->params.ecn,
@@ -176,10 +186,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,
return err;
}
- if (sch->limit >= 1)
- sch->flags |= TCQ_F_CAN_BYPASS;
- else
- sch->flags &= ~TCQ_F_CAN_BYPASS;
+ codel_set_can_bypass(sch);
sch->flags |= TCQ_F_DEQUEUE_DROPS;
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index 24db54684e8a..2695181cb046 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -364,6 +364,14 @@ static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = {
[TCA_FQ_CODEL_CE_THRESHOLD_MASK] = { .type = NLA_U8 },
};
+static void fq_codel_set_can_bypass(struct Qdisc *sch)
+{
+ if (sch->limit >= 1)
+ sch->flags |= TCQ_F_CAN_BYPASS;
+ else
+ sch->flags &= ~TCQ_F_CAN_BYPASS;
+}
+
static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
@@ -422,9 +430,11 @@ static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
(interval * NSEC_PER_USEC) >> CODEL_SHIFT);
}
- if (tb[TCA_FQ_CODEL_LIMIT])
+ if (tb[TCA_FQ_CODEL_LIMIT]) {
WRITE_ONCE(sch->limit,
nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]));
+ fq_codel_set_can_bypass(sch);
+ }
if (tb[TCA_FQ_CODEL_ECN])
WRITE_ONCE(q->cparams.ecn,
@@ -514,10 +524,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
codel_vars_init(&flow->cvars);
}
}
- if (sch->limit >= 1)
- sch->flags |= TCQ_F_CAN_BYPASS;
- else
- sch->flags &= ~TCQ_F_CAN_BYPASS;
+ fq_codel_set_can_bypass(sch);
sch->flags |= TCQ_F_DEQUEUE_DROPS;
--
2.43.0
next reply other threads:[~2026-06-09 0:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 0:12 Samuel Moelius [this message]
2026-06-10 3:28 ` Eric Dumazet
2026-06-10 19:02 ` Samuel Moelius
2026-06-28 13:59 ` Samuel Moelius
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260609001013.1234755.d884b9e2028f.codel-limit-zero-bypass@trailofbits.com \
--to=sam.moelius@trailofbits.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®