[Patch net v6 0/8] netem: Fix skb duplication logic and prevent infinite loops

Cong Wang
2025-12-27T19:41:38Z

This patchset fixes the infinite loops due to duplication in netem, the
real root cause of this problem is enqueuing to the root qdisc, which is
now changed to enqueuing to the same qdisc. This is more reasonable,
more intuitive from users' perspective, less error-prone and more elegant
from kernel developers' perspective.

Please see more details in patch 4/8 which contains two pages of detailed
explanation including why it is safe and better.

This reverts the offending commits from William which clearly broke
mq+netem use cases, as reported by two users.

All the TC test cases pass with this patchset.

---
v6: Dropped the init_user_ns check patch
Reordered the qfq patch
Rebased to the latest -net branch

v5: Reverted the offending commits
Added a init_user_ns check (4/9)
Rebased to the latest -net branch

v4: Added a fix for qfq qdisc (2/6)
Updated 1/6 patch description
Added a patch to update the enqueue reentrant behaviour tests

v3: Fixed the root cause of enqueuing to root
Switched back to netem_skb_cb safely
Added two more test cases

v2: Fixed a typo
Improved tdc selftest to check sent bytes

Cong Wang (8):
net_sched: Check the return value of qfq_choose_next_agg()
Revert "net/sched: Restrict conditions for adding duplicating netems
to qdisc tree"
Revert "selftests/tc-testing: Add tests for restrictions on netem
duplication"
net_sched: Implement the right netem duplication behavior
selftests/tc-testing: Add a nested netem duplicate test
selftests/tc-testing: Add a test case for piro with netem duplicate
selftests/tc-testing: Add a test case for mq with netem duplicate
selftests/tc-testing: Update test cases with netem duplicate

net/sched/sch_netem.c | 66 +++-------
net/sched/sch_qfq.c | 2 +
.../tc-testing/tc-tests/infra/qdiscs.json | 115 +++++++++++++-----
.../tc-testing/tc-tests/qdiscs/netem.json | 90 +++-----------
4 files changed, 120 insertions(+), 153 deletions(-)

--
2.34.1