Commit a394b27
committed
Fix SFE/conntrack race and HTB quantum warnings on IPQ9574 (#506)
* Flush SFE before conntrack deletes to fix double-free race on IPQ9574
When wansteer deletes conntrack entries (failover, config reload, reconcile,
shutdown), SFE may still hold offloaded fast-path references. SFE then tries
to clean up a stale path and hits a double-free, causing
"sfe_ipv4_remove_connection: Connection has been removed already" kernel errors.
Fix: flush SFE cache (IPv4 + IPv6) before every conntrack deletion. The order
SFE delete -> conntrack delete prevents the race. flushSFE() writes to
/sys/sfe_ipv4/flush and /sys/sfe_ipv6/flush, silently skipping on platforms
without SFE.
Covered paths:
- flushConntrackForMark (health failover, config reload, shutdown)
- Reconcile cycle (drift-detected rule rebuild)
* Replace misleading SFE sysfs test with idempotency test
TestFlushSFE_WritesToSysfs didn't actually call flushSFE() - it just
tested os.WriteFile on temp files. Replace with an idempotency test
that verifies multiple flushSFE calls are safe (relevant for
flushAllSteeredConntrack which calls it per-WAN).
* Change HTB minimum class rate from 64bit to 100kbit in Adaptive SQM
rate 64bit causes the kernel to log "HTB: quantum of class XXXXX is small"
warnings every time qdiscs are reapplied (every 5 minutes), generating ~21K
warnings per 3 hours in kern.log. This adds unnecessary eMMC write pressure
on the UniFi Cloud Gateway Fiber.
100kbit is still effectively zero guaranteed rate (classes borrow via ceil),
but produces a quantum of 1250 bytes with r2q 10, well above the warning
threshold. Also update the filter to match both 64bit (stock UniFi) and
100Kbit (after our update) as best-effort class markers.1 parent 156f740 commit a394b27
4 files changed
Lines changed: 54 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
571 | | - | |
572 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
573 | 574 | | |
574 | 575 | | |
575 | 576 | | |
| |||
585 | 586 | | |
586 | 587 | | |
587 | 588 | | |
588 | | - | |
| 589 | + | |
589 | 590 | | |
590 | | - | |
| 591 | + | |
591 | 592 | | |
592 | 593 | | |
593 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
332 | 350 | | |
333 | 351 | | |
334 | 352 | | |
| 353 | + | |
| 354 | + | |
335 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
336 | 361 | | |
337 | 362 | | |
338 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
0 commit comments