Repository navigation
cniprovider: keep proxy dials in CNI netns - #6863
Conversation
| // loopback resolvers (systemd-resolved, Docker embedded | ||
| // DNS) are only reachable in the host namespace | ||
| return d.DialContext(ctx, networkName, address) |
There was a problem hiding this comment.
could this bypass the target CNI namespace which could be wrong in RootlessKit detached-netns cases?
buildkit/util/network/cniprovider/cni_linux.go
Lines 77 to 106 in e7b395c
cc @AkihiroSuda
There was a problem hiding this comment.
Pushed a follow-up to make the loopback DNS path explicit.
Now it captures the namespace that called DialContext before entering the CNI namespace, then uses that namespace for loopback DNS dials. Non-loopback DNS and final connection dials still run inside the target CNI namespace.
Also added a regression test that invokes the resolver hook while already inside the target namespace, so the old ambient-namespace behavior would fail instead of passing by accident.
Let me know if that looks good @tonistiigi
Dialing from a CNI namespace with the standard net.Dialer can escape the namespace through happy-eyeballs connection attempts or resolver goroutines. Use a serial dialer and route Go resolver sockets through the target namespace, while preserving host loopback DNS stubs such as systemd-resolved and Docker embedded DNS. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
78df309 to
bac24d3
Compare
depends on #6862
Dialing from a CNI namespace with the standard net.Dialer can escape the
namespace through happy-eyeballs connection attempts or resolver goroutines.
Use a serial dialer and route Go resolver sockets through the target
namespace, while preserving host loopback DNS stubs such as systemd-resolved
and Docker embedded DNS.