Skip to content

linux netLookupPosix should use AI_ADDRCONFIG = true #26016

@graveland

Description

@graveland

Zig Version

0.16.0-dev.1316+181b25ce4

Steps to Reproduce and Observed Behavior

When using HostName.lookup in a kubernetes environment it's returning NameServerFailure where other programs successfully resolve DNS. The one specific difference with other things I've tested is setting AI_ADDRCONFIG in getnameinfo.

Expected Behavior

I'd expect it to resolve the addresses instead of returning an error.

I'm suggesting the following, but I'm not sure of the cross-platform repercussions:

--- a/lib/std/Io/Threaded.zig
+++ b/lib/std/Io/Threaded.zig
@@ -4924,7 +4924,7 @@ fn netLookupPosix(
         const port_c = std.fmt.bufPrintZ(&port_buffer, "{d}", .{options.port}) catch unreachable;

         const hints: posix.addrinfo = .{
-            .flags = .{ .NUMERICSERV = true },
+            .flags = .{ .NUMERICSERV = true, .ADDRCONFIG = true },
             .family = posix.AF.UNSPEC,
             .socktype = posix.SOCK.STREAM,
             .protocol = posix.IPPROTO.TCP,

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions