diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2012-03-01 17:01:23 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-02 17:18:04 -0500 |
commit | 31b8e2aec099f22d40277c424d8c24b2a4c95fce (patch) | |
tree | 47092ef0ac344736a78afadd71e4808e4fe63dcc /fs/nfs/client.c | |
parent | 2e738fdce22f9a7edf20281fd2d768ef9785922e (diff) |
NFS: Make clientaddr= optional
For NFSv4 mounts, the clientaddr= mount option has always been
required. Now we have rpc_localaddr() in the kernel, which was
modeled after the same logic in the mount.nfs command that constructs
the clientaddr= mount option. If user space doesn't provide a
clientaddr= mount option, the kernel can now construct its own.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/client.c')
-rw-r--r-- | fs/nfs/client.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index d038dc5916e5..d30dcbfb6b20 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -1346,6 +1346,7 @@ int nfs4_init_client(struct nfs_client *clp, | |||
1346 | rpc_authflavor_t authflavour, | 1346 | rpc_authflavor_t authflavour, |
1347 | int noresvport) | 1347 | int noresvport) |
1348 | { | 1348 | { |
1349 | char buf[INET6_ADDRSTRLEN + 1]; | ||
1349 | int error; | 1350 | int error; |
1350 | 1351 | ||
1351 | if (clp->cl_cons_state == NFS_CS_READY) { | 1352 | if (clp->cl_cons_state == NFS_CS_READY) { |
@@ -1361,6 +1362,20 @@ int nfs4_init_client(struct nfs_client *clp, | |||
1361 | 1, noresvport); | 1362 | 1, noresvport); |
1362 | if (error < 0) | 1363 | if (error < 0) |
1363 | goto error; | 1364 | goto error; |
1365 | |||
1366 | /* If no clientaddr= option was specified, find a usable cb address */ | ||
1367 | if (ip_addr == NULL) { | ||
1368 | struct sockaddr_storage cb_addr; | ||
1369 | struct sockaddr *sap = (struct sockaddr *)&cb_addr; | ||
1370 | |||
1371 | error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr)); | ||
1372 | if (error < 0) | ||
1373 | goto error; | ||
1374 | error = rpc_ntop(sap, buf, sizeof(buf)); | ||
1375 | if (error < 0) | ||
1376 | goto error; | ||
1377 | ip_addr = (const char *)buf; | ||
1378 | } | ||
1364 | strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); | 1379 | strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); |
1365 | 1380 | ||
1366 | error = nfs_idmap_new(clp); | 1381 | error = nfs_idmap_new(clp); |