Repository navigation
bridge: batch firewall updates for published ports - #54011
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-backend firewall and proxy rollback sequencing warrants maintainer review, particularly with the full daemon integration suite not run.
No open issues 🎉
What changed in this PR
This PR addresses #53466 by batching bridge port-publishing firewall updates, reducing nftables ruleset rewrites from one per port group to one per address family.
Changes:
- Preserve grouped host-port allocation while collecting bindings for a single firewall update.
- Start userland proxies after firewall installation and separate resource cleanup from firewall rollback.
- Extend regression tests to verify batching and cleanup after firewall or proxy failures.
| File | Description |
|---|---|
daemon/libnetwork/drivers/bridge/port_mapping_linux.go |
Batch firewall updates and reorganize allocation, proxy startup, and rollback. |
daemon/libnetwork/drivers/bridge/port_mapping_linux_test.go |
Check firewall call counts, failure cleanup, and host-port reuse. |
Review effort: Balanced
robmry
left a comment
There was a problem hiding this comment.
Thank you @akasakariko - batching the firewall update looks good to me.
Could you drop the second commit (libnetwork: isolate TestDNSOptions and retry flaky TestAllocator)? Those CI failures are unrelated to this change, and master has been passing. Renaming TestAllocator to TestFlakyAllocator would hide a nil pointer panic in that test, so it needs looking into separately rather than retrying. The TestDNSOptions fix looks reasonable, but in a separate PR.
Allocate all requested port bindings before applying their firewall rules, so nftables rewrites each affected chain once per address family rather than once per port group Keep grouped port allocation, start proxies after the firewall update, and roll back resources and installed rules if either stage fails Extend the port-mapping tests to check a single firewall update and verify cleanup and rebinding after setup failures Signed-off-by: akasakariko <[email protected]>
faa2268 to
e83b503
Compare
|
Thanks for the review Removed the unrelated DNS and allocator commit and folded the requested changes into
Related package tests, the libnftables variant, bridge race tests, lint, vet, formatting and Linux/amd64 compilation pass locally in Colima The full daemon integration suite has not been run |
robmry
left a comment
There was a problem hiding this comment.
LGTM - thank you @akasakariko.
|
Hi @akasakariko are you interested in opening a follow up PR with the TestDNSOptions changes from faa2268 ? |
|
Of course, happy to open a follow-up PR with the TestDNSOptions changes |
Fixes: #53466
Summary
Collect all port bindings before updating the firewall, allowing nftables to apply one transaction per address family instead of one per port group
Keep grouped host-port allocation and start userland proxies only after the firewall batch is installed
Extend the existing port-mapping tests to check batching and cleanup after firewall or proxy failures, including simultaneous proxy-stop and firewall-cleanup errors
AI assistance: ChatGPT in pi investigated the issue, drafted the implementation, regression tests and review revisions, and ran local validation
Validation
Validated in a privileged Colima Linux/arm64 container using Go 1.26.10 and nftables 1.1.3
errors.Joinlibnftablesbuild tagA local runtime probe with 1000 existing IPv4 port bindings measured the actual nft transactions used by the bridge port-mapping path
These are single-run port-mapping measurements, not complete container startup timings
The full daemon integration suite has not been run
Release notes (optional)
Created with: ChatGPT (pi)