Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31b8e2ae authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust
Browse files

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: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 2e738fdc
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1346,6 +1346,7 @@ int nfs4_init_client(struct nfs_client *clp,
		     rpc_authflavor_t authflavour,
		     int noresvport)
{
	char buf[INET6_ADDRSTRLEN + 1];
	int error;

	if (clp->cl_cons_state == NFS_CS_READY) {
@@ -1361,6 +1362,20 @@ int nfs4_init_client(struct nfs_client *clp,
				      1, noresvport);
	if (error < 0)
		goto error;

	/* If no clientaddr= option was specified, find a usable cb address */
	if (ip_addr == NULL) {
		struct sockaddr_storage cb_addr;
		struct sockaddr *sap = (struct sockaddr *)&cb_addr;

		error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
		if (error < 0)
			goto error;
		error = rpc_ntop(sap, buf, sizeof(buf));
		if (error < 0)
			goto error;
		ip_addr = (const char *)buf;
	}
	strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));

	error = nfs_idmap_new(clp);
+0 −6
Original line number Diff line number Diff line
@@ -2557,12 +2557,6 @@ static int nfs4_validate_text_mount_data(void *options,
		return -EINVAL;
	}

	if (args->client_address == NULL) {
		dfprintk(MOUNT,
			 "NFS4: mount program didn't pass callback address\n");
		return -EINVAL;
	}

	return nfs_parse_devname(dev_name,
				   &args->nfs_server.hostname,
				   NFS4_MAXNAMLEN,