Skip to content

net/sched: Fix packet loops in mirred and netem

Jamal Hadi Salim netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 3 repliesIn review

Changes in v4 from the cover letter

- Provide better context in patch 1 commit to appease Sashiko We'll see if it will stop yapping about corner cases! I believe I am making history being the first human to talk directly to Sashiko in a patch submission;->
- Fix infinite loop for the mirred egress blockcast case (patch 6)
- Fix skb leak in tcf_mirred_act caught by Sashiko (patch 7)

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9net: Introduce skb tc depth field to track packet loopsinclude/linux/skbuff.h+2 -00 replies
2/9net/sched: Revert "net/sched: Restrict conditions for adding duplicating netems to qdisc tree"net/sched/sch_netem.c+0 -400 replies
3/9Revert "selftests/tc-testing: Add tests for restrictions on netem duplication"tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json tools/testing/selftests/tc-testing/tc-tests/qdiscs/netem.json+3 -830 replies
4/9net/sched: fix packet loop on netem when duplicate is onnet/sched/sch_netem.c+3 -41 reply
5/9net/sched: Fix ethx:ingress -> ethy:egress -> ethx:ingress mirred loopnet/sched/act_mirred.c+30 -170 replies
6/9net/sched: act_mirred: Fix blockcast recursion bypass leading to stack overflownet/sched/act_mirred.c+6 -20 replies
7/9net/sched: act_mirred: Fix skb leak in early mirred redirect returnsnet/sched/act_mirred.c+12 -60 replies
8/9selftests/tc-testing: Add mirred test cases exercising loopstools/testing/selftests/tc-testing/tc-tests/actions/mirred.json+615 -10 replies
9/9selftests/tc-testing: Add netem test case exercising loopstools/testing/selftests/tc-testing/tc-tests/qdiscs/netem.json+32 -12 replies

Reviews trailers per patch

All 9 patches have a Reviewed-by or Acked-by.

PatchStephen HemmingerVictor NogueiraJamal Hadi SalimWilliam Liu
1/9R-b
2/9R-b
3/9R-b
4/9R-b R-b
5/9R-b T-b
6/9T-b A-b
7/9A-b
8/9A-b A-b
9/9A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH net 0/9] net/sched: Fix packet loops in mirred and netem

This patchset adds a 2-bit per-skb tc_depth counter that travels with the packet to help fixes packet loops caused by mirred ingress redirects and netem duplication in stacked qdisc trees.
The existing per-CPU mirred nest tracking loses state when a packet is deferred through the backlog or moves between CPUs via XPS/RPS. A per-skb field covers both cases.

Patch 1 adds the tc_depth field in a padding hole in sk_buff. Patches 2-3 revert the check_netem_in_tree() fix and its tests, which broke legitimate multi-netem configurations.
Patch 4 uses tc_depth to stop netem duplicate recursion.
Patch 5 uses tc_depth to catch mirred ingress redirect loops. Patch 6 fixes the infinite loop in the mirred egress blockcast case. Patch 7 fixes an skb leak in early return error scenarios in tcf_mirred_act for redirect (caught by Sashiko [1]).
Patches 8-9 add mirred and netem test cases.

Changes in v4:
- Provide better context in patch 1 commit to appease Sashiko We'll see if it will stop yapping about corner cases! I believe I am making history being the first human to talk directly to Sashiko in a patch submission;->
- Fix infinite loop for the mirred egress blockcast case (patch 6)
- Fix skb leak in tcf_mirred_act caught by Sashiko (patch 7)

Changes in v3:
- Renamed skb->ttl to skb->tc_depth to avoid confusion with IP TTL
- Expanded commit messages
- Split mirred and netem test cases into separate patches
- No code changes from v2

Changes in v2:
- Do not reuse skb->from_ingress (which was moved to skb->cb)

[1] https://sashiko.dev/#/patchset/20260413082027.2244884-1-hxzene%40gmail.com

Jamal Hadi Salim (5):
net: Introduce skb tc depth field to track packet loops net/sched: 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: fix packet loop on netem when duplicate is on net/sched: Fix ethx:ingress -> ethy:egress -> ethx:ingress mirred loop

Kito Xu (veritas501) (1):
net/sched: act_mirred: Fix blockcast recursion bypass leading to stack
overflow

Victor Nogueira (3):
net/sched: act_mirred: Fix skb leak in early mirred redirect returns selftests/tc-testing: Add mirred test cases exercising loops selftests/tc-testing: Add netem test case exercising loops

 include/linux/skbuff.h                        |   2 +
 net/sched/act_mirred.c                        |  67 +-
 net/sched/sch_netem.c                         |  47 +-
 .../tc-testing/tc-tests/actions/mirred.json   | 616 +++++++++++++++++-
 .../tc-testing/tc-tests/infra/qdiscs.json     |   5 +-
 .../tc-testing/tc-tests/qdiscs/netem.json     |  96 +--
 6 files changed, 691 insertions(+), 142 deletions(-)
Signature · 1 line
2.34.1