Repository navigation
Networks: the address pool skips only on-link routes, as Docker does (#228) - #351
Open
sundarshahi wants to merge 1 commit into
Open
sundarshahi wants to merge 1 commit into
sundarshahi wants to merge 1 commit into
Conversation
AndreKurait
added a commit
to AndreKurait/asagiri
that referenced
this pull request
Nov 16, 2026
Port the public Linux routing-table fix while retaining Asagiri's custom address-pool allocator and host-interface exclusions. Ignore gateway, blackhole and unspecified-destination routes when reserving connected subnets, so a full-tunnel route does not cover every pool candidate. The new regression failed against the original parser. All 20 network tests now pass, including OpenVPN/WireGuard route-table inputs and default and custom pools that still avoid the host LAN. Native VPN operation is not established by these portable tests. Upstream-PR: libracoder/kiri#351 Upstream-Commit: 4b4df15aad6880965f93a8a2bf8fe21b92678b8c Co-authored-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <akurait@amazon.com>
…ibracoder#228) Kiri kept every subnet a host route covers out of the address pool. A route through a gateway, like OpenVPN's full-tunnel 0.0.0.0/1 and 128.0.0.0/1, covers every candidate, so `docker network create` with no --subnet failed with "no free subnet left", and so did kind. Since 23.0 Docker reserves only on-link routes (moby#42598). Kiri now does the same with /proc/net/route: it skips routes through a gateway, blackhole and unreachable routes (interface "*") and routes to 0.0.0.0.
sundarshahi
force-pushed
the
fix/228-pool-ignores-gateway-routes
branch
from
November 16, 2026 15:35
4b4df15 to
2d5557b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes and why
On a Linux host,
docker network createwith no--subnetcan fail withno free subnet lefteven when 172.18–172.31 are all free. kind runs exactly that command, sokind create clusterfails too. Docker Engine creates the network on the same host.Kiri keeps every subnet a host route covers out of its address pool. Since 23.0, Docker keeps out only on-link routes (moby#42598,
queryOnLinkRoutesindaemon/libnetwork/netutils/utils_linux.go). A route through a gateway doesn't mean the subnet is in use. A full-tunnel VPN shows why that matters: OpenVPN'sdef1adds0.0.0.0/1and128.0.0.0/1through the tunnel's gateway, and those two routes cover every subnet Kiri would pick.Refs #228. I could reproduce the error, but the report doesn't include the host's routes. @MAST1999, could you post
cat /proc/net/routefrom the machine where it fails? That would show whether this is your cause.Problem
free_subnet(crates/kiri/src/daemon/network.rs:746) skips any candidate that overlapshost_routes().host_routes(:787) kept every non-default route from/proc/net/route, including:G, e.g.0.0.0.0/1 via 10.8.0.1 dev tun0);*)./1routes, every 172.x/16 and 10.89.x/24 candidate overlaps, andcreatereturnsno free subnet left(:622).Fix
host_routesnow keeps only the routes that put the host on a subnet, as Docker does. It skips:RTF_GATEWAY, 0x2);*): blackhole, unreachable and prohibit;0.0.0.0/1such asdev wg0. Docker skips an unspecified destination the same way.On-link routes still count. Kiri running inside another engine's container still avoids that container's own
eth0subnet (the comment inNetworks::load).The cost, same trade-off as Docker: a LAN reached only through a gateway, e.g.
172.20.0.0/16 via 192.168.1.254, is no longer avoided automatically. Docker's way out isdefault-address-pools. Kiri has no pool setting, so the way out is--subnet. This changes which subnets Kiri picks, so it needs your call.Not in this change:
/etc/resolv.conf.host_routes6still does.Happy to do either here or separately.
How you tested it
Linux, GitHub's
ubuntu-24.04runner. main and this branch are built as static musl binaries, the same way the Speed check builds them. Each engine runs in its own privileged container, and the routes are added in that container's network namespace.Docker Engine 28.0.4 on the same runner, with OpenVPN-style routes:
Kiri main, same routes, kind's exact command:
This branch:
only_on_link_routes_reserve_subnets, a new unit test, parses a/proc/net/routewith:def1pair;0.0.0.0/1;unreachable 10.0.0.0/8andblackhole 172.16.0.0/12;kiri1bridge.It checks that only the two LANs come back. The test fails if any one of the three new checks is removed (each was reverted separately).
cargo test -p kiri --bin kiri network::passes on Linux (musl) and macOS.cargo clippy -p kiriadds no warnings in the changed lines.rustfmtadds no differences beyond what main already has at the repo's line width.tests/e2e.shwasn't run for this change. It only touches subnet choice, and the case above runs the API end to end.Tested on: Linux (Ubuntu 24.04, kernel from GitHub's runner), macOS 27 (unit tests)
How you found it
AI tools used to write this change: yes. An AI coding assistant helped write and test it. I reviewed and tested every change.
Checklist
cargo fmt,cargo clippyand the tests pass