Date: Tue, 03 Sep 2019 14:08:08 -0000 From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r346466 - in stable/10/sys: fs/nfs modules/nfscommon Message-ID: <201904210115.x3L1Fsal046438@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Sun Apr 21 01:15:54 2019 New Revision: 346466 URL: https://svnweb.freebsd.org/changeset/base/346466 Log: MFC: r345992, r346087 Add INET6 support for the upcalls to the nfsuserd daemon. The kernel code uses UDP to do upcalls to the nfsuserd(8) daemon to get updates to the username<->uid and groupname<->gid mappings. A change to AF_LOCAL last year had to be reverted, since it could result in vnode locking issues on the AF_LOCAL socket. This patch adds INET6 support and the required #ifdef INET and INET6 to the code. Modified: stable/10/sys/fs/nfs/nfs.h stable/10/sys/fs/nfs/nfs_commonport.c stable/10/sys/fs/nfs/nfs_commonsubs.c stable/10/sys/fs/nfs/nfs_var.h stable/10/sys/modules/nfscommon/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfs/nfs.h ============================================================================== --- stable/10/sys/fs/nfs/nfs.h Sun Apr 21 00:59:21 2019 (r346465) +++ stable/10/sys/fs/nfs/nfs.h Sun Apr 21 01:15:54 2019 (r346466) @@ -212,6 +212,11 @@ struct nfsd_oidargs { int nid_namelen; /* and its length */ }; +struct nfsuserd_args { + sa_family_t nuserd_family; /* Address family to use */ + u_short nuserd_port; /* Port# */ +}; + struct nfsd_clid { int nclid_idlen; /* Length of client id */ u_char nclid_id[NFSV4_OPAQUELIMIT]; /* and name */ Modified: stable/10/sys/fs/nfs/nfs_commonport.c ============================================================================== --- stable/10/sys/fs/nfs/nfs_commonport.c Sun Apr 21 00:59:21 2019 (r346465) +++ stable/10/sys/fs/nfs/nfs_commonport.c Sun Apr 21 01:15:54 2019 (r346466) @@ -536,11 +536,24 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, goto out; } else if (uap->flag & NFSSVC_NFSUSERDPORT) { u_short sockport; + struct nfsuserd_args nargs; - error = copyin(uap->argp, (caddr_t)&sockport, - sizeof (u_short)); + if ((uap->flag & NFSSVC_NEWSTRUCT) == 0) { + error = copyin(uap->argp, (caddr_t)&sockport, + sizeof (u_short)); + if (error == 0) { + nargs.nuserd_family = AF_INET; + nargs.nuserd_port = sockport; + } + } else { + /* + * New nfsuserd_args structure, which indicates + * which IP version to use along with the port#. + */ + error = copyin(uap->argp, &nargs, sizeof(nargs)); + } if (!error) - error = nfsrv_nfsuserdport(sockport, p); + error = nfsrv_nfsuserdport(&nargs, p); } else if (uap->flag & NFSSVC_NFSUSERDDELPORT) { nfsrv_nfsuserddelport(); error = 0; Modified: stable/10/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- stable/10/sys/fs/nfs/nfs_commonsubs.c Sun Apr 21 00:59:21 2019 (r346465) +++ stable/10/sys/fs/nfs/nfs_commonsubs.c Sun Apr 21 01:15:54 2019 (r346466) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); * copy data between mbuf chains and uio lists. */ #ifndef APPLEKEXT +#include "opt_inet.h" #include "opt_inet6.h" #include <fs/nfs/nfsport.h> @@ -3071,10 +3072,16 @@ nfsrv_cmpmixedcase(u_char *cp, u_char *cp2, int len) * Set the port for the nfsuserd. */ APPLESTATIC int -nfsrv_nfsuserdport(u_short port, NFSPROC_T *p) +nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPROC_T *p) { struct nfssockreq *rp; +#ifdef INET struct sockaddr_in *ad; +#endif +#ifdef INET6 + struct sockaddr_in6 *ad6; + const struct in6_addr in6loopback = IN6ADDR_LOOPBACK_INIT; +#endif int error; NFSLOCKNAMEID(); @@ -3094,17 +3101,39 @@ nfsrv_nfsuserdport(u_short port, NFSPROC_T *p) rp->nr_soproto = IPPROTO_UDP; rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST); rp->nr_cred = NULL; - NFSSOCKADDRALLOC(rp->nr_nam); - NFSSOCKADDRSIZE(rp->nr_nam, sizeof (struct sockaddr_in)); - ad = NFSSOCKADDR(rp->nr_nam, struct sockaddr_in *); - ad->sin_family = AF_INET; - ad->sin_addr.s_addr = htonl((u_int32_t)0x7f000001); /* 127.0.0.1 */ - ad->sin_port = port; rp->nr_prog = RPCPROG_NFSUSERD; + error = 0; + switch (nargs->nuserd_family) { +#ifdef INET + case AF_INET: + rp->nr_nam = malloc(sizeof(struct sockaddr_in), M_SONAME, + M_WAITOK | M_ZERO); + ad = (struct sockaddr_in *)rp->nr_nam; + ad->sin_len = sizeof(struct sockaddr_in); + ad->sin_family = AF_INET; + ad->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + ad->sin_port = nargs->nuserd_port; + break; +#endif +#ifdef INET6 + case AF_INET6: + rp->nr_nam = malloc(sizeof(struct sockaddr_in6), M_SONAME, + M_WAITOK | M_ZERO); + ad6 = (struct sockaddr_in6 *)rp->nr_nam; + ad6->sin6_len = sizeof(struct sockaddr_in6); + ad6->sin6_family = AF_INET6; + ad6->sin6_addr = in6loopback; + ad6->sin6_port = nargs->nuserd_port; + break; +#endif + default: + error = ENXIO; + } rp->nr_vers = RPCNFSUSERD_VERS; - error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); + if (error == 0) + error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); if (error) { - NFSSOCKADDRFREE(rp->nr_nam); + free(rp->nr_nam, M_SONAME); nfsrv_nfsuserd = 0; } out: Modified: stable/10/sys/fs/nfs/nfs_var.h ============================================================================== --- stable/10/sys/fs/nfs/nfs_var.h Sun Apr 21 00:59:21 2019 (r346465) +++ stable/10/sys/fs/nfs/nfs_var.h Sun Apr 21 01:15:54 2019 (r346466) @@ -130,7 +130,7 @@ int nfsrv_checksetattr(vnode_t, struct nfsrv_descript NFSPROC_T *); int nfsrv_checkgetattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *, struct ucred *, NFSPROC_T *); -int nfsrv_nfsuserdport(u_short, NFSPROC_T *); +int nfsrv_nfsuserdport(struct nfsuserd_args *, NFSPROC_T *); void nfsrv_nfsuserddelport(void); void nfsrv_throwawayallstate(NFSPROC_T *); int nfsrv_checksequence(struct nfsrv_descript *, uint32_t, uint32_t *, Modified: stable/10/sys/modules/nfscommon/Makefile ============================================================================== --- stable/10/sys/modules/nfscommon/Makefile Sun Apr 21 00:59:21 2019 (r346465) +++ stable/10/sys/modules/nfscommon/Makefile Sun Apr 21 01:15:54 2019 (r346466) @@ -7,6 +7,7 @@ SRCS= vnode_if.h \ nfs_commonkrpc.c \ nfs_commonport.c \ nfs_commonsubs.c \ + opt_inet.h \ opt_inet6.h \ opt_kdtrace.h \ opt_kgssapi.h \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904210115.x3L1Fsal046438>