[Bug 1295229] Re: getaddrinfo() returns -5 (EAI_NODATA) when network interface is down

Thomas Hood 1295229 at bugs.launchpad.net
Thu Mar 20 16:46:15 UTC 2014


** Summary changed:

- getaddrinfo() returns -5 (EAI_FAMILY) when network interface is down
+ getaddrinfo() returns -5 (EAI_NODATA) when network interface is down

** Summary changed:

- getaddrinfo() returns -5 (EAI_NODATA) when network interface is down
+ With `hosts: mdns4` getaddrinfo() returns -5 (EAI_NODATA) when network interface is down

** Summary changed:

- 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

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to nss-mdns in Ubuntu.
https://bugs.launchpad.net/bugs/1295229

Title:
  With 'hosts: mdns4' in nsswitch.conf, getaddrinfo() returns -5
  (EAI_NODATA) when network interface is down

Status in “nss-mdns” package in Ubuntu:
  New

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("www.google.com", NULL, NULL, &res);
      printf("Results of looking up www.google.com: status = %d, errno = %d\n", status, errno);
      status = getaddrinfo("sjfkdsjfswfloo0f02938sjf28398sd.com", NULL, NULL, &res);
      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("/etc/resolv.conf", "w+"); fclose(fp);
      sleep(1);
      check_google();

      printf("Writing nameserver option to resolv.conf\n");
      fp = fopen("/etc/resolv.conf", "w+"); fprintf(fp, "nameserver 193.67.79.39\n"); fclose(fp);
      sleep(1);
      check_google();

      printf("Writing incorrect nameserver option to resolv.conf\n");
      fp = fopen("/etc/resolv.conf", "w+"); fprintf(fp, "nameserver 192.168.5.4\n"); fclose(fp);
      sleep(1);
      check_google();
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nss-mdns/+bug/1295229/+subscriptions



More information about the foundations-bugs mailing list