]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
nfs-utils: Remove all uses of AI_ADDRCONFIG
authorChuck Lever <chuck.lever@oracle.com>
Thu, 28 Oct 2010 16:12:12 +0000 (12:12 -0400)
committerSteve Dickson <steved@redhat.com>
Mon, 1 Nov 2010 12:05:14 +0000 (08:05 -0400)
It was reported that, if only "lo" is up,

  mount.nfs 127.0.0.1:/export /mount

fails with "Name or service not known".

"man 3 getaddrinfo" says this:

  If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4
  addresses are returned in the list pointed to by res only if the
  local system has at least one IPv4 address configured, and IPv6
  addresses are only returned if the local system has at least
  one IPv6 address configured.

The man page oversimplifies here.  A review of glibc shows that
getaddrinfo(3) explicitly ignores loopback addresses when deciding
whether an IPv4 or IPv6 address is configured.

This behavior around loopback is a problem not just for mount.nfs,
but also for RPC daemons that have to start up before a system's
networking is fully configured and started.  Given the history of
other problems with AI_ADDRCONFIG and the unpredictable behavior it
introduces, let's just remove it everywhere in nfs-utils.

This fix addresses:

  https://bugzilla.linux-nfs.org/show_bug.cgi?id=191

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/export/hostname.c
tests/nsm_client/nsm_client.c
utils/mount/network.c
utils/mount/stropts.c
utils/statd/hostname.c
utils/statd/sm-notify.c

index 3c55ce7ef4bf6261c28b62f23a5f701552ee441b..efcb75cdb97260a12b2feea32949c83c1a873624 100644 (file)
 #include "sockaddr.h"
 #include "exportfs.h"
 
 #include "sockaddr.h"
 #include "exportfs.h"
 
-#ifndef HAVE_DECL_AI_ADDRCONFIG
-#define AI_ADDRCONFIG  0
-#endif
-
 /**
  * host_ntop - generate presentation address given a sockaddr
  * @sap: pointer to socket address
 /**
  * host_ntop - generate presentation address given a sockaddr
  * @sap: pointer to socket address
@@ -170,7 +166,7 @@ host_addrinfo(const char *hostname)
 #endif
                /* don't return duplicates */
                .ai_protocol    = (int)IPPROTO_UDP,
 #endif
                /* don't return duplicates */
                .ai_protocol    = (int)IPPROTO_UDP,
-               .ai_flags       = AI_ADDRCONFIG | AI_CANONNAME,
+               .ai_flags       = AI_CANONNAME,
        };
        int error;
 
        };
        int error;
 
index 0d1159a8f12ca173d1b679139c501bda1bd5eda8..0fa3422d95dae5077b6c292231b47acc16c8a21c 100644 (file)
@@ -205,7 +205,7 @@ nsm_client_get_rpcclient(const char *node)
 {
        unsigned short          port;
        struct addrinfo         *ai;
 {
        unsigned short          port;
        struct addrinfo         *ai;
-       struct addrinfo         hints = { .ai_flags     = AI_ADDRCONFIG };
+       struct addrinfo         hints = { };
        int                     err;
        CLIENT                  *client = NULL;
 
        int                     err;
        CLIENT                  *client = NULL;
 
index 5b515c30d76d26a79839331d5db7dd2b7840f6e3..21a7a2cc11fd8ed2faa5fa064c7a68bf5b5e3026 100644 (file)
@@ -210,9 +210,6 @@ int nfs_lookup(const char *hostname, const sa_family_t family,
 {
        struct addrinfo *gai_results;
        struct addrinfo gai_hint = {
 {
        struct addrinfo *gai_results;
        struct addrinfo gai_hint = {
-#ifdef HAVE_DECL_AI_ADDRCONFIG
-               .ai_flags       = AI_ADDRCONFIG,
-#endif /* HAVE_DECL_AI_ADDRCONFIG */
                .ai_family      = family,
        };
        socklen_t len = *salen;
                .ai_family      = family,
        };
        socklen_t len = *salen;
index 50a1a2a06626a72ba2c09fe656df3331e66a85b1..bcc36f3ece6085cdf50c46bd9cd2c6b4ff675908 100644 (file)
 #include "parse_dev.h"
 #include "conffile.h"
 
 #include "parse_dev.h"
 #include "conffile.h"
 
-#ifndef HAVE_DECL_AI_ADDRCONFIG
-#define AI_ADDRCONFIG  0
-#endif
-
 #ifndef NFS_PROGRAM
 #define NFS_PROGRAM    (100003)
 #endif
 #ifndef NFS_PROGRAM
 #define NFS_PROGRAM    (100003)
 #endif
@@ -343,7 +339,6 @@ static int nfs_validate_options(struct nfsmount_info *mi)
 {
        struct addrinfo hint = {
                .ai_protocol    = (int)IPPROTO_UDP,
 {
        struct addrinfo hint = {
                .ai_protocol    = (int)IPPROTO_UDP,
-               .ai_flags       = AI_ADDRCONFIG,
        };
        sa_family_t family;
        int error;
        };
        sa_family_t family;
        int error;
index 38f22650c61e50f3447ba4aebf64b57936584325..616a3cbf45e2668ea57efe69c5aacf6995f80cd5 100644 (file)
 #include "statd.h"
 #include "xlog.h"
 
 #include "statd.h"
 #include "xlog.h"
 
-#ifndef HAVE_DECL_AI_ADDRCONFIG
-#define AI_ADDRCONFIG  0
-#endif
-
 /**
  * statd_present_address - convert sockaddr to presentation address
  * @sap: pointer to socket address to convert
 /**
  * statd_present_address - convert sockaddr to presentation address
  * @sap: pointer to socket address to convert
index 437e37a6b49de679f72b9663324faad4b346723d..b7f43715b5e536d284571a7a506aaed9942b3a7d 100644 (file)
 #include "nsm.h"
 #include "nfsrpc.h"
 
 #include "nsm.h"
 #include "nfsrpc.h"
 
-#ifndef HAVE_DECL_AI_ADDRCONFIG
-#define AI_ADDRCONFIG  0
-#endif
-
 #define NSM_TIMEOUT    2
 #define NSM_MAX_TIMEOUT        120     /* don't make this too big */
 
 #define NSM_TIMEOUT    2
 #define NSM_MAX_TIMEOUT        120     /* don't make this too big */
 
@@ -78,7 +74,6 @@ smn_lookup(const char *name)
 {
        struct addrinfo *ai = NULL;
        struct addrinfo hint = {
 {
        struct addrinfo *ai = NULL;
        struct addrinfo hint = {
-               .ai_flags       = AI_ADDRCONFIG,
                .ai_family      = (nsm_family == AF_INET ? AF_INET: AF_UNSPEC),
                .ai_protocol    = (int)IPPROTO_UDP,
        };
                .ai_family      = (nsm_family == AF_INET ? AF_INET: AF_UNSPEC),
                .ai_protocol    = (int)IPPROTO_UDP,
        };