X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fmount%2Fnetwork.c;h=52a538940ad2f33d1115bec1f6c34a021ee50fe8;hb=73840ef610accf4cf667427bc64805377c0d8394;hp=1759c1cdbc732b341494ee0b7f56aea77bc63e36;hpb=7e90281b88c05b01c61152b54a0cf2faec45b09c;p=nfs-utils.git diff --git a/utils/mount/network.c b/utils/mount/network.c index 1759c1c..52a5389 100644 --- a/utils/mount/network.c +++ b/utils/mount/network.c @@ -210,9 +210,6 @@ int nfs_lookup(const char *hostname, const sa_family_t family, { 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; @@ -1098,7 +1095,7 @@ static int nfs_ca_sockname(const struct sockaddr *sap, const socklen_t salen, .sin6_family = AF_INET6, .sin6_addr = IN6ADDR_ANY_INIT, }; - int sock; + int sock, result = 0; sock = socket(sap->sa_family, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) @@ -1106,28 +1103,26 @@ static int nfs_ca_sockname(const struct sockaddr *sap, const socklen_t salen, switch (sap->sa_family) { case AF_INET: - if (bind(sock, SAFE_SOCKADDR(&sin), sizeof(sin)) < 0) { - close(sock); - return 0; - } + if (bind(sock, SAFE_SOCKADDR(&sin), sizeof(sin)) < 0) + goto out; break; case AF_INET6: - if (bind(sock, SAFE_SOCKADDR(&sin6), sizeof(sin6)) < 0) { - close(sock); - return 0; - } + if (bind(sock, SAFE_SOCKADDR(&sin6), sizeof(sin6)) < 0) + goto out; break; default: errno = EAFNOSUPPORT; - return 0; + goto out; } - if (connect(sock, sap, salen) < 0) { - close(sock); - return 0; - } + if (connect(sock, sap, salen) < 0) + goto out; - return !getsockname(sock, buf, buflen); + result = !getsockname(sock, buf, buflen); + +out: + close(sock); + return result; } /* @@ -1349,7 +1344,7 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port) case PO_NOT_FOUND: break; case PO_FOUND: - if (tmp >= 1 && tmp <= 65535) { + if (tmp >= 0 && tmp <= 65535) { *port = tmp; return 1; } @@ -1521,7 +1516,11 @@ nfs_mount_protocol(struct mount_options *options, unsigned long *protocol) * set @protocol to zero. The pmap protocol value will * be filled in later by an rpcbind query in this case. */ - return nfs_nfs_protocol(options, protocol); + if (!nfs_nfs_protocol(options, protocol)) + return 0; + if (*protocol == NFSPROTO_RDMA) + *protocol = IPPROTO_TCP; + return 1; } /* @@ -1537,7 +1536,7 @@ nfs_mount_port(struct mount_options *options, unsigned long *port) case PO_NOT_FOUND: break; case PO_FOUND: - if (tmp >= 1 && tmp <= 65535) { + if (tmp >= 0 && tmp <= 65535) { *port = tmp; return 1; }