svn commit: r325448 - stable/10/sys/fs/nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Sun Nov 5 20:28:30 UTC 2017
Author: rmacklem
Date: Sun Nov 5 20:28:28 2017
New Revision: 325448
URL: https://svnweb.freebsd.org/changeset/base/325448
Log:
MFC: r324639
Fix the client IP address reported by nfsdumpstate for 64bit arch and NFSv4.1.
The client IP address was not being reported for some NFSv4 mounts by
nfsdumpstate. Upon investigation, two problems were found for mounts
using IPv4. One was that the code (originally written and tested on i386)
assumed that a "u_long" was a "uint32_t" and would exactly store an
IPv4 host address. Not correct for 64bit arches.
Also, for NFSv4.1 mounts, the field was not being filled in. This was
basically correct, because NFSv4.1 does not use a callback address.
However, it meant that nfsdumpstate could not report the client IP addr.
This patch should fix both of these issues.
For IPv6, the address will still not be reported. The original NFSv4 RFC
only specified IPv4 callback addresses. I think this has changed and, if so,
a future commit to fix reporting of IPv6 addresses will be needed.
Modified:
stable/10/sys/fs/nfsserver/nfs_nfsdserv.c
stable/10/sys/fs/nfsserver/nfs_nfsdstate.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Sun Nov 5 20:03:57 2017 (r325447)
+++ stable/10/sys/fs/nfsserver/nfs_nfsdserv.c Sun Nov 5 20:28:28 2017 (r325448)
@@ -3700,6 +3700,7 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused
uint32_t sp4type, v41flags;
uint64_t owner_minor;
struct timespec verstime;
+ struct sockaddr_in *sad, *rad;
if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) {
nd->nd_repstat = NFSERR_WRONGSEC;
@@ -3723,6 +3724,13 @@ nfsrvd_exchangeid(struct nfsrv_descript *nd, __unused
NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
+ sad = NFSSOCKADDR(nd->nd_nam, struct sockaddr_in *);
+ rad = NFSSOCKADDR(clp->lc_req.nr_nam, struct sockaddr_in *);
+ rad->sin_family = AF_INET;
+ rad->sin_addr.s_addr = 0;
+ rad->sin_port = 0;
+ if (sad->sin_family == AF_INET)
+ rad->sin_addr.s_addr = sad->sin_addr.s_addr;
clp->lc_req.nr_cred = NULL;
NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
clp->lc_idlen = idlen;
Modified: stable/10/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Sun Nov 5 20:03:57 2017 (r325447)
+++ stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Sun Nov 5 20:28:28 2017 (r325448)
@@ -3888,11 +3888,11 @@ nfsrv_getclientipaddr(struct nfsrv_descript *nd, struc
u_char protocol[5], addr[24];
int error = 0, cantparse = 0;
union {
- u_long ival;
+ in_addr_t ival;
u_char cval[4];
} ip;
union {
- u_short sval;
+ in_port_t sval;
u_char cval[2];
} port;
@@ -3986,8 +3986,10 @@ nfsrv_getclientipaddr(struct nfsrv_descript *nd, struc
}
if (cantparse) {
sad = NFSSOCKADDR(nd->nd_nam, struct sockaddr_in *);
- rad->sin_addr.s_addr = sad->sin_addr.s_addr;
- rad->sin_port = 0x0;
+ if (sad->sin_family == AF_INET) {
+ rad->sin_addr.s_addr = sad->sin_addr.s_addr;
+ rad->sin_port = 0x0;
+ }
clp->lc_program = 0;
}
nfsmout:
More information about the svn-src-all
mailing list