Skip to content

Won't perform DNS resolution if the only nameservers are IPv6 #262

@nwf

Description

@nwf

Running Debian/ppc64le with cqueues 20200726-2+b1.

If /etc/resolv.conf contains just nameserver fdb3:8168:d522::1, cqueues won't resolve DNS names:

$ lua -e 'print(require "cqueues.socket".connect{host="google.com"; port="443"}:connect())'
lua: (command line):1: socket:connect: A non-recoverable error occurred when attempting to resolve the name
stack traceback:
        [C]: in function 'error'
        /usr/share/lua/5.3/cqueues/socket.lua:90: in function </usr/share/lua/5.3/cqueues/socket.lua:75>
        (...tail calls...)
        /usr/share/lua/5.3/cqueues/socket.lua:271: in method 'connect'
        (command line):1: in main chunk
        [C]: in ?

strace sayeth...

fstat(3, {st_mode=S_IFREG|0644, st_size=74, ...}) = 0                                                                                                                                                                                                                                                                        
_llseek(3, 0, [0], SEEK_SET)            = 0                           
read(3, "search lw.ietfng.org.\n#nameserve"..., 512) = 74                                                                                                     
read(3, "", 512)                        = 0                                                                                                                   
close(3)                                = 0                                                                                                                   
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3                                                                                                
fstat(3, {st_mode=S_IFREG|0644, st_size=526, ...}) = 0                                                                                                        
read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 1024) = 526                                                                                                  
read(3, "", 1024)                       = 0                                                                                                                   
close(3)                                = 0                                                                                                                   
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3                                                                                                        
fstat(3, {st_mode=S_IFREG|0644, st_size=155, ...}) = 0                                                                                                        
_llseek(3, 0, [0], SEEK_SET)            = 0                                                                                                                   
read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tve"..., 512) = 155                                                                                                  
read(3, "", 512)                        = 0                                                                                                                   
close(3)                                = 0                                                                                                                                                                                                                                                                                  
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 3                                                                                        
bind(3, {sa_family=AF_INET, sin_port=htons(10218), sin_addr=inet_addr("0.0.0.0")}, 16) = 0                                                                    
rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000}, {sa_handler=0x123a47670, sa_mask=[], sa_flags=SA_NODEFER|SA_RESETHAND}, 8) = 0
write(2, "lua: ", 5lua: )                    = 5

The system as a whole can perform DNS resolution just fine; strace ping google.com sayeth:

newfstatat(AT_FDCWD, "/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=74, ...}, 0) = 0
newfstatat(AT_FDCWD, "/etc/nsswitch.conf", {st_mode=S_IFREG|0644, st_size=526, ...}, 0) = 0
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=155, ...}) = 0
_llseek(5, 0, [0], SEEK_SET)            = 0
read(5, "127.0.0.1\tlocalhost\n127.0.1.1\tve"..., 512) = 155
read(5, "", 512)                        = 0
close(5)                                = 0
socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 5
setsockopt(5, SOL_IPV6, IPV6_RECVERR, [1], 4) = 0
connect(5, {sa_family=AF_INET6, sin6_port=htons(53), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "fdb3:8168:d522::1", &sin6_addr), sin6_scope_id=0}, 28) = 0
poll([{fd=5, events=POLLOUT}], 1, 0)    = 1 ([{fd=5, revents=POLLOUT}])
send(5, "^4\1\0\0\1\0\0\0\0\0\0\1e\0010\0010\0012\0010\0010\0010\0010\0010\0010"..., 90, MSG_NOSIGNAL) = 90
poll([{fd=5, events=POLLIN}], 1, 5000)  = 1 ([{fd=5, revents=POLLIN}])
ioctl(5, FIONREAD, [129])               = 0
recvfrom(5, "^4\201\200\0\1\0\1\0\0\0\0\1e\0010\0010\0012\0010\0010\0010\0010\0010\0010"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "fdb3:8168:d522::1", &sin6_addr), sin6_scope_id=0}, [28]) = 129
close(5)                                = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x5), ...}) = 0
write(1, "PING google.com(yyz12s08-in-x0e."..., 84PING google.com(yyz12s08-in-x0e.1e100.net (2607:f8b0:400b:803::200e)) 56 data bytes

Adding an IPv4 nameserver to /etc/resolv.conf can workaround the issue, but is less than ideal.

Please advise if there's more I can tell you that'd be useful.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions