🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5589

[PATCH net-next v8 0/4] net/sched: cap the accounted backlog before it can wrap

#5589
From: Jamal Hadi Salim
Date: Tue, 20 Oct 2026 16:57
124 lines
17203 bytes
This series bounds the accounted backlog of the AQM qdiscs so that it
cannot wrap mod 2^32.

v1 widened the counters to u64 and was rejected; from v2 on the fix drops
at enqueue instead. The v5 posting was a single patch; at the reviewer's
request it is split into four:

  1/4  cake: classifier refactor: cake_tcf_classify() returns its result
       to the caller.
  2/4  cake: use a dedicated split-GSO list iterator.
  3/4  the fix: drop at enqueue once the stored backlog cannot
       represent the packet's accounted length -- the standing
       QDISC_MAX_BACKLOG ceiling for ordinary packets, a per-packet
       representability check for the larger wire estimates. Covers
       fq_codel, cake, codel, pie, fq_pie, dualpi2, RED, pfifo, plug
       and gred.
  4/4  cake: split cake_hash() into side-effect-free key extraction (on
       the unsegmented skb) and set-associative resolution (after
       admission), move the split-GSO path ahead of the resolution, and
       tag every deferred split segment.

The commit logs and the in-code comments are written for readability.

The guard half is a net fix, but the CAKE hash split is new-code net-next
material, so the series targets net-next with no Fixes: (the aggregate
wrap predates every touched qdisc).

Changes in v8:
  - 1/4 is cake-only. fq_codel_classify() is line-for-line the same as
    fq_pie_classify(), and fq_pie is not changed by this series, so the
    two stay in lockstep: fq_codel keeps its original classify shape and
    the fq_codel backlog guard is placed inline in its enqueue path
    (3/4) instead. (Toke Høiland-Jørgensen)
  - 3/4: the fq_codel guard sits between idx-- and
    codel_set_enqueue_time(), so a dropped packet cannot touch flow
    state. The commit message is reworded as suggested. (Toke
    Høiland-Jørgensen)
  - 4/4: the original skb is consumed unconditionally right after a
    successful split -- that is the caller's reference, since a fraglist
    GSO takes the list's own reference on the same skb in
    skb_segment_list() -- so the reject branch tags every deferred
    segment and drops the whole list with qdisc_drop_all(), and the
    admitted path no longer consumes the skb after the walk. (Toke
    Høiland-Jørgensen)

Changes in v7:
  - 1/4: complete the fq_codel_classify() comment (Sashiko nipa v6
    main-2-1, Low). The comment listed only the terminal-action and
    no-class-ID cases; the function also returns true when no filter
    matched or when the selected class minor is above q->flows_cnt,
    and those packets are BYPASS drops, not a fallback to hashing as
    in cake. Comment-only, no code change; folded into this resend
    since the series is revised anyway.
  - 3/4: do not clamp the shared qdisc_pkt_len() (Sashiko nipa v6
    main-2-6, Medium). The clamp silently undercharged BPF
    __sk_buff.wire_len, act_police and the HTB/TBF shapers for a valid
    large GSO estimate. The initializer now stays truthful for every
    input and the overflow protection is enqueue admission: each
    affected qdisc drops a packet once the stored backlog cannot
    represent its accounted length -- the standing QDISC_MAX_BACKLOG
    ceiling covers ordinary packets, and a per-packet representability
    check covers the larger wire estimates, which a supported
    small-MSS BIG TCP aggregate can legitimately carry above 1 MiB
    while its raw length stays within GSO_MAX_SIZE. The consumers read
    the real length, and sch_handle_ingress() keeps complete pkt_segs
    metadata.
  - 4/4: tag every deferred split-GSO segment with QDISC_DROP_OVERLIMIT
    (Sashiko nipa v6 gpt-6-astra-2-5, Medium). __skb_gso_segment() stores
    SKB_GSO_CB at cb offset 32, aliasing tc_skb_cb.drop_reason, and the cb
    is copied into every segment, so tagging only the head left the rest
    with GSO scratch as their drop reason.
  - 4/4: snapshot q->config->flow_mode once with READ_ONCE() and pass it
    to both hash helpers (Sashiko nipa v6 gpt-6-astra-5-9, Low). The split
    introduced two loads with the segmentation work between them.
  - Not folded: the 3/4 intermediate-commit split-GSO limitation (4/4
    closes it; the pre-series path was already unbounded) and the
    Fixes:/stable suggestions (intentional net-next target). The gemini
    v6 TC_ACT_CONSUMED High is the v5 finding already rebutted as
    unreachable from a qdisc classify switch.

v6  rewrite as a four-patch series per Toke Høiland-Jørgensen's review of
    v5 (split the classifier refactor, the split-GSO iterator, the
    overflow guard and the cake hash split; drop the machine-written
    prose). Considered the Sashiko gemini v5 TC_ACT_CONSUMED report and
    did not fold it (unreachable; see below). Reworded the cake block
    comment that had an embedded "/*" (Simon Horman's W=1 warning) and
    reworded a comment that overstated the classifier's return cases. The
    TC_ACT_CONSUMED switch case was dropped from the final 0001 because it
    still reached __qdisc_drop(); no in-tree producer can deliver
    TC_ACT_CONSUMED to a qdisc classify switch (act_ct returns it only on
    a clsact/ingress qdisc, act_mirred only for a non-cloning ingress
    redirect, and cls_bpf/act_bpf remap an unknown verdict to UNSPEC).

v5/v4/v3/v2 history: see the v6 posting. In short, v3 adopted the stored
    backlog compare qdisc_backlog_at_max() (no double-count of the 1 MiB
    headroom, no per-enqueue 64-bit add), moved the classifier and the
    ceiling check ahead of the hash/shaper state, and added pfifo; v4
    split the hash keys from the set-associative resolution and handled
    the fraglist-GSO self-link; v2 replaced the rejected u64 widening with
    the enqueue drop; v1 widened the counters.

Jamal Hadi Salim (4):
  net/sched: cake: return the classifier result to the caller
  net/sched: cake: use a dedicated split-GSO list iterator
  net/sched: cap the accounted backlog before it can wrap
  net/sched: cake: hash before segmenting and reject an overlong split

 include/net/pkt_sched.h   |   1 -
 include/net/sch_generic.h |  20 +++++
 net/sched/sch_cake.c      | 177 +++++++++++++++++++++++++++-----------
 net/sched/sch_codel.c     |  16 ++--
 net/sched/sch_dualpi2.c   |   1 +
 net/sched/sch_fifo.c      |   6 ++
 net/sched/sch_fq_codel.c  |   9 ++
 net/sched/sch_fq_pie.c    |   3 +-
 net/sched/sch_gred.c      |   9 ++
 net/sched/sch_pie.c       |   3 +-
 net/sched/sch_plug.c      |   9 +-
 net/sched/sch_red.c       |  23 +++--
 12 files changed, 209 insertions(+), 68 deletions(-)

-- 
2.43.0
Technical Details
Message-ID: <QDISC-BA27.v8.r0.20261020063241@mojatatu.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349405-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349405-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v8 0/4] net/sched: cap the accounted backlog before it can wrap
Date: Tue, 20 Oct 2026 12:57:26 -0400
Organization: Usenet Network
Message-ID: <QDISC-BA27.v8.r0.20261020063241@mojatatu.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3901867"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rWMT6DLz7AjaDg53549sQJsBNtE= sha256:OrbdaN4QJsplHeM5yldgGlcnx4bQoD3kfHbndyoH2Kk=
	sha1:rIx9GwbYvYiqYypTFKk9qWSq6Wg= sha256:3Y7zoLf3ckQFlRMQvDmLJAlSpHLcpf5jPIGGxQwigX0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id BCEED110D84; Tue, 20 Oct 2026 20:02:15 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=mojatatu.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id O12bp8tW2FlR;
	Tue, 20 Oct 2026 20:02:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-349405-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id CBACE110C79; Tue, 20 Oct 2026 20:02:01 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 266F560964A; Tue, 20 Oct 2026 16:57:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792515458;
	b=ZqBUYE5Z8tP3VKQk+0oNVhrafw01JBHqb/OJaDp+NRAl+Uj9bvfKe3nMHMqHGAMIJ6Qi
	 w6lA4gDh+nbmiI9pLbNntHty9aQBYCjJhEGhvjpyP+3V+eRnd9c658jFshAad8Ktbz9lk
	 ZPWel9qHygJjfB5lgRWirF0FeXsBh0hGNjMKZVO2djzKObRdXGAFoEtxG6rMPzUX0SgU2
	 FxWDLd3sKX4PyxuoOXf/PzhD5Elq6JMr9MHwZzXJhOc7uzq7XH7fwh2g+E8+zuOkhI7dO
	 T1FzN/gB5t0YT1lbz3UuhD/2Rn3MkFB7VKRU/tc0IRKzliWoibkbo3wT4D/yjkKCzjg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792515458;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=JHEt6N5Ticf96mw5x9ZzEm52SQKQT8zrU+XA8kvKCYM=;
	b=jjguAIwBRLzQcJAD0fR9xbO83anIW1QZi2SE+0l50XVFNS7sMUqxA45ZqqxM/Oth3vOp
	 rOpBCiOL0bH33HxznRzJT/FtPHJCU5UwRTC34CKT7pb6L9SWkbPjTCrC7NqmMSZKO7nn2
	 iI3fdTIGBUnPeFQ6S01vz8Nu42tXMdzF/uvHpW3jnz8xUjwqvSPIXg0zx5fur/GWkJXiq
	 4HoFfNYOnbgho/yr7dXqudTLH+tB2/oTSAKol+mDkdybZMCf0UouEGCQYbW3fkj9/gYBz
	 ZnxFhsmjZEv+kPuabMswMyFgFpYQx8YFKwTlkME0nF5dC4kdIkoM+0ud+LH2sfxOCyg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=LL1tZR23;
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id DDD0C606A32E;
	Tue, 20 Oct 2026 16:57:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=LL1tZR23
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.42
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792515457;
	b=IZPNf71YL6qOw7ivGuu9xaulK7H4aMiAtFvYCpqPo1YDCDHP0PmwK7o6AOCpitRxpaXV
	 JDkA4Qqheb+Pa/GqbCH2JG70McVe6Hpz4Gj8VsQbH3xWQd2csmU7rAHgs6PBx+Gy1aXBv
	 oOImbsddlSIjmbY9C9puP+cBJT27Ezw/TeUg88+I+Qpi8oQq9/Ok7DTYbKmEuCYcIKZlr
	 BeVgGl58VHtN/5MOdZcotTOH2O0yS0MT4sZa+dakS8vRMyL9t9FqcGFs6PvxYSw7cA+aw
	 AAbEIS0oguNLPSrMvnxFXreUzCQ6gfBogtvRhXXzx58pmWIDU122AMY78UQJ66M4SHA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792515457;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-Id:X-Mailer:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=JHEt6N5Ticf96mw5x9ZzEm52SQKQT8zrU+XA8kvKCYM=;
	b=th8WvV+ewgTocNq/3pL5/d2o1+jWg6uXFSTG4tJT6sSyp0vrlfWah1xBOv61rtdsYGro
	 qkaLuvy+zPOoSPxh7x/pYuPT2dun6H/OI5O9AMwhW3xQDmr68v6nRISDXd2KXzBHviRhr
	 NadtqGrGxFwIktGFVtXYz8YAJ4UhmZj0korZJX9PwXrPr1QxlFGYwxa8lW9iKTTMyfotk
	 yglry7kwIJANYWiSwNfjQ5JBb/MFOd8+Zc1ZeYgosQUvkf5NgXwpPmY2SIWYnXlBT9yKm
	 Xv7KzeYfCjQB99dJ43hA5utLs/43LiIpczbBJ/Y2uYb+sMeLc4xVGxVgfR6VvgcSoiA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=mojatatu.com;
	spf=none smtp.mailfrom=mojatatu.com;
	dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=LL1tZR23;
	arc=none smtp.remote-ip=209.85.219.42
X-Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A38E606A320
	for <netdev@vger.kernel.org>; Tue, 20 Oct 2026 16:57:36 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4A38E606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-917866225aaso32579106d6.1
        for <netdev@vger.kernel.org>; Tue, 20 Oct 2026 09:57:36 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=mojatatu.com; s=google; t=1792515455; x=1793120255; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:mime-version:message-id:date
         :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=JHEt6N5Ticf96mw5x9ZzEm52SQKQT8zrU+XA8kvKCYM=;
        b=LL1tZR23b8WQlsx7F+v+5P4/QsK7so1JJg5oRbEte9SovoIxbcR3JIqNzYebDgRjXE
         FSTmMaCOmVUDgR5nNE9FOfcUHPmLiOxnAICjswnYPkli2ue1nKd2PHDxut4LdXGiexNK
         S9lNdxmhZypZPZNCW+t8CY6ba9QxrpTaqKNvo=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792515455; x=1793120255;
        h=content-transfer-encoding:content-type:mime-version:message-id:date
         :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=JHEt6N5Ticf96mw5x9ZzEm52SQKQT8zrU+XA8kvKCYM=;
        b=JptGYNY69qljLFTTPm7gzi6yGykCGJmhBVeLHIempZahVmCWuqmVI/1YOaAAKVjH75
         VH9r7pEFcujkEv1bTnaQ6TJMfn8mTgB/bR2f5OUfqK3gStby/1iXB8awwg6uyOoJaClY
         ExENoM7UlWsRv0fbBILg6ByFTcNJcW0wcwMV0+QF90UNrv38a4yV4Cc0XIM2q3RpUNxx
         v+5GIQ94fIn/jkWGy3g4pIfOBafeJUcHuLMhd9JkX95zK0jwVEEVhEc8GQSmlUrqk9F/
         CmALFXgDJJpc3gV42sgldqhrRgKMO8Vho/0wTkSfz3PLRQlOv7ZBdUMGKgaqW+zIjriw
         LVsg==
X-Gm-Message-State: AFq9FYIEZkmV8bXAHc46Bk7MEKJG1PqAvHIlI31fIWN9a9QCeUtf4Orp
	pSapwDX7drbWeZBAIZ1TUjPPkUbeSMNDXeg5mSCcly+MIHcQW+1fT7OvEM3EtPv8OTOO6rE8K9L
	hRIk=
X-Gm-Gg: AYBFou3BvRgzRmfsv50g1Cm/QWKJNfl43/Vo6Jen0p6O/X2UVxLV+nm+LcbRUZrtQnJ
	8rv6aD05w6v9jmfrSfPowRhLhLmKkBF7/BEK7cS2dkripYLZgIPuSd2sBKKCedDVduZvOR1hUdM
	j9O3wWIPk0W7RujPCD+PaYkLAa/ugWF4CFzDdh7xiDvsVREfvoEoqZU7CXA58GrVypzMCsrYeUz
	EG0TlMJ5iJGBJmpfg+URN/CMZAmaQBkhhHJwXSXyUiJAjErXA81WaqWGMOuDKeAR4yJQZ1/kqfb
	l0iUnjVv2MfZD4XcYpkabPbdHbfnwAye2ltpLIlYksVzqD+oqBRiWlnq9fcvCKlHYBFiBlCL7ws
	3U6oLHwpEqI1wHOhHdkJu3UkRjYMSeiWNqMsNyfMET++IXRbSWCT/P/KXD89pwQmyj67usl+qhW
	V8HvLYtPHcfLJJAXqe52Oe2+bTpeEgaUf/OR6T//+fvWpV/VKbf7PCGQ5bRQaIXCVW+aZsT8sxk
	PnlvwIlk83h8hXpvVVKLtjeqbdm3mIJUkLrLCwYHBbX
X-Received: by 2002:a05:6214:2f89:b0:91b:8d3b:7d44 with SMTP id 6a1803df08f44-91bdf0a1fc1mr203880666d6.19.1792515455088;
        Tue, 20 Oct 2026 09:57:35 -0700 (PDT)
X-Received: from mbili.waya ([64.203.83.2])
        by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91c10a441acsm3034586d6.6.2026.10.20.09.57.33
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Tue, 20 Oct 2026 09:57:34 -0700 (PDT)
X-Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Victor Nogueira <victor@mojatatu.com>,
	Toke Høiland-Jørgensen <toke@toke.dk>,
	Björn Töpel <bjorn@kernel.org>,
	cake@lists.bufferbloat.net,
	Sashiko <sashiko-bot@kernel.org>
X-Mailer: git-send-email 2.34.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list