With 'hosts: mdns4' in nsswitch.conf, getaddrinfo() returns -5 (EAI_NODATA) when network interface is down
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
nss-mdns (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
When the "hosts:" line in nsswitch.conf includes `mdns4` or `mdns4_minimal` last and the network interface is taken down, getaddrinfo() returns -5 (EAI_NODATA — "No address associated with hostname") instead of something more appropriate such as -4 (EAI_FAIL — "Non-recoverable failure in name resolution").
$ dpkg -l libc6
[...]
ii libc6:amd64 2.17-93ubuntu4 amd64
$ grep hosts /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
$ sudo su
# ifconfig eth0 down
# ./a.out
Making resolv.conf empty
Results of looking up www.google.com: status = -5, errno = 110
Results of looking up a bogus name: status = -5, errno = 110
Writing correct nameserver option to resolv.conf
Results of looking up www.google.com: status = -5, errno = 110
Results of looking up a bogus name: status = -5, errno = 110
Writing incorrect nameserver option to resolv.conf
Results of looking up www.google.com: status = -5, errno = 110
Results of looking up a bogus name: status = -5, errno = 110
# cat x.c
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
struct addrinfo *res;
void check_google()
{
int status;
status = getaddrinfo(
printf("Results of looking up www.google.com: status = %d, errno = %d\n", status, errno);
status = getaddrinfo(
printf("Results of looking up a bogus name: status = %d, errno = %d\n", status, errno);
}
int main()
{
FILE *fp;
printf("Making resolv.conf empty\n");
fp = fopen("
sleep(1);
check_google();
printf("Writing nameserver option to resolv.conf\n");
fp = fopen("
sleep(1);
check_google();
printf("Writing incorrect nameserver option to resolv.conf\n");
fp = fopen("
sleep(1);
check_google();
}
affects: | eglibc (Ubuntu) → nss-mdns (Ubuntu) |
summary: |
- getaddrinfo() returns -5 (EAI_FAMILY) when network interface is down + getaddrinfo() returns -5 (EAI_NODATA) when network interface is down |
summary: |
- getaddrinfo() returns -5 (EAI_NODATA) when network interface is down + With `hosts: mdns4` getaddrinfo() returns -5 (EAI_NODATA) when network + interface is down |
summary: |
- With `hosts: mdns4` getaddrinfo() returns -5 (EAI_NODATA) when network - interface is down + With 'hosts: mdns4' in nsswitch.conf, getaddrinfo() returns -5 + (EAI_NODATA) when network interface is down |
I've just spent several hours along with nacc debugging this same issue affecting a user with a fresh 17.10 install, causing several minute delays when using "sudo xxxx" commands.