2007-08-31 14:01:07

by Gabriel Barazer

[permalink] [raw]
Subject: [PATCH] mount.nfs4: don't try to detect a clientaddr if clientaddr= option is provided

If get_my_ipv4addr() fails (dns error, wrong hostname, etc.), nfs4mount would
fail even if the clientaddr= is provided (and with clientaddr=, get_my_ipv4addr
detection is then useless).

Signed-off-by: Gabriel Barazer <[email protected]>
---
utils/mount/nfs4mount.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c
index c4e8bfb..391665b 100644
--- a/utils/mount/nfs4mount.c
+++ b/utils/mount/nfs4mount.c
@@ -199,8 +199,6 @@ int nfs4mount(const char *spec, const char *node, int flags,

if (fill_ipv4_sockaddr(hostname, &server_addr))
goto fail;
- if (get_my_ipv4addr(ip_addr, sizeof(ip_addr)))
- goto fail;

/* add IP address to mtab options for use when unmounting */
s = inet_ntoa(server_addr.sin_addr);
@@ -328,6 +326,14 @@ int nfs4mount(const char *spec, const char *node, int flags,
}
}

+ /* Try to get and resolve the local address only if
+ * it is not provided by the clientaddr= option.
+ * Else, nfs4mount could fail if the local hostname is not resolvable
+ * (poor DNS config or early mount), even if clientaddr= is provided.
+ */
+ if (!ip_addr_in_opts && get_my_ipv4addr(ip_addr, sizeof(ip_addr)))
+ goto fail;
+
data.flags = (soft ? NFS4_MOUNT_SOFT : 0)
| (intr ? NFS4_MOUNT_INTR : 0)
| (nocto ? NFS4_MOUNT_NOCTO : 0)
--
1.5.2.5


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs