shaper: detect a cake_mq root qdisc instead of assuming cake (#353) - #391
shaper: detect a cake_mq root qdisc instead of assuming cake (#353)#391ooonea wants to merge 1 commit into
Conversation
|
This looks pretty good to me. Pedantic me wondered about |
|
I went with There is a local reason too: Still keeping this in draft until someone with a multi-queue box can confirm the |
|
Perhaps I can test on my RT3200 actually? |
|
That would be great! The detection half is already covered (fixtures plus a live |
…cat#353) set_shaper_rate() hardcoded "cake" in its `tc qdisc change root` call. Where the root qdisc is cake_mq -- which sqm-scripts selects whenever USE_MQ=1 and the device has more than one queue (functions.sh:966-968) -- that call fails with "Invalid qdisc name", and because stderr goes to /dev/null and the exit status is ignored, cake-autorate carries on logging SHAPER lines while shaping nothing at all. Silent inertness rather than an error. Detect the root qdisc kind once per direction at startup and use whatever is actually there. Anything that is not cake_mq falls back to "cake", so a conventional single-cake setup behaves byte-identically to before. cake_mq is the v7.0 series backported by OpenWrt into backport-6.12 (700-02..700-07), with userspace support in the iproute2 patch 001-1-tc-cake-add-cake_mq-support. Configuring the cake_mq instance directly and letting the config propagate to the sub-qdiscs is the intended path -- 700-04, "Share config across cake_mq sub-qdiscs". Assisted-by: Claude Code
ad92569 to
c177ef4
Compare
Closes the gap reported in #353. @lynxthecat asked me in that thread whether I saw a good way to address it; this is the shape I proposed there, now written out.
The failure mode
set_shaper_rate()hardcodescakein itstc qdisc change rootcall. If the root qdisc iscake_mq, the kernel rejects the change withInvalid qdisc name— but the call sends stderr to/dev/nulland its exit status is never checked, so cake-autorate keeps emittingSHAPERlog lines while shaping nothing. It fails silently, which is worse than failing loudly: from the logs everything looks fine.This is reachable today, not hypothetical: sqm-scripts picks
cake_mqwheneverUSE_MQ=1and the device has more than one queue (functions.sh:966-968), and OpenWrt carries the kernel side inbackport-6.12(700-02..700-07) plus the iproute2 side in001-1-tc-cake-add-cake_mq-support. Configuring thecake_mqinstance directly and letting the config reach the sub-qdiscs is the designed behaviour —700-04is literally "Share config across cake_mq sub-qdiscs".The change
~15 lines.
get_root_qdisc_kind()readstc qdisc show root dev <if>once per direction at startup and stores the kind in a newqdisc_kind[dl|ul];set_shaper_rate()uses that instead of the literal. Anything unrecognised —htb,noqueue, empty output, a leaf line — falls back tocake, so a conventional setup is byte-identical to today. No per-iteration cost, no new config knob.What I tested, and what I could not
Tested:
tcoutput strings:cake_mqroot →cake_mq;cakeroot,htbroot,noqueue, aparent 1:1leaf line, and empty output →caketc qdisc show root, in a network namespace with a dummy interface: a genuinecakeroot is detected ascake;fq_codelandhtbroots fall back tocakebash -nclean,shellcheck -S warningreports nothing on the new linesNot tested, and this is the part that needs someone with the hardware: I have no cake_mq-capable box, so I have not observed an actual
tc qdisc change root dev <if> cake_mq bandwidth <X>taking effect end to end. The detection is verified; that the subsequent rate change propagates to the sub-qdiscs rests on reading700-04/701-02rather than on my having seen it work.Marking this a draft for exactly that reason. @Snuupy, @CHC383 — you raised #353 and suggested the
grep -q cake_mqapproach; if either of you can run this on a multi-queue setup withUSE_MQ=1and confirm the shaper actually tracks, I will flip it out of draft. If it turns outchangeon acake_mqroot needs different handling, better to find that now than after merge.