svn commit: r362158 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs fs/cd9660 fs/msdosfs fs/nfs fs/nfsserver fs/unionfs kern nlm sys ufs/ffs
Author: rmacklem Date: Sun Jun 14 00:10:18 2020 New Revision: 362158 URL: https://svnweb.freebsd.org/changeset/base/362158 Log: Fix export_args ex_flags field so that is 64bits, the same as mnt_flags. Since mnt_flags was upgraded to 64bits there has been a quirk in "struct export_args", since it hold a copy of mnt_flags in ex_flags, which is an "int" (32bits). This happens to currently work, since all the flag bits used in ex_flags are defined in the low order 32bits. However, new export flags cannot be defined. Also, ex_anon is a "struct xucred", which limits it to 16 additional groups. This patch revises "struct export_args" to make ex_flags 64bits and replaces ex_anon with ex_uid, ex_ngroups and ex_groups (which points to a groups list, so it can be malloc'd up to NGROUPS in size. This requires that the VFS_CHECKEXP() arguments change, so I also modified the last "secflavors" argument to be an array pointer, so that the secflavors could be copied in VFS_CHECKEXP() while the export entry is locked. (Without this patch VFS_CHECKEXP() returns a pointer to the secflavors array and then it is used after being unlocked, which is potentially a problem if the exports entry is changed. In practice this does not occur when mountd is run with "-S", but I think it is worth fixing.) This patch also deleted the vfs_oexport_conv() function, since do_mount_update() does the conversion, as required by the old vfs_cmount() calls. Reviewed by: kib, freqlabs Relnotes: yes Differential Revision:https://reviews.freebsd.org/D25088 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c head/sys/fs/cd9660/cd9660_vfsops.c head/sys/fs/msdosfs/msdosfs_vfsops.c head/sys/fs/nfs/nfsdport.h head/sys/fs/nfs/nfsport.h head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/unionfs/union_vfsops.c head/sys/kern/vfs_export.c head/sys/kern/vfs_init.c head/sys/kern/vfs_mount.c head/sys/nlm/nlm_prot_impl.c head/sys/sys/mount.h head/sys/ufs/ffs/ffs_vfsops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cSat Jun 13 23:35:22 2020(r362157) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cSun Jun 14 00:10:18 2020(r362158) @@ -101,8 +101,8 @@ static int zfs_root(vfs_t *vfsp, int flags, vnode_t ** static int zfs_statfs(vfs_t *vfsp, struct statfs *statp); static int zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp); static int zfs_sync(vfs_t *vfsp, int waitfor); -static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, -struct ucred **credanonp, int *numsecflavors, int **secflavors); +static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, +struct ucred **credanonp, int *numsecflavors, int *secflavors); static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp); static void zfs_objset_close(zfsvfs_t *zfsvfs); static void zfs_freevfs(vfs_t *vfsp); @@ -2268,8 +2268,8 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t ** } static int -zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, -struct ucred **credanonp, int *numsecflavors, int **secflavors) +zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, +struct ucred **credanonp, int *numsecflavors, int *secflavors) { zfsvfs_t *zfsvfs = vfsp->vfs_data; Modified: head/sys/fs/cd9660/cd9660_vfsops.c == --- head/sys/fs/cd9660/cd9660_vfsops.c Sat Jun 13 23:35:22 2020 (r362157) +++ head/sys/fs/cd9660/cd9660_vfsops.c Sun Jun 14 00:10:18 2020 (r362158) @@ -101,16 +101,14 @@ static int cd9660_cmount(struct mntarg *ma, void *data, uint64_t flags) { struct iso_args args; - struct export_args exp; int error; error = copyin(data, , sizeof args); if (error) return (error); - vfs_oexport_conv(, ); ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN); - ma = mount_arg(ma, "export", , sizeof(exp)); + ma = mount_arg(ma, "export", , sizeof(args.export)); ma = mount_argsu(ma, "cs_disk", args.cs_disk, 64); ma = mount_argsu(ma, "cs_local", args.cs_local, 64); ma = mount_argf(ma, "ssector", "%u", args.ssector); Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c == --- head/sys/fs/msdosfs/msdosfs_vfsops.cSat Jun 13 23:35:22 2020 (r362157) +++ head/sys/fs/msdosfs/msdosfs_vfsops.cSun Jun 14 00:10:18 2020 (r362158) @@ -190,7 +190,6 @@ static int msdosfs_cmount(struct mntarg *ma, void *data, uint64_t flags) { struct msdosfs_args args; - struct
svn commit: r361998 - in head/sys: kern sys
Author: rmacklem Date: Wed Jun 10 02:51:39 2020 New Revision: 361998 URL: https://svnweb.freebsd.org/changeset/base/361998 Log: Add two functions that create M_EXTPG mbufs with anonymous pages. These two functions are needed by nfs-over-tls, but could also be useful for other purposes. mb_alloc_ext_plus_pages() - Allocates a M_EXTPG mbuf and enough anonymous pages to store "len" data bytes. mb_mapped_to_unmapped() - Copies the data from a list of mapped (non-M_EXTPG) mbufs into a list of M_EXTPG mbufs allocated with anonymous pages. This is roughly the inverse of mb_unmapped_to_ext(). Reviewed by: gallatin Differential Revision:https://reviews.freebsd.org/D25182 Modified: head/sys/kern/kern_mbuf.c head/sys/sys/mbuf.h Modified: head/sys/kern/kern_mbuf.c == --- head/sys/kern/kern_mbuf.c Wed Jun 10 02:50:25 2020(r361997) +++ head/sys/kern/kern_mbuf.c Wed Jun 10 02:51:39 2020(r361998) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1536,4 +1537,105 @@ m_snd_tag_destroy(struct m_snd_tag *mst) ifp->if_snd_tag_free(mst); if_rele(ifp); counter_u64_add(snd_tag_count, -1); +} + +/* + * Allocate an mbuf with anonymous external pages. + */ +struct mbuf * +mb_alloc_ext_plus_pages(int len, int how) +{ + struct mbuf *m; + vm_page_t pg; + int i, npgs; + + m = mb_alloc_ext_pgs(how, mb_free_mext_pgs); + if (m == NULL) + return (NULL); + m->m_epg_flags |= EPG_FLAG_ANON; + npgs = howmany(len, PAGE_SIZE); + for (i = 0; i < npgs; i++) { + do { + pg = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL | + VM_ALLOC_NOOBJ | VM_ALLOC_NODUMP | VM_ALLOC_WIRED); + if (pg == NULL) { + if (how == M_NOWAIT) { + m->m_epg_npgs = i; + m_free(m); + return (NULL); + } + vm_wait(NULL); + } + } while (pg == NULL); + m->m_epg_pa[i] = VM_PAGE_TO_PHYS(pg); + } + m->m_epg_npgs = npgs; + return (m); +} + +/* + * Copy the data in the mbuf chain to a chain of mbufs with anonymous external + * unmapped pages. + * len is the length of data in the input mbuf chain. + * mlen is the maximum number of bytes put into each ext_page mbuf. + */ +struct mbuf * +mb_mapped_to_unmapped(struct mbuf *mp, int len, int mlen, int how, +struct mbuf **mlast) +{ + struct mbuf *m, *mout; + char *pgpos, *mbpos; + int i, mblen, mbufsiz, pglen, xfer; + + if (len == 0) + return (NULL); + mbufsiz = min(mlen, len); + m = mout = mb_alloc_ext_plus_pages(mbufsiz, how); + if (m == NULL) + return (m); + pgpos = (char *)(void *)PHYS_TO_DMAP(m->m_epg_pa[0]); + pglen = PAGE_SIZE; + mblen = 0; + i = 0; + do { + if (pglen == 0) { + if (++i == m->m_epg_npgs) { + m->m_epg_last_len = PAGE_SIZE; + mbufsiz = min(mlen, len); + m->m_next = mb_alloc_ext_plus_pages(mbufsiz, + how); + m = m->m_next; + if (m == NULL) { + m_freem(mout); + return (m); + } + i = 0; + } + pgpos = (char *)(void *)PHYS_TO_DMAP(m->m_epg_pa[i]); + pglen = PAGE_SIZE; + } + while (mblen == 0) { + if (mp == NULL) { + m_freem(mout); + return (NULL); + } + KASSERT((mp->m_flags & M_EXTPG) == 0, + ("mb_copym_ext_pgs: ext_pgs input mbuf")); + mbpos = mtod(mp, char *); + mblen = mp->m_len; + mp = mp->m_next; + } + xfer = min(mblen, pglen); + memcpy(pgpos, mbpos, xfer); + pgpos += xfer; + mbpos += xfer; + pglen -= xfer; + mblen -= xfer; + len -= xfer; + m->m_len += xfer; + } while (len > 0); + m->m_epg_last_len = PAGE_SIZE - pglen; + if (mlast != NULL) + *mlast = m; + return (mout); } Modified: head/sys/sys/mbuf.h
svn commit: r361956 - head/usr.sbin/mountd
Author: rmacklem Date: Tue Jun 9 05:01:23 2020 New Revision: 361956 URL: https://svnweb.freebsd.org/changeset/base/361956 Log: Fix a bug where XU_NGROUPS + 1 groups might be copied. r361780 fixed the code so that it would only remove the duplicate when it actually existed. However, that might have resulted in XU_NGROUPS + 1 groups being copied, running off the end of the array. This patch fixes the problem. Spotted during code inspection for other mountd changes. MFC after:2 weeks Modified: head/usr.sbin/mountd/mountd.c Modified: head/usr.sbin/mountd/mountd.c == --- head/usr.sbin/mountd/mountd.c Tue Jun 9 02:07:43 2020 (r361955) +++ head/usr.sbin/mountd/mountd.c Tue Jun 9 05:01:23 2020 (r361956) @@ -3481,6 +3481,8 @@ parsecred(char *namelist, struct xucred *cr) cr->cr_groups[cnt - 1] = groups[cnt]; } else { cr->cr_ngroups = ngroups; + if (cr->cr_ngroups > XU_NGROUPS) + cr->cr_ngroups = XU_NGROUPS; for (cnt = 1; cnt < ngroups; cnt++) cr->cr_groups[cnt] = groups[cnt]; } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361854 - head/usr.sbin/mountd
Author: rmacklem Date: Sat Jun 6 00:40:02 2020 New Revision: 361854 URL: https://svnweb.freebsd.org/changeset/base/361854 Log: Fix mountd so that it will not lose SIGHUPs that indicate "reload exports". Without this patch, if a SIGHUP is handled while the process is executing get_exportlist(), that SIGHUP is essentially ignored because the got_sighup variable is reset to 0 after get_exportlist(). This results in the exports file(s) not being reloaded until another SIGHUP signal is sent to mountd. This patch fixes this by resetting got_sighup to zero before the get_exportlist() call while SIGHUP is blocked. It also defines a delay time of 250msec before doing another exports reload if there are RPC request(s) to process. This prevents repeated exports reloads from delaying handling of RPC requests significantly. PR: 246597 Reported by: patrykkotlow...@gmail.com Tested by:patrykkotlow...@gmail.com Reviewed by: markj MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D25127 Modified: head/usr.sbin/mountd/mountd.c Modified: head/usr.sbin/mountd/mountd.c == --- head/usr.sbin/mountd/mountd.c Sat Jun 6 00:35:41 2020 (r361853) +++ head/usr.sbin/mountd/mountd.c Sat Jun 6 00:40:02 2020 (r361854) @@ -184,6 +184,12 @@ struct fhreturn { #defineGETPORT_MAXTRY 20 /* Max tries to get a port # */ +/* + * How long to delay a reload of exports when there are RPC request(s) + * to process, in usec. Must be less than 1second. + */ +#defineRELOADDELAY 25 + /* Global defs */ static char*add_expdir(struct dirlist **, char *, int); static voidadd_dlist(struct dirlist **, struct dirlist *, @@ -410,6 +416,10 @@ main(int argc, char **argv) int maxrec = RPC_MAXDATASIZE; int attempt_cnt, port_len, port_pos, ret; char **port_list; + uint64_t curtime, nexttime; + struct timeval tv; + struct timespec tp; + sigset_t sighup_mask; /* Check that another mountd isn't already running. */ pfh = pidfile_open(_PATH_MOUNTDPID, 0600, ); @@ -665,19 +675,49 @@ main(int argc, char **argv) } /* Expand svc_run() here so that we can call get_exportlist(). */ + curtime = nexttime = 0; + sigemptyset(_mask); + sigaddset(_mask, SIGHUP); for (;;) { - if (got_sighup) { - get_exportlist(1); + clock_gettime(CLOCK_MONOTONIC, ); + curtime = tp.tv_sec; + curtime = curtime * 100 + tp.tv_nsec / 1000; + sigprocmask(SIG_BLOCK, _mask, NULL); + if (got_sighup && curtime >= nexttime) { got_sighup = 0; - } + sigprocmask(SIG_UNBLOCK, _mask, NULL); + get_exportlist(1); + clock_gettime(CLOCK_MONOTONIC, ); + nexttime = tp.tv_sec; + nexttime = nexttime * 100 + tp.tv_nsec / 1000 + + RELOADDELAY; + } else + sigprocmask(SIG_UNBLOCK, _mask, NULL); + + /* +* If a reload is pending, poll for received request(s), +* otherwise set a RELOADDELAY timeout, since a SIGHUP +* could be processed between the got_sighup test and +* the select() system call. +*/ + tv.tv_sec = 0; + if (got_sighup) + tv.tv_usec = 0; + else + tv.tv_usec = RELOADDELAY; readfds = svc_fdset; - switch (select(svc_maxfd + 1, , NULL, NULL, NULL)) { + switch (select(svc_maxfd + 1, , NULL, NULL, )) { case -1: - if (errno == EINTR) -continue; + if (errno == EINTR) { + /* Allow a reload now. */ + nexttime = 0; + continue; + } syslog(LOG_ERR, "mountd died: select: %m"); exit(1); case 0: + /* Allow a reload now. */ + nexttime = 0; continue; default: svc_getreqset(); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361780 - head/usr.sbin/mountd
Author: rmacklem Date: Thu Jun 4 00:28:20 2020 New Revision: 361780 URL: https://svnweb.freebsd.org/changeset/base/361780 Log: Fix mountd to handle getgrouplist() not returning groups[0] == groups[1]. Prior to r174547, getgrouplist(3) always returned a groups list with element 0 and 1 set to the basegid argument, so long as ngroups was > 1. Post-r174547 this is not the case. r328304 disabled the deduplication that removed the duplicate, but the duplicate still does not occur unless the group for a user in the password database is also entered in the group database. This patch fixes mountd so that it handles the case where a user specified with the -maproot or -mapall exports option has a getgrouplist(3) groups list where groups[0] != groups[1]. Found while testing another mountd patch. MFC after:2 weeks Modified: head/usr.sbin/mountd/mountd.c Modified: head/usr.sbin/mountd/mountd.c == --- head/usr.sbin/mountd/mountd.c Wed Jun 3 23:21:44 2020 (r361779) +++ head/usr.sbin/mountd/mountd.c Thu Jun 4 00:28:20 2020 (r361780) @@ -3434,10 +3434,16 @@ parsecred(char *namelist, struct xucred *cr) /* * Compress out duplicate. */ - cr->cr_ngroups = ngroups - 1; cr->cr_groups[0] = groups[0]; - for (cnt = 2; cnt < ngroups; cnt++) - cr->cr_groups[cnt - 1] = groups[cnt]; + if (ngroups > 1 && groups[0] == groups[1]) { + cr->cr_ngroups = ngroups - 1; + for (cnt = 2; cnt < ngroups; cnt++) + cr->cr_groups[cnt - 1] = groups[cnt]; + } else { + cr->cr_ngroups = ngroups; + for (cnt = 1; cnt < ngroups; cnt++) + cr->cr_groups[cnt] = groups[cnt]; + } return; } /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361711 - head/sys/kern
Author: rmacklem Date: Tue Jun 2 00:03:26 2020 New Revision: 361711 URL: https://svnweb.freebsd.org/changeset/base/361711 Log: Fix build issue introduced by r361699. Reported by: cy (and others) Modified: head/sys/kern/vfs_mount.c Modified: head/sys/kern/vfs_mount.c == --- head/sys/kern/vfs_mount.c Mon Jun 1 23:44:03 2020(r361710) +++ head/sys/kern/vfs_mount.c Tue Jun 2 00:03:26 2020(r361711) @@ -70,6 +70,9 @@ __FBSDID("$FreeBSD$"); #include +#include +#include + #include #include ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r361682 - head/include
>Author: rmacklem >Date: Sun May 31 22:46:32 2020 >New Revision: 361682 >URL: https://svnweb.freebsd.org/changeset/base/361682 > >Log: > Oops, I didn't notice the "cd" is needed for each install line. > >Modified: > head/include/Makefile > >Modified: head/include/Makefile >=>= >--- head/include/Makefile Sun May 31 22:40:39 2020(r361681) >+++ head/include/Makefile Sun May 31 22:46:32 2020(r361682) >@@ -236,6 +236,7 @@ copies: .PHONY .META >cd ${SRCTOP}/sys/rpc; \ >${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 > rpcsec_tls.h \ >${SDESTDIR}${INCLUDEDIR}/rpc Or would it be preferable to put a line continuation "\" here instead of adding the second "cd .."? >+ cd ${SRCTOP}/sys/rpc; \ >${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 types.h \ >${SDESTDIR}${INCLUDEDIR}/rpc >cd ${SRCTOP}/sys/teken; \ rick ps: I'll admit I tried to do a "make buildworld" but it was still building clang after 7 hours, so I gave up... ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361682 - head/include
Author: rmacklem Date: Sun May 31 22:46:32 2020 New Revision: 361682 URL: https://svnweb.freebsd.org/changeset/base/361682 Log: Oops, I didn't notice the "cd" is needed for each install line. Modified: head/include/Makefile Modified: head/include/Makefile == --- head/include/Makefile Sun May 31 22:40:39 2020(r361681) +++ head/include/Makefile Sun May 31 22:46:32 2020(r361682) @@ -236,6 +236,7 @@ copies: .PHONY .META cd ${SRCTOP}/sys/rpc; \ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 rpcsec_tls.h \ ${SDESTDIR}${INCLUDEDIR}/rpc + cd ${SRCTOP}/sys/rpc; \ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 types.h \ ${SDESTDIR}${INCLUDEDIR}/rpc cd ${SRCTOP}/sys/teken; \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361679 - head/include
Author: rmacklem Date: Sun May 31 22:15:34 2020 New Revision: 361679 URL: https://svnweb.freebsd.org/changeset/base/361679 Log: Update the Makefile to copy rpcsec_tls.h to /usr/include/rpc. Modified: head/include/Makefile Modified: head/include/Makefile == --- head/include/Makefile Sun May 31 22:12:56 2020(r361678) +++ head/include/Makefile Sun May 31 22:15:34 2020(r361679) @@ -234,6 +234,8 @@ copies: .PHONY .META .endif .endfor cd ${SRCTOP}/sys/rpc; \ + ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 rpcsec_tls.h \ + ${SDESTDIR}${INCLUDEDIR}/rpc ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 types.h \ ${SDESTDIR}${INCLUDEDIR}/rpc cd ${SRCTOP}/sys/teken; \ @@ -367,7 +369,7 @@ symlinks: .PHONY .META ${SDESTDIR}${INCLUDEDIR}/isofs/cd9660; \ done cd ${SRCTOP}/sys/rpc; \ - for h in types.h; do \ + for h in rpcsec_tls.h types.h; do \ ${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/rpc/$$h \ ${SDESTDIR}${INCLUDEDIR}/rpc; \ done ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361658 - head/sys/rpc
Author: rmacklem Date: Sun May 31 01:12:52 2020 New Revision: 361658 URL: https://svnweb.freebsd.org/changeset/base/361658 Log: Add the .h file that describes the operations for the rpctls_syscall. This .h file will be used by the nfs-over-tls daemons to do the system call that was added by r361599. Added: head/sys/rpc/rpcsec_tls.h (contents, props changed) Added: head/sys/rpc/rpcsec_tls.h == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/rpc/rpcsec_tls.h Sun May 31 01:12:52 2020(r361658) @@ -0,0 +1,82 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 Rick Macklem + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef_RPC_RPCSEC_TLS_H_ +#define_RPC_RPCSEC_TLS_H_ + +/* Operation values for rpctls syscall. */ +#defineRPCTLS_SYSC_CLSETPATH 1 +#defineRPCTLS_SYSC_CLSOCKET2 +#defineRPCTLS_SYSC_CLSHUTDOWN 3 +#defineRPCTLS_SYSC_SRVSETPATH 4 +#defineRPCTLS_SYSC_SRVSOCKET 5 +#defineRPCTLS_SYSC_SRVSHUTDOWN 6 + +/* System call used by the rpctlscd, rpctlssd daemons. */ +intrpctls_syscall(int, const char *); + +/* Flag bits to indicate certificate results. */ +#defineRPCTLS_FLAGS_HANDSHAKE 0x01 +#defineRPCTLS_FLAGS_GOTCERT0x02 +#defineRPCTLS_FLAGS_SELFSIGNED 0x04 +#defineRPCTLS_FLAGS_VERIFIED 0x08 +#defineRPCTLS_FLAGS_DISABLED 0x10 +#defineRPCTLS_FLAGS_CERTUSER 0x20 + +/* Error return values for upcall rpcs. */ +#defineRPCTLSERR_OK0 +#defineRPCTLSERR_NOCLOSE 1 +#defineRPCTLSERR_NOSSL 2 +#defineRPCTLSERR_NOSOCKET 3 + +#ifdef _KERNEL +/* Functions that perform upcalls to the rpctlsd daemon. */ +enum clnt_stat rpctls_connect(CLIENT *newclient, struct socket *so, + uint64_t *sslp, uint32_t *reterr); +enum clnt_stat rpctls_cl_handlerecord(uint64_t sec, uint64_t usec, + uint64_t ssl, uint32_t *reterr); +enum clnt_stat rpctls_srv_handlerecord(uint64_t sec, uint64_t usec, + uint64_t ssl, uint32_t *reterr); +enum clnt_stat rpctls_cl_disconnect(uint64_t sec, uint64_t usec, + uint64_t ssl, uint32_t *reterr); +enum clnt_stat rpctls_srv_disconnect(uint64_t sec, uint64_t usec, + uint64_t ssl, uint32_t *reterr); + +/* Initialization function for rpcsec_tls. */ +intrpctls_init(void); + +/* Get TLS information function. */ +bool rpctls_getinfo(u_int *maxlen); + +/* String for AUTH_TLS reply verifier. */ +#defineRPCTLS_START_STRING "STARTTLS" + +#endif /* _KERNEL */ + +#endif /* _RPC_RPCSEC_TLS_H_ */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361614 - head/sys/sys
Author: rmacklem Date: Fri May 29 00:10:19 2020 New Revision: 361614 URL: https://svnweb.freebsd.org/changeset/base/361614 Log: Oops two, missed syscall.mk as well. Modified: head/sys/sys/syscall.mk Modified: head/sys/sys/syscall.mk == --- head/sys/sys/syscall.mk Fri May 29 00:09:12 2020(r361613) +++ head/sys/sys/syscall.mk Fri May 29 00:10:19 2020(r361614) @@ -416,4 +416,5 @@ MIASM = \ shm_rename.o \ sigfastblock.o \ __realpathat.o \ - close_range.o + close_range.o \ + rpctls_syscall.o ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361610 - head/sys/sys
Author: rmacklem Date: Thu May 28 23:57:50 2020 New Revision: 361610 URL: https://svnweb.freebsd.org/changeset/base/361610 Log: Oops, missed syscall.h and sysproto.h for r361602. Pointy hat goes on me. Modified: head/sys/sys/syscall.h head/sys/sys/sysproto.h Modified: head/sys/sys/syscall.h == --- head/sys/sys/syscall.h Thu May 28 23:55:46 2020(r361609) +++ head/sys/sys/syscall.h Thu May 28 23:57:50 2020(r361610) @@ -511,4 +511,5 @@ #defineSYS_sigfastblock573 #defineSYS___realpathat574 #defineSYS_close_range 575 -#defineSYS_MAXSYSCALL 576 +#defineSYS_rpctls_syscall 576 +#defineSYS_MAXSYSCALL 577 Modified: head/sys/sys/sysproto.h == --- head/sys/sys/sysproto.h Thu May 28 23:55:46 2020(r361609) +++ head/sys/sys/sysproto.h Thu May 28 23:57:50 2020(r361610) @@ -1832,6 +1832,10 @@ struct close_range_args { char highfd_l_[PADL_(u_int)]; u_int highfd; char highfd_r_[PADR_(u_int)]; char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; }; +struct rpctls_syscall_args { + char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; +}; intnosys(struct thread *, struct nosys_args *); void sys_sys_exit(struct thread *, struct sys_exit_args *); intsys_fork(struct thread *, struct fork_args *); @@ -,6 +2226,7 @@ int sys_shm_rename(struct thread *, struct shm_rename_ intsys_sigfastblock(struct thread *, struct sigfastblock_args *); intsys___realpathat(struct thread *, struct __realpathat_args *); intsys_close_range(struct thread *, struct close_range_args *); +intsys_rpctls_syscall(struct thread *, struct rpctls_syscall_args *); #ifdef COMPAT_43 @@ -3152,6 +3157,7 @@ int freebsd12_closefrom(struct thread *, struct freebs #defineSYS_AUE_sigfastblockAUE_NULL #defineSYS_AUE___realpathatAUE_REALPATHAT #defineSYS_AUE_close_range AUE_CLOSERANGE +#defineSYS_AUE_rpctls_syscall AUE_NULL #undef PAD_ #undef PADL_ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361603 - head/lib/libc/sys
Author: rmacklem Date: Thu May 28 21:26:26 2020 New Revision: 361603 URL: https://svnweb.freebsd.org/changeset/base/361603 Log: Add an entry to Symbol.map for the rpctls_syscall added by r361599. Reviewed by: brooks Differential Revision:https://reviews.freebsd.org/D24949 Modified: head/lib/libc/sys/Symbol.map Modified: head/lib/libc/sys/Symbol.map == --- head/lib/libc/sys/Symbol.mapThu May 28 21:23:02 2020 (r361602) +++ head/lib/libc/sys/Symbol.mapThu May 28 21:26:26 2020 (r361603) @@ -1033,4 +1033,5 @@ FBSDprivate_1.0 { __sys_cpuset_getdomain; _cpuset_setdomain; __sys_cpuset_setdomain; + rpctls_syscall; }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361602 - in head/sys: compat/freebsd32 kern
Author: rmacklem Date: Thu May 28 21:23:02 2020 New Revision: 361602 URL: https://svnweb.freebsd.org/changeset/base/361602 Log: Update the files created from the new syscalls.master from r361599. Reviewed by: brooks Differential Revision:https://reviews.freebsd.org/D24949 Modified: head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/freebsd32/freebsd32_systrace_args.c head/sys/kern/init_sysent.c head/sys/kern/syscalls.c head/sys/kern/systrace_args.c Modified: head/sys/compat/freebsd32/freebsd32_syscall.h == --- head/sys/compat/freebsd32/freebsd32_syscall.h Thu May 28 21:22:30 2020(r361601) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Thu May 28 21:23:02 2020(r361602) @@ -502,4 +502,5 @@ #defineFREEBSD32_SYS_sigfastblock 573 #defineFREEBSD32_SYS___realpathat 574 #defineFREEBSD32_SYS_close_range 575 -#defineFREEBSD32_SYS_MAXSYSCALL576 +#defineFREEBSD32_SYS_rpctls_syscall576 +#defineFREEBSD32_SYS_MAXSYSCALL577 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c == --- head/sys/compat/freebsd32/freebsd32_syscalls.c Thu May 28 21:22:30 2020(r361601) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Thu May 28 21:23:02 2020(r361602) @@ -612,4 +612,5 @@ const char *freebsd32_syscallnames[] = { "sigfastblock", /* 573 = sigfastblock */ "__realpathat", /* 574 = __realpathat */ "close_range", /* 575 = close_range */ + "rpctls_syscall", /* 576 = rpctls_syscall */ }; Modified: head/sys/compat/freebsd32/freebsd32_sysent.c == --- head/sys/compat/freebsd32/freebsd32_sysent.cThu May 28 21:22:30 2020(r361601) +++ head/sys/compat/freebsd32/freebsd32_sysent.cThu May 28 21:23:02 2020(r361602) @@ -665,4 +665,5 @@ struct sysent freebsd32_sysent[] = { { AS(sigfastblock_args), (sy_call_t *)sys_sigfastblock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 573 = sigfastblock */ { AS(__realpathat_args), (sy_call_t *)sys___realpathat, AUE_REALPATHAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 574 = __realpathat */ { AS(close_range_args), (sy_call_t *)sys_close_range, AUE_CLOSERANGE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 575 = close_range */ + { AS(rpctls_syscall_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },/* 576 = rpctls_syscall */ }; Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c == --- head/sys/compat/freebsd32/freebsd32_systrace_args.c Thu May 28 21:22:30 2020(r361601) +++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Thu May 28 21:23:02 2020(r361602) @@ -3376,6 +3376,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg *n_args = 3; break; } + /* rpctls_syscall */ + case 576: { + struct rpctls_syscall_args *p = params; + iarg[0] = p->op; /* int */ + uarg[1] = (intptr_t) p->path; /* const char * */ + *n_args = 2; + break; + } default: *n_args = 0; break; @@ -9103,6 +9111,19 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; }; break; + /* rpctls_syscall */ + case 576: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "userland const char *"; + break; + default: + break; + }; + break; default: break; }; @@ -10999,6 +11020,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* close_range */ case 575: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* rpctls_syscall */ + case 576: if (ndx == 0 || ndx == 1) p = "int"; break; Modified: head/sys/kern/init_sysent.c == --- head/sys/kern/init_sysent.c Thu May 28 21:22:30 2020(r361601) +++ head/sys/kern/init_sysent.c Thu May 28 21:23:02 2020(r361602) @@ -631,4 +631,5 @@ struct sysent sysent[] = {
svn commit: r361599 - in head/sys: compat/freebsd32 kern
Author: rmacklem Date: Thu May 28 21:06:10 2020 New Revision: 361599 URL: https://svnweb.freebsd.org/changeset/base/361599 Log: Add a syscall for the nfs-over-tls daemons to use. The nfs-over-tls daemons need a system call to perform operations such as associate a file descriptor with a krpc socket. The daemons will not be in head for some time, but it will make it easier for testers of nfs-over-tls to do testing if the system call is in head (basically the stub for libc which will be commited soon). Reviewed by: brooks Differential Revision:https://reviews.freebsd.org/D24949 Modified: head/sys/compat/freebsd32/syscalls.master head/sys/kern/syscalls.master Modified: head/sys/compat/freebsd32/syscalls.master == --- head/sys/compat/freebsd32/syscalls.master Thu May 28 21:02:12 2020 (r361598) +++ head/sys/compat/freebsd32/syscalls.master Thu May 28 21:06:10 2020 (r361599) @@ -1164,5 +1164,8 @@ char *buf, size_t size, int flags); } 575AUE_CLOSERANGE NOPROTO { int close_range(u_int lowfd, u_int highfd, \ int flags); } +; 576 is initialised by the krpc code, if present. +576AUE_NULLNOSTD|NOPROTO { int rpctls_syscall(int op, \ + const char *path); } ; vim: syntax=off Modified: head/sys/kern/syscalls.master == --- head/sys/kern/syscalls.master Thu May 28 21:02:12 2020 (r361598) +++ head/sys/kern/syscalls.master Thu May 28 21:06:10 2020 (r361599) @@ -3234,6 +3234,13 @@ int flags ); } +; 576 is initialised by the krpc code, if present. +576AUE_NULLNOSTD { + int rpctls_syscall( + int op, + _In_z_ const char *path + ); + } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361567 - head/sys/kern
Author: rmacklem Date: Wed May 27 23:20:35 2020 New Revision: 361567 URL: https://svnweb.freebsd.org/changeset/base/361567 Log: Fix sosend() for the case where mbufs are passed in while doing ktls. For kernel tls, sosend() needs to call ktls_frame() on the mbuf list to be sent. Without this patch, this was only done when sosend()'s arguments used a uio_iov and not when an mbuf list is passed in. At this time, sosend() is never called with an mbuf list argument when kernel tls is in use, but will be once nfs-over-tls has been incorporated into head. Reviewed by: gallatin, glebius Differential Revision:https://reviews.freebsd.org/D24674 Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Wed May 27 22:48:34 2020(r361566) +++ head/sys/kern/uipc_socket.c Wed May 27 23:20:35 2020(r361567) @@ -1678,6 +1678,13 @@ restart: resid = 0; if (flags & MSG_EOR) top->m_flags |= M_EOR; +#ifdef KERN_TLS + if (tls != NULL) { + ktls_frame(top, tls, _enq_cnt, + tls_rtype); + tls_rtype = TLS_RLTYPE_APP; + } +#endif } else { /* * Copy the data from userland into a mbuf ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361146 - in head/sys/fs: nfs nfsserver
Author: rmacklem Date: Mon May 18 00:07:45 2020 New Revision: 361146 URL: https://svnweb.freebsd.org/changeset/base/361146 Log: Add a function nfsm_set() to initialize "struct nfsrv_descript" for building mbuf lists. This function is currently trivial, but will that will change when support for building NFS messages in ext_pgs mbufs is added. Adding support for ext_pgs mbufs is needed for KERN_TLS, which will be used to implement nfs-over-tls. Modified: head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfs_var.h head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cSun May 17 22:31:38 2020 (r361145) +++ head/sys/fs/nfs/nfs_commonsubs.cMon May 18 00:07:45 2020 (r361146) @@ -4778,3 +4778,14 @@ nfsv4_findmirror(struct nfsmount *nmp) return (ds); } +/* + * Fill in the fields of "struct nfsrv_descript". + */ +void +nfsm_set(struct nfsrv_descript *nd, u_int offs) +{ + struct mbuf *m; + + m = nd->nd_mb; + nd->nd_bpos = mtod(m, char *) + offs; +} Modified: head/sys/fs/nfs/nfs_var.h == --- head/sys/fs/nfs/nfs_var.h Sun May 17 22:31:38 2020(r361145) +++ head/sys/fs/nfs/nfs_var.h Mon May 18 00:07:45 2020(r361146) @@ -360,6 +360,7 @@ int nfsv4_sequencelookup(struct nfsmount *, struct nfs void nfsv4_freeslot(struct nfsclsession *, int); struct ucred *nfsrv_getgrpscred(struct ucred *); struct nfsdevice *nfsv4_findmirror(struct nfsmount *); +void nfsm_set(struct nfsrv_descript *, u_int); /* nfs_clcomsubs.c */ void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int); Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cSun May 17 22:31:38 2020 (r361145) +++ head/sys/fs/nfsserver/nfs_nfsdport.cMon May 18 00:07:45 2020 (r361146) @@ -5080,7 +5080,7 @@ nfsrv_writedsdorpc(struct nfsmount *nmp, fhandle_t *fh while (m->m_next != NULL) m = m->m_next; nd->nd_mb = m; - nd->nd_bpos = mtod(m, char *) + m->m_len; + nfsm_set(nd, m->m_len); NFSD_DEBUG(4, "nfsrv_writedsdorpc: lastmb len=%d\n", m->m_len); /* Do a Getattr for the attributes that change upon writing. */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360678 - head/sys/fs/nfs
Author: rmacklem Date: Wed May 6 00:44:03 2020 New Revision: 360678 URL: https://svnweb.freebsd.org/changeset/base/360678 Log: Delete unused function newnfs_trimleading. The NFS function called newnfs_trimleading() has not been used by the code in long time. To give you a clue, it still had a K style function declaration. Delete it, since it is just cruft, as a part of the NFS mbuf handling cleanup in preparation for adding ext_pgs mbuf support. The ext_pgs mbuf support for the build/send side is needed by nfs-over-tls. Modified: head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfs_var.h Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cWed May 6 00:25:43 2020 (r360677) +++ head/sys/fs/nfs/nfs_commonsubs.cWed May 6 00:44:03 2020 (r360678) @@ -1006,53 +1006,6 @@ nfsaddr2_match(NFSSOCKADDR_T nam1, NFSSOCKADDR_T nam2) return (0); } - -/* - * Trim the stuff already dissected off the mbuf list. - */ -APPLESTATIC void -newnfs_trimleading(nd) - struct nfsrv_descript *nd; -{ - struct mbuf *m, *n; - int offs; - - /* -* First, free up leading mbufs. -*/ - if (nd->nd_mrep != nd->nd_md) { - m = nd->nd_mrep; - while (m->m_next != nd->nd_md) { - if (m->m_next == NULL) - panic("nfsm trim leading"); - m = m->m_next; - } - m->m_next = NULL; - m_freem(nd->nd_mrep); - } - m = nd->nd_md; - - /* -* Now, adjust this mbuf, based on nd_dpos. -*/ - offs = nd->nd_dpos - mtod(m, caddr_t); - if (offs == m->m_len) { - n = m; - m = m->m_next; - if (m == NULL) - panic("nfsm trim leading2"); - n->m_next = NULL; - m_freem(n); - } else if (offs > 0) { - m->m_len -= offs; - m->m_data += offs; - } else if (offs < 0) - panic("nfsm trimleading offs"); - nd->nd_mrep = m; - nd->nd_md = m; - nd->nd_dpos = mtod(m, caddr_t); -} - /* * Trim trailing data off the mbuf list being built. */ Modified: head/sys/fs/nfs/nfs_var.h == --- head/sys/fs/nfs/nfs_var.h Wed May 6 00:25:43 2020(r360677) +++ head/sys/fs/nfs/nfs_var.h Wed May 6 00:44:03 2020(r360678) @@ -324,7 +324,6 @@ int nfsm_mbufuio(struct nfsrv_descript *, struct uio * int nfsm_fhtom(struct nfsrv_descript *, u_int8_t *, int, int); int nfsm_advance(struct nfsrv_descript *, int, int); void *nfsm_dissct(struct nfsrv_descript *, int, int); -void newnfs_trimleading(struct nfsrv_descript *); void newnfs_trimtrailing(struct nfsrv_descript *, struct mbuf *, caddr_t); void newnfs_copycred(struct nfscred *, struct ucred *); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360650 - head/sys/fs/nfs
Author: rmacklem Date: Tue May 5 00:58:03 2020 New Revision: 360650 URL: https://svnweb.freebsd.org/changeset/base/360650 Log: Revert r360514, to avoid unnecessary churn of the sources. r360514 prepared the NFS code for changes to handle ext_pgs mbufs on the receive side. However, at this time, KERN_TLS does not pass ext_pgs mbufs up through soreceive(). As such, as this time, only the send/build side of the NFS mbuf code needs to handle ext_pgs mbufs. Revert r360514 since the rather extensive changes required for receive side ext_pgs mbufs are not yet needed. This avoids unnecessary churn of the sources. Modified: head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfs_var.h Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cTue May 5 00:08:41 2020 (r360649) +++ head/sys/fs/nfs/nfs_commonsubs.cTue May 5 00:58:03 2020 (r360650) @@ -229,8 +229,6 @@ static void nfsrv_removeuser(struct nfsusrgrp *usrp, i static int nfsrv_getrefstr(struct nfsrv_descript *, u_char **, u_char **, int *, int *); static void nfsrv_refstrbigenough(int, u_char **, u_char **, int *); -static int nfsm_copyfrommbuf(struct nfsrv_descript *, char *, enum uio_seg, -int); static struct { int op; @@ -703,49 +701,52 @@ nfsm_dissct(struct nfsrv_descript *nd, int siz, int ho caddr_t retp; retp = NULL; - left = mtod(nd->nd_md, char *) + nd->nd_md->m_len - - nd->nd_dpos; + left = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; while (left == 0) { - if (!nfsm_shiftnext(nd, )) - return (NULL); + nd->nd_md = nd->nd_md->m_next; + if (nd->nd_md == NULL) + return (retp); + left = nd->nd_md->m_len; + nd->nd_dpos = mtod(nd->nd_md, caddr_t); } if (left >= siz) { retp = nd->nd_dpos; nd->nd_dpos += siz; + } else if (nd->nd_md->m_next == NULL) { + return (retp); } else if (siz > ncl_mbuf_mhlen) { panic("nfs S too big"); } else { - /* Allocate a new mbuf for the "siz" bytes of data. */ MGET(mp2, MT_DATA, how); if (mp2 == NULL) return (NULL); - - /* -* Link the new mp2 mbuf into the list then copy left -* bytes from the mbuf before it and siz - left bytes -* from the mbuf(s) after it. -*/ mp2->m_next = nd->nd_md->m_next; nd->nd_md->m_next = mp2; nd->nd_md->m_len -= left; - retp = p = mtod(mp2, char *); - memcpy(p, nd->nd_dpos, left); /* Copy what was left */ + nd->nd_md = mp2; + retp = p = mtod(mp2, caddr_t); + NFSBCOPY(nd->nd_dpos, p, left); /* Copy what was left */ siz2 = siz - left; p += left; - mp2->m_len = siz; - nd->nd_md = mp2->m_next; + mp2 = mp2->m_next; /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { - if (nd->nd_md == NULL) + if (mp2 == NULL) return (NULL); - nfsm_set(nd, 0, false); - xfer = nfsm_copyfrommbuf(nd, p, - UIO_SYSSPACE, siz2); - p += xfer; - siz2 -= xfer; + xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; + if (xfer > 0) { + NFSBCOPY(mtod(mp2, caddr_t), p, xfer); + mp2->m_data += xfer; + mp2->m_len -= xfer; + p += xfer; + siz2 -= xfer; + } if (siz2 > 0) - nd->nd_md = nd->nd_md->m_next; + mp2 = mp2->m_next; } + nd->nd_md->m_len = siz; + nd->nd_md = mp2; + nd->nd_dpos = mtod(mp2, caddr_t); } return (retp); } @@ -4824,76 +4825,5 @@ nfsv4_findmirror(struct nfsmount *nmp) } } return (ds); -} - -/* - * Fill in the fields of "struct nfsrv_descript" for a new ext_pgs mbuf. - * The build argument is true for build and false for dissect. - */ -int -nfsm_set(struct nfsrv_descript *nd, u_int offs, bool build) -{ - struct mbuf *m; - int rlen; - - if (build) - m = nd->nd_mb; - else - m = nd->nd_md; - if (build) { - nd->nd_bpos = mtod(m, char *) + offs; -
svn commit: r360556 - stable/11/sys/fs/nfsserver
Author: rmacklem Date: Fri May 1 23:07:23 2020 New Revision: 360556 URL: https://svnweb.freebsd.org/changeset/base/360556 Log: MFC: r360032 Add a sanity check for nes_numsecflavor to the NFS server. Ryan Moeller reported crashes in the NFS server that appear to be caused by stack corruption in nfsrv_compound(). It appears that the stack got corrupted just after a NFSv4.1 Lookup that crosses a server mount point. Although it is just a "theory" at this point, the most obvious way the stack could get corrupted would be if nfsvno_checkexp() somehow acquires an export with a bogus nes_numsecflavor value. This would cause the copying of the secflavors to run off the end of the array, which is allocated on the stack below where the corruption occurs. This sanity check is simple to do and would stop the stack corruption if the theory is correct. Otherwise, doing the sanity check seems to be a reasonable safety belt to add to the code. Modified: stable/11/sys/fs/nfsserver/nfs_nfsdport.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsserver/nfs_nfsdport.c == --- stable/11/sys/fs/nfsserver/nfs_nfsdport.c Fri May 1 22:37:09 2020 (r360555) +++ stable/11/sys/fs/nfsserver/nfs_nfsdport.c Fri May 1 23:07:23 2020 (r360556) @@ -2746,6 +2746,11 @@ nfsvno_checkexp(struct mount *mp, struct sockaddr *nam exp->nes_numsecflavor = 0; error = 0; } + } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > + MAXSECFLAVORS) { + printf("nfsvno_checkexp: numsecflavors out of range\n"); + exp->nes_numsecflavor = 0; + error = EACCES; } else { /* Copy the security flavors. */ for (i = 0; i < exp->nes_numsecflavor; i++) @@ -2782,6 +2787,12 @@ nfsvno_fhtovp(struct mount *mp, fhandle_t *fhp, struct } else { vput(*vpp); } + } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > + MAXSECFLAVORS) { + printf("nfsvno_fhtovp: numsecflavors out of range\n"); + exp->nes_numsecflavor = 0; + error = EACCES; + vput(*vpp); } else { /* Copy the security flavors. */ for (i = 0; i < exp->nes_numsecflavor; i++) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360555 - stable/12/sys/fs/nfsserver
Author: rmacklem Date: Fri May 1 22:37:09 2020 New Revision: 360555 URL: https://svnweb.freebsd.org/changeset/base/360555 Log: MFC: r360032 Add a sanity check for nes_numsecflavor to the NFS server. Ryan Moeller reported crashes in the NFS server that appear to be caused by stack corruption in nfsrv_compound(). It appears that the stack got corrupted just after a NFSv4.1 Lookup that crosses a server mount point. Although it is just a "theory" at this point, the most obvious way the stack could get corrupted would be if nfsvno_checkexp() somehow acquires an export with a bogus nes_numsecflavor value. This would cause the copying of the secflavors to run off the end of the array, which is allocated on the stack below where the corruption occurs. This sanity check is simple to do and would stop the stack corruption if the theory is correct. Otherwise, doing the sanity check seems to be a reasonable safety belt to add to the code. Modified: stable/12/sys/fs/nfsserver/nfs_nfsdport.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfsserver/nfs_nfsdport.c == --- stable/12/sys/fs/nfsserver/nfs_nfsdport.c Fri May 1 21:59:47 2020 (r360554) +++ stable/12/sys/fs/nfsserver/nfs_nfsdport.c Fri May 1 22:37:09 2020 (r360555) @@ -3015,6 +3015,11 @@ nfsvno_checkexp(struct mount *mp, struct sockaddr *nam exp->nes_numsecflavor = 0; error = 0; } + } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > + MAXSECFLAVORS) { + printf("nfsvno_checkexp: numsecflavors out of range\n"); + exp->nes_numsecflavor = 0; + error = EACCES; } else { /* Copy the security flavors. */ for (i = 0; i < exp->nes_numsecflavor; i++) @@ -3051,6 +3056,12 @@ nfsvno_fhtovp(struct mount *mp, fhandle_t *fhp, struct } else { vput(*vpp); } + } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > + MAXSECFLAVORS) { + printf("nfsvno_fhtovp: numsecflavors out of range\n"); + exp->nes_numsecflavor = 0; + error = EACCES; + vput(*vpp); } else { /* Copy the security flavors. */ for (i = 0; i < exp->nes_numsecflavor; i++) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360514 - head/sys/fs/nfs
Author: rmacklem Date: Fri May 1 00:36:14 2020 New Revision: 360514 URL: https://svnweb.freebsd.org/changeset/base/360514 Log: Factor some code out of nfsm_dissct() into separate functions. Factoring some of the code in nfsm_dissct() out into separate functions allows these functions to be used elsewhere in the NFS mbuf handling code. Other uses of these functions will be done in future commits. It also makes it easier to add support for ext_pgs mbufs, which is needed for nfs-over-tls under development in base/projects/nfs-over-tls. Although the algorithm in nfsm_dissct() is somewhat re-written by this patch, the semantics of nfsm_dissct() should not have changed. Modified: head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfs_var.h Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cThu Apr 30 23:41:22 2020 (r360513) +++ head/sys/fs/nfs/nfs_commonsubs.cFri May 1 00:36:14 2020 (r360514) @@ -229,6 +229,8 @@ static void nfsrv_removeuser(struct nfsusrgrp *usrp, i static int nfsrv_getrefstr(struct nfsrv_descript *, u_char **, u_char **, int *, int *); static void nfsrv_refstrbigenough(int, u_char **, u_char **, int *); +static int nfsm_copyfrommbuf(struct nfsrv_descript *, char *, enum uio_seg, +int); static struct { int op; @@ -701,52 +703,49 @@ nfsm_dissct(struct nfsrv_descript *nd, int siz, int ho caddr_t retp; retp = NULL; - left = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; + left = mtod(nd->nd_md, char *) + nd->nd_md->m_len - + nd->nd_dpos; while (left == 0) { - nd->nd_md = nd->nd_md->m_next; - if (nd->nd_md == NULL) - return (retp); - left = nd->nd_md->m_len; - nd->nd_dpos = mtod(nd->nd_md, caddr_t); + if (!nfsm_shiftnext(nd, )) + return (NULL); } if (left >= siz) { retp = nd->nd_dpos; nd->nd_dpos += siz; - } else if (nd->nd_md->m_next == NULL) { - return (retp); } else if (siz > ncl_mbuf_mhlen) { panic("nfs S too big"); } else { + /* Allocate a new mbuf for the "siz" bytes of data. */ MGET(mp2, MT_DATA, how); if (mp2 == NULL) return (NULL); + + /* +* Link the new mp2 mbuf into the list then copy left +* bytes from the mbuf before it and siz - left bytes +* from the mbuf(s) after it. +*/ mp2->m_next = nd->nd_md->m_next; nd->nd_md->m_next = mp2; nd->nd_md->m_len -= left; - nd->nd_md = mp2; - retp = p = mtod(mp2, caddr_t); - NFSBCOPY(nd->nd_dpos, p, left); /* Copy what was left */ + retp = p = mtod(mp2, char *); + memcpy(p, nd->nd_dpos, left); /* Copy what was left */ siz2 = siz - left; p += left; - mp2 = mp2->m_next; + mp2->m_len = siz; + nd->nd_md = mp2->m_next; /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { - if (mp2 == NULL) + if (nd->nd_md == NULL) return (NULL); - xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; - if (xfer > 0) { - NFSBCOPY(mtod(mp2, caddr_t), p, xfer); - mp2->m_data += xfer; - mp2->m_len -= xfer; - p += xfer; - siz2 -= xfer; - } + nfsm_set(nd, 0, false); + xfer = nfsm_copyfrommbuf(nd, p, + UIO_SYSSPACE, siz2); + p += xfer; + siz2 -= xfer; if (siz2 > 0) - mp2 = mp2->m_next; + nd->nd_md = nd->nd_md->m_next; } - nd->nd_md->m_len = siz; - nd->nd_md = mp2; - nd->nd_dpos = mtod(mp2, caddr_t); } return (retp); } @@ -4825,5 +4824,76 @@ nfsv4_findmirror(struct nfsmount *nmp) } } return (ds); +} + +/* + * Fill in the fields of "struct nfsrv_descript" for a new ext_pgs mbuf. + * The build argument is true for build and false for dissect. + */ +int +nfsm_set(struct nfsrv_descript *nd, u_int offs, bool build) +{ + struct mbuf *m; + int rlen; + + if (build) + m = nd->nd_mb; + else + m = nd->nd_md; + if (build) { +
svn commit: r360424 - in head/sys/fs: nfs nfsclient
Author: rmacklem Date: Tue Apr 28 02:11:02 2020 New Revision: 360424 URL: https://svnweb.freebsd.org/changeset/base/360424 Log: Get rid of uio_XXX macros used for the Mac OS/X port. The NFS code had a bunch of Mac OS/X accessor functions named uio_XXX left over from the port to Mac OS/X. Since that port is long forgotten, replace the calls with the code generated by the FreeBSD macros for these in nfskpiport.h. This allows the macros to be deleted from nfskpiport.h and I think makes the code more readable. This patch should not result in any semantic change. Modified: head/sys/fs/nfs/nfskpiport.h head/sys/fs/nfsclient/nfs_clrpcops.c Modified: head/sys/fs/nfs/nfskpiport.h == --- head/sys/fs/nfs/nfskpiport.hTue Apr 28 02:08:55 2020 (r360423) +++ head/sys/fs/nfs/nfskpiport.hTue Apr 28 02:11:02 2020 (r360424) @@ -43,20 +43,4 @@ typedef struct vnode * vnode_t; #definevnode_mount(v) ((v)->v_mount) #definevnode_vtype(v) ((v)->v_type) -/* - * This stuff is needed by Darwin for handling the uio structure. - */ -#defineuio_uio_resid(p)((p)->uio_resid) -#defineuio_uio_resid_add(p, v) ((p)->uio_resid += (v)) -#defineuio_uio_resid_set(p, v) ((p)->uio_resid = (v)) -#defineuio_iov_base(p) ((p)->uio_iov->iov_base) -#defineuio_iov_base_add(p, v) do { \ - char *pp; \ - pp = (char *)(p)->uio_iov->iov_base;\ - pp += (v); \ - (p)->uio_iov->iov_base = (void *)pp;\ -} while (0) -#defineuio_iov_len(p) ((p)->uio_iov->iov_len) -#defineuio_iov_len_add(p, v) ((p)->uio_iov->iov_len += (v)) - #endif /* _NFS_NFSKPIPORT_H */ Modified: head/sys/fs/nfsclient/nfs_clrpcops.c == --- head/sys/fs/nfsclient/nfs_clrpcops.cTue Apr 28 02:08:55 2020 (r360423) +++ head/sys/fs/nfsclient/nfs_clrpcops.cTue Apr 28 02:11:02 2020 (r360424) @@ -1617,7 +1617,7 @@ nfsrpc_readrpc(vnode_t vp, struct uio *uiop, struct uc off_t tmp_off; *attrflagp = 0; - tsiz = uio_uio_resid(uiop); + tsiz = uiop->uio_resid; tmp_off = uiop->uio_offset + tsiz; NFSLOCKMNT(nmp); if (tmp_off > nmp->nm_maxfilesize || tmp_off < uiop->uio_offset) { @@ -1793,7 +1793,7 @@ nfsrpc_writerpc(vnode_t vp, struct uio *uiop, int *iom KASSERT(uiop->uio_iovcnt == 1, ("nfs: writerpc iovcnt > 1")); *attrflagp = 0; - tsiz = uio_uio_resid(uiop); + tsiz = uiop->uio_resid; tmp_off = uiop->uio_offset + tsiz; NFSLOCKMNT(nmp); if (tmp_off > nmp->nm_maxfilesize || tmp_off < uiop->uio_offset) { @@ -1878,9 +1878,10 @@ nfsrpc_writerpc(vnode_t vp, struct uio *uiop, int *iom * back. */ uiop->uio_offset -= len; - uio_uio_resid_add(uiop, len); - uio_iov_base_add(uiop, -len); - uio_iov_len_add(uiop, len); + uiop->uio_resid += len; + uiop->uio_iov->iov_base = + (char *)uiop->uio_iov->iov_base - len; + uiop->uio_iov->iov_len += len; } if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) { error = nfscl_wcc_data(nd, vp, nap, attrflagp, @@ -1898,10 +1899,12 @@ nfsrpc_writerpc(vnode_t vp, struct uio *uiop, int *iom goto nfsmout; } else if (rlen < len) { backup = len - rlen; - uio_iov_base_add(uiop, -(backup)); - uio_iov_len_add(uiop, backup); + uiop->uio_iov->iov_base = + (char *)uiop->uio_iov->iov_base - + backup; + uiop->uio_iov->iov_len += backup; uiop->uio_offset -= backup; - uio_uio_resid_add(uiop, backup); + uiop->uio_resid += backup; len = rlen; } commit = fxdr_unsigned(int, *tl++); @@ -2925,7 +2928,7 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 size_t tresid; KASSERT(uiop->uio_iovcnt == 1 && - (uio_uio_resid(uiop) & (DIRBLKSIZ - 1)) == 0, +
svn commit: r360416 - head/sys/kern
Author: rmacklem Date: Mon Apr 27 23:55:09 2020 New Revision: 360416 URL: https://svnweb.freebsd.org/changeset/base/360416 Log: Fix sosend_generic() so that it can handle a list of ext_pgs mbufs. Without this patch, sosend_generic() will try to use top->m_pkthdr.len, assuming that the first mbuf has a pkthdr. When a list of ext_pgs mbufs is passed in, the first mbuf is not a pkthdr and cannot be post-r359919. As such, the value of top->m_pkthdr.len is bogus (0 for my testing). This patch fixes sosend_generic() to handle this case, calculating the total length via m_length() for this case. There is currently nothing that hands a list of ext_pgs mbufs to sosend_generic(), but the nfs-over-tls kernel RPC code in projects/nfs-over-tls will do that and was used to test this patch. Reviewed by: gallatin Differential Revision:https://reviews.freebsd.org/D24568 Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Mon Apr 27 23:49:13 2020(r360415) +++ head/sys/kern/uipc_socket.c Mon Apr 27 23:55:09 2020(r360416) @@ -1557,8 +1557,10 @@ sosend_generic(struct socket *so, struct sockaddr *add #endif if (uio != NULL) resid = uio->uio_resid; - else + else if ((top->m_flags & M_PKTHDR) != 0) resid = top->m_pkthdr.len; + else + resid = m_length(top, NULL); /* * In theory resid should be unsigned. However, space must be * signed, as it might be less than 0 if we over-committed, and we ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360289 - in head/sys/fs: nfs nfsclient nfsserver
Author: rmacklem Date: Sat Apr 25 02:18:59 2020 New Revision: 360289 URL: https://svnweb.freebsd.org/changeset/base/360289 Log: Remove Mac OS/X macros that did nothing for FreeBSD. The macros CAST_USER_ADDR_T() and CAST_DOWN() were used for the Mac OS/X port. The first of these macros was a no-op for FreeBSD and the second is no longer used. This patch gets rid of them. It also deletes the "mbuf_t" typedef which is no longer used in the FreeBSD code from nfskpiport.h This patch should not change semantics. Modified: head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfskpiport.h head/sys/fs/nfsclient/nfs_clcomsubs.c head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cSat Apr 25 00:57:48 2020 (r360288) +++ head/sys/fs/nfs/nfs_commonsubs.cSat Apr 25 02:18:59 2020 (r360289) @@ -652,7 +652,7 @@ nfsm_mbufuio(struct nfsrv_descript *nd, struct uio *ui if (uiop->uio_segflg == UIO_SYSSPACE) NFSBCOPY(mbufcp, uiocp, xfer); else - copyout(mbufcp, CAST_USER_ADDR_T(uiocp), xfer); + copyout(mbufcp, uiocp, xfer); left -= xfer; len -= xfer; mbufcp += xfer; @@ -3759,8 +3759,7 @@ nfssvc_idname(struct nfsd_idargs *nidp) } if (nidp->nid_flag & NFSID_INITIALIZE) { cp = malloc(nidp->nid_namelen + 1, M_NFSSTRING, M_WAITOK); - error = copyin(CAST_USER_ADDR_T(nidp->nid_name), cp, - nidp->nid_namelen); + error = copyin(nidp->nid_name, cp, nidp->nid_namelen); if (error != 0) { free(cp, M_NFSSTRING); goto out; @@ -3856,13 +3855,13 @@ nfssvc_idname(struct nfsd_idargs *nidp) */ newusrp = malloc(sizeof(struct nfsusrgrp) + nidp->nid_namelen, M_NFSUSERGROUP, M_WAITOK | M_ZERO); - error = copyin(CAST_USER_ADDR_T(nidp->nid_name), newusrp->lug_name, + error = copyin(nidp->nid_name, newusrp->lug_name, nidp->nid_namelen); if (error == 0 && nidp->nid_ngroup > 0 && (nidp->nid_flag & NFSID_ADDUID) != 0) { grps = malloc(sizeof(gid_t) * nidp->nid_ngroup, M_TEMP, M_WAITOK); - error = copyin(CAST_USER_ADDR_T(nidp->nid_grps), grps, + error = copyin(nidp->nid_grps, grps, sizeof(gid_t) * nidp->nid_ngroup); if (error == 0) { /* Modified: head/sys/fs/nfs/nfskpiport.h == --- head/sys/fs/nfs/nfskpiport.hSat Apr 25 00:57:48 2020 (r360288) +++ head/sys/fs/nfs/nfskpiport.hSat Apr 25 02:18:59 2020 (r360289) @@ -43,13 +43,9 @@ typedef struct vnode * vnode_t; #definevnode_mount(v) ((v)->v_mount) #definevnode_vtype(v) ((v)->v_type) -typedef struct mbuf * mbuf_t; - /* * This stuff is needed by Darwin for handling the uio structure. */ -#defineCAST_USER_ADDR_T(a) (a) -#defineCAST_DOWN(c, a) ((c) (a)) #defineuio_uio_resid(p)((p)->uio_resid) #defineuio_uio_resid_add(p, v) ((p)->uio_resid += (v)) #defineuio_uio_resid_set(p, v) ((p)->uio_resid = (v)) Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c == --- head/sys/fs/nfsclient/nfs_clcomsubs.c Sat Apr 25 00:57:48 2020 (r360288) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Sat Apr 25 02:18:59 2020 (r360289) @@ -105,8 +105,7 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui NFSBCOPY(uiocp, mtod(mp, caddr_t) + mp->m_len, xfer); else - copyin(CAST_USER_ADDR_T(uiocp), mtod(mp, caddr_t) - + mp->m_len, xfer); + copyin(uiocp, mtod(mp, caddr_t) + mp->m_len, xfer); mp->m_len += xfer; left -= xfer; uiocp += xfer; Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cSat Apr 25 00:57:48 2020 (r360288) +++ head/sys/fs/nfsserver/nfs_nfsdport.cSat Apr 25 02:18:59 2020 (r360289) @@ -3712,8 +3712,7 @@ nfssvc_srvcall(struct thread *p, struct nfssvc_args *u len = sizeof (struct nfsd_dumpclients) * dumplist.ndl_size; dumpclients = malloc(len, M_TEMP,
svn commit: r360208 - stable/11/sys/fs/nfsserver
Author: rmacklem Date: Wed Apr 22 21:15:26 2020 New Revision: 360208 URL: https://svnweb.freebsd.org/changeset/base/360208 Log: MFC: r359720 Fix an interoperability issue w.r.t. the Linux client and the NFSv4 server. Luoqi Chen reported a problem on freebsd-fs@ where a Linux NFSv4 client was able to open and write to a file when the file's permissions were not set to allow the owner write access. Since NFS servers check file permissions on every write RPC, it is standard practice to allow the owner of the file to do writes, regardless of file permissions. This provides POSIX like behaviour, since POSIX only checks permissions upon open(2). The traditional way NFS clients handle this is to check access via the Access operation/RPC and use that to determine if an open(2) on the client is allowed. It appears that, for NFSv4, the Linux client expects the NFSv4 Open (not a POSIX open) operation to fail with NFSERR_ACCES if the file is not being created and file permissions do not allow owner access, unlike NFSv3. Since both the Linux and OpenSolaris NFSv4 servers seem to exhibit this behaviour, this patch changes the FreeBSD NFSv4 server to do the same. A sysctl called vfs.nfsd.v4openaccess can be set to 0 to return the NFSv4 server to its previous behaviour. Since both the Linux and FreeBSD NFSv4 clients seem to exhibit correct behaviour with the access check for file owner in Open enabled, it is enabled by default. Reported by: luoqi.c...@gmail.com Modified: stable/11/sys/fs/nfsserver/nfs_nfsdserv.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsserver/nfs_nfsdserv.c == --- stable/11/sys/fs/nfsserver/nfs_nfsdserv.c Wed Apr 22 21:08:08 2020 (r360207) +++ stable/11/sys/fs/nfsserver/nfs_nfsdserv.c Wed Apr 22 21:15:26 2020 (r360208) @@ -62,6 +62,10 @@ static int nfs_async = 0; SYSCTL_DECL(_vfs_nfsd); SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, _async, 0, "Tell client that writes were synced even though they were not"); +static boolnfsrv_openaccess = true; +SYSCTL_BOOL(_vfs_nfsd, OID_AUTO, v4openaccess, CTLFLAG_RW, +_openaccess, 0, +"Enable Linux style NFSv4 Open access check"); /* * This list defines the GSS mechanisms supported. @@ -2587,7 +2591,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is u_int32_t *tl; int i, retext; struct nfsstate *stp = NULL; - int error = 0, create, claim, exclusive_flag = 0; + int error = 0, create, claim, exclusive_flag = 0, override; u_int32_t rflags = NFSV4OPEN_LOCKTYPEPOSIX, acemask; int how = NFSCREATE_UNCHECKED; int32_t cverf[2], tverf[2] = { 0, 0 }; @@ -2890,15 +2894,38 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is */ nd->nd_repstat = (vp->v_type == VDIR) ? NFSERR_ISDIR : NFSERR_SYMLINK; } + + /* +* If the Open is being done for a file that already exists, apply +* normal permission checking including for the file owner, if +* vfs.nfsd.v4openaccess is set. +* Previously, the owner was always allowed to open the file to +* be consistent with the NFS tradition of always allowing the +* owner of the file to write to the file regardless of permissions. +* It now appears that the Linux client expects the owner +* permissions to be checked for opens that are not creating the +* file. I believe the correct approach is to use the Access +* operation's results to be consistent with NFSv3, but that is +* not what the current Linux client appears to be doing. +* Since both the Linux and OpenSolaris NFSv4 servers do this check, +* I have enabled it by default. +* If this semantic change causes a problem, it can be disabled by +* setting the sysctl vfs.nfsd.v4openaccess to 0 to re-enable the +* previous semantics. +*/ + if (nfsrv_openaccess && create == NFSV4OPEN_NOCREATE) + override = NFSACCCHK_NOOVERRIDE; + else + override = NFSACCCHK_ALLOWOWNER; if (!nd->nd_repstat && (stp->ls_flags & NFSLCK_WRITEACCESS)) nd->nd_repstat = nfsvno_accchk(vp, VWRITE, nd->nd_cred, - exp, p, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, NULL); + exp, p, override, NFSACCCHK_VPISLOCKED, NULL); if (!nd->nd_repstat && (stp->ls_flags & NFSLCK_READACCESS)) { nd->nd_repstat = nfsvno_accchk(vp, VREAD, nd->nd_cred, - exp, p, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, NULL); + exp, p, override, NFSACCCHK_VPISLOCKED, NULL); if (nd->nd_repstat) nd->nd_repstat = nfsvno_accchk(vp, VEXEC, - nd->nd_cred, exp, p, NFSACCCHK_ALLOWOWNER, +
svn commit: r360207 - stable/12/sys/fs/nfsserver
Author: rmacklem Date: Wed Apr 22 21:08:08 2020 New Revision: 360207 URL: https://svnweb.freebsd.org/changeset/base/360207 Log: MFC: r359720 Fix an interoperability issue w.r.t. the Linux client and the NFSv4 server. Luoqi Chen reported a problem on freebsd-fs@ where a Linux NFSv4 client was able to open and write to a file when the file's permissions were not set to allow the owner write access. Since NFS servers check file permissions on every write RPC, it is standard practice to allow the owner of the file to do writes, regardless of file permissions. This provides POSIX like behaviour, since POSIX only checks permissions upon open(2). The traditional way NFS clients handle this is to check access via the Access operation/RPC and use that to determine if an open(2) on the client is allowed. It appears that, for NFSv4, the Linux client expects the NFSv4 Open (not a POSIX open) operation to fail with NFSERR_ACCES if the file is not being created and file permissions do not allow owner access, unlike NFSv3. Since both the Linux and OpenSolaris NFSv4 servers seem to exhibit this behaviour, this patch changes the FreeBSD NFSv4 server to do the same. A sysctl called vfs.nfsd.v4openaccess can be set to 0 to return the NFSv4 server to its previous behaviour. Since both the Linux and FreeBSD NFSv4 clients seem to exhibit correct behaviour with the access check for file owner in Open enabled, it is enabled by default. Reported by: luoqi.c...@gmail.com Modified: stable/12/sys/fs/nfsserver/nfs_nfsdserv.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfsserver/nfs_nfsdserv.c == --- stable/12/sys/fs/nfsserver/nfs_nfsdserv.c Wed Apr 22 21:03:24 2020 (r360206) +++ stable/12/sys/fs/nfsserver/nfs_nfsdserv.c Wed Apr 22 21:08:08 2020 (r360207) @@ -74,6 +74,10 @@ SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, extern int nfsrv_doflexfile; SYSCTL_INT(_vfs_nfsd, OID_AUTO, default_flexfile, CTLFLAG_RW, _doflexfile, 0, "Make Flex File Layout the default for pNFS"); +static boolnfsrv_openaccess = true; +SYSCTL_BOOL(_vfs_nfsd, OID_AUTO, v4openaccess, CTLFLAG_RW, +_openaccess, 0, +"Enable Linux style NFSv4 Open access check"); /* * This list defines the GSS mechanisms supported. @@ -2727,7 +2731,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is u_int32_t *tl; int i, retext; struct nfsstate *stp = NULL; - int error = 0, create, claim, exclusive_flag = 0; + int error = 0, create, claim, exclusive_flag = 0, override; u_int32_t rflags = NFSV4OPEN_LOCKTYPEPOSIX, acemask; int how = NFSCREATE_UNCHECKED; int32_t cverf[2], tverf[2] = { 0, 0 }; @@ -3030,15 +3034,38 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is */ nd->nd_repstat = (vp->v_type == VDIR) ? NFSERR_ISDIR : NFSERR_SYMLINK; } + + /* +* If the Open is being done for a file that already exists, apply +* normal permission checking including for the file owner, if +* vfs.nfsd.v4openaccess is set. +* Previously, the owner was always allowed to open the file to +* be consistent with the NFS tradition of always allowing the +* owner of the file to write to the file regardless of permissions. +* It now appears that the Linux client expects the owner +* permissions to be checked for opens that are not creating the +* file. I believe the correct approach is to use the Access +* operation's results to be consistent with NFSv3, but that is +* not what the current Linux client appears to be doing. +* Since both the Linux and OpenSolaris NFSv4 servers do this check, +* I have enabled it by default. +* If this semantic change causes a problem, it can be disabled by +* setting the sysctl vfs.nfsd.v4openaccess to 0 to re-enable the +* previous semantics. +*/ + if (nfsrv_openaccess && create == NFSV4OPEN_NOCREATE) + override = NFSACCCHK_NOOVERRIDE; + else + override = NFSACCCHK_ALLOWOWNER; if (!nd->nd_repstat && (stp->ls_flags & NFSLCK_WRITEACCESS)) nd->nd_repstat = nfsvno_accchk(vp, VWRITE, nd->nd_cred, - exp, p, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, NULL); + exp, p, override, NFSACCCHK_VPISLOCKED, NULL); if (!nd->nd_repstat && (stp->ls_flags & NFSLCK_READACCESS)) { nd->nd_repstat = nfsvno_accchk(vp, VREAD, nd->nd_cred, - exp, p, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, NULL); + exp, p, override, NFSACCCHK_VPISLOCKED, NULL); if (nd->nd_repstat) nd->nd_repstat = nfsvno_accchk(vp, VEXEC, - nd->nd_cred, exp, p,
svn commit: r360205 - in head/sys/fs: nfs nfsclient
Author: rmacklem Date: Wed Apr 22 21:00:14 2020 New Revision: 360205 URL: https://svnweb.freebsd.org/changeset/base/360205 Log: Make the NFSv4.n client's recovery from NFSERR_BADSESSION RFC5661 conformant. RFC5661 specifies that a client's recovery upon receipt of NFSERR_BADSESSION should first consist of a CreateSession operation using the extant ClientID. If that fails, then a full recovery beginning with the ExchangeID operation is to be done. Without this patch, the FreeBSD client did not attempt the CreateSession operation with the extant ClientID and went directly to a full recovery beginning with ExchangeID. I have had this patch several years, but since no extant NFSv4.n server required the CreateSession with extant ClientID, I have never committed it. I an committing it now, since I suspect some future NFSv4.n server will require this and it should not negatively impact recovery for extant NFSv4.n servers, since they should all return NFSERR_STATECLIENTID for this first CreateSession. The patched client has been tested for recovery against both the FreeBSD and Linux NFSv4.n servers and no problems have been observed. MFC after:1 month Modified: head/sys/fs/nfs/nfs_var.h head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsclient/nfs_clstate.c Modified: head/sys/fs/nfs/nfs_var.h == --- head/sys/fs/nfs/nfs_var.h Wed Apr 22 20:50:24 2020(r360204) +++ head/sys/fs/nfs/nfs_var.h Wed Apr 22 21:00:14 2020(r360205) @@ -454,7 +454,7 @@ int nfsrpc_closerpc(struct nfsrv_descript *, struct nf int nfsrpc_openconfirm(vnode_t, u_int8_t *, int, struct nfsclopen *, struct ucred *, NFSPROC_T *); int nfsrpc_setclient(struct nfsmount *, struct nfsclclient *, int, -struct ucred *, NFSPROC_T *); +bool *, struct ucred *, NFSPROC_T *); int nfsrpc_getattr(vnode_t, struct ucred *, NFSPROC_T *, struct nfsvattr *, void *); int nfsrpc_getattrnovp(struct nfsmount *, u_int8_t *, int, int, Modified: head/sys/fs/nfsclient/nfs_clrpcops.c == --- head/sys/fs/nfsclient/nfs_clrpcops.cWed Apr 22 20:50:24 2020 (r360204) +++ head/sys/fs/nfsclient/nfs_clrpcops.cWed Apr 22 21:00:14 2020 (r360205) @@ -932,7 +932,7 @@ nfsmout: */ APPLESTATIC int nfsrpc_setclient(struct nfsmount *nmp, struct nfsclclient *clp, int reclaim, -struct ucred *cred, NFSPROC_T *p) +bool *retokp, struct ucred *cred, NFSPROC_T *p) { u_int32_t *tl; struct nfsrv_descript nfsd; @@ -944,26 +944,81 @@ nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli nfsquad_t confirm; u_int32_t lease; static u_int32_t rev = 0; - struct nfsclds *dsp; + struct nfsclds *dsp, *odsp; struct in6_addr a6; struct nfsclsession *tsep; if (nfsboottime.tv_sec == 0) NFSSETBOOTTIME(nfsboottime); - clp->nfsc_rev = rev++; if (NFSHASNFSV4N(nmp)) { - /* -* Either there was no previous session or the -* previous session has failed, so... -* do an ExchangeID followed by the CreateSession. -*/ - error = nfsrpc_exchangeid(nmp, clp, >nm_sockreq, 0, - NFSV4EXCH_USEPNFSMDS | NFSV4EXCH_USENONPNFS, , cred, p); - NFSCL_DEBUG(1, "aft exch=%d\n", error); - if (error == 0) + error = NFSERR_BADSESSION; + odsp = dsp = NULL; + if (retokp != NULL) { + NFSLOCKMNT(nmp); + odsp = TAILQ_FIRST(>nm_sess); + NFSUNLOCKMNT(nmp); + } + if (odsp != NULL) { + /* +* When a session already exists, first try a +* CreateSession with the extant ClientID. +*/ + dsp = malloc(sizeof(struct nfsclds) + + odsp->nfsclds_servownlen + 1, M_NFSCLDS, + M_WAITOK | M_ZERO); + dsp->nfsclds_expire = NFSD_MONOSEC + clp->nfsc_renew; + dsp->nfsclds_servownlen = odsp->nfsclds_servownlen; + dsp->nfsclds_sess.nfsess_clientid = + odsp->nfsclds_sess.nfsess_clientid; + dsp->nfsclds_sess.nfsess_sequenceid = + odsp->nfsclds_sess.nfsess_sequenceid; + dsp->nfsclds_flags = odsp->nfsclds_flags; + if (dsp->nfsclds_servownlen > 0) + memcpy(dsp->nfsclds_serverown, + odsp->nfsclds_serverown, + dsp->nfsclds_servownlen + 1); +
svn commit: r360142 - in stable/11/sys/fs: nfs nfsserver
Author: rmacklem Date: Tue Apr 21 05:00:35 2020 New Revision: 360142 URL: https://svnweb.freebsd.org/changeset/base/360142 Log: MFC: r359679 Fix noisy NFSv4 server printf. Peter reported that his dmesg was getting cluttered with nfsrv_cache_session: no session messages when he rebooted his NFS server and they did not seem useful. He was correct, in that these messages are "normal" and expected when NFSv4.1 or NFSv4.2 are mounted and the server is rebooted. This patch silences the printf() during the grace period after a reboot. It also adds the client IP address to the printf(), so that the message is more useful if/when it occurs. If this happens outside of the server's grace period, it does indicate something is not working correctly. Instead of adding yet another nd_XXX argument, the arguments for nfsrv_cache_session() were simplified to take a "struct nfsrv_descript *". Modified: stable/11/sys/fs/nfs/nfs_var.h stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfs_var.h == --- stable/11/sys/fs/nfs/nfs_var.h Tue Apr 21 04:47:42 2020 (r360141) +++ stable/11/sys/fs/nfs/nfs_var.h Tue Apr 21 05:00:35 2020 (r360142) @@ -136,7 +136,7 @@ void nfsrv_throwawayallstate(NFSPROC_T *); int nfsrv_checksequence(struct nfsrv_descript *, uint32_t, uint32_t *, uint32_t *, int, uint32_t *, NFSPROC_T *); int nfsrv_checkreclaimcomplete(struct nfsrv_descript *, int); -void nfsrv_cache_session(uint8_t *, uint32_t, int, struct mbuf **); +void nfsrv_cache_session(struct nfsrv_descript *, struct mbuf **); void nfsrv_freeallbackchannel_xprts(void); /* nfs_nfsdserv.c */ Modified: stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c == --- stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c Tue Apr 21 04:47:42 2020 (r360141) +++ stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c Tue Apr 21 05:00:35 2020 (r360142) @@ -387,8 +387,7 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, SVC } else m = NULL; if ((nd->nd_flag & ND_HASSEQUENCE) != 0) - nfsrv_cache_session(nd->nd_sessionid, - nd->nd_slotid, nd->nd_repstat, ); + nfsrv_cache_session(nd, ); if (nd->nd_repstat == NFSERR_REPLYFROMCACHE) nd->nd_repstat = 0; cacherep = RC_REPLY; Modified: stable/11/sys/fs/nfsserver/nfs_nfsdstate.c == --- stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Tue Apr 21 04:47:42 2020 (r360141) +++ stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Tue Apr 21 05:00:35 2020 (r360142) @@ -6156,22 +6156,56 @@ nfsrv_checkreclaimcomplete(struct nfsrv_descript *nd, * Cache the reply in a session slot. */ void -nfsrv_cache_session(uint8_t *sessionid, uint32_t slotid, int repstat, - struct mbuf **m) +nfsrv_cache_session(struct nfsrv_descript *nd, struct mbuf **m) { struct nfsdsession *sep; struct nfssessionhash *shp; + char *buf, *cp; +#ifdef INET + struct sockaddr_in *sin; +#endif +#ifdef INET6 + struct sockaddr_in6 *sin6; +#endif - shp = NFSSESSIONHASH(sessionid); + shp = NFSSESSIONHASH(nd->nd_sessionid); NFSLOCKSESSION(shp); - sep = nfsrv_findsession(sessionid); + sep = nfsrv_findsession(nd->nd_sessionid); if (sep == NULL) { NFSUNLOCKSESSION(shp); - printf("nfsrv_cache_session: no session\n"); + if ((nfsrv_stablefirst.nsf_flags & NFSNSF_GRACEOVER) != 0) { + buf = malloc(INET6_ADDRSTRLEN, M_TEMP, M_WAITOK); + switch (nd->nd_nam->sa_family) { +#ifdef INET + case AF_INET: + sin = (struct sockaddr_in *)nd->nd_nam; + cp = inet_ntop(sin->sin_family, + >sin_addr.s_addr, buf, + INET6_ADDRSTRLEN); + break; +#endif +#ifdef INET6 + case AF_INET6: + sin6 = (struct sockaddr_in6 *)nd->nd_nam; + cp = inet_ntop(sin6->sin6_family, + >sin6_addr, buf, INET6_ADDRSTRLEN); + break; +#endif + default: + cp = NULL; + } + if (cp != NULL) + printf("nfsrv_cache_session: no session " +
svn commit: r360141 - in stable/12/sys/fs: nfs nfsserver
Author: rmacklem Date: Tue Apr 21 04:47:42 2020 New Revision: 360141 URL: https://svnweb.freebsd.org/changeset/base/360141 Log: MFC: r359679 Fix noisy NFSv4 server printf. Peter reported that his dmesg was getting cluttered with nfsrv_cache_session: no session messages when he rebooted his NFS server and they did not seem useful. He was correct, in that these messages are "normal" and expected when NFSv4.1 or NFSv4.2 are mounted and the server is rebooted. This patch silences the printf() during the grace period after a reboot. It also adds the client IP address to the printf(), so that the message is more useful if/when it occurs. If this happens outside of the server's grace period, it does indicate something is not working correctly. Instead of adding yet another nd_XXX argument, the arguments for nfsrv_cache_session() were simplified to take a "struct nfsrv_descript *". Modified: stable/12/sys/fs/nfs/nfs_var.h stable/12/sys/fs/nfsserver/nfs_nfsdkrpc.c stable/12/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfs/nfs_var.h == --- stable/12/sys/fs/nfs/nfs_var.h Tue Apr 21 03:57:30 2020 (r360140) +++ stable/12/sys/fs/nfs/nfs_var.h Tue Apr 21 04:47:42 2020 (r360141) @@ -142,7 +142,7 @@ void nfsrv_throwawayallstate(NFSPROC_T *); int nfsrv_checksequence(struct nfsrv_descript *, uint32_t, uint32_t *, uint32_t *, int, uint32_t *, NFSPROC_T *); int nfsrv_checkreclaimcomplete(struct nfsrv_descript *, int); -void nfsrv_cache_session(uint8_t *, uint32_t, int, struct mbuf **); +void nfsrv_cache_session(struct nfsrv_descript *, struct mbuf **); void nfsrv_freeallbackchannel_xprts(void); int nfsrv_layoutcommit(struct nfsrv_descript *, vnode_t, int, int, uint64_t, uint64_t, uint64_t, int, struct timespec *, int, nfsv4stateid_t *, Modified: stable/12/sys/fs/nfsserver/nfs_nfsdkrpc.c == --- stable/12/sys/fs/nfsserver/nfs_nfsdkrpc.c Tue Apr 21 03:57:30 2020 (r360140) +++ stable/12/sys/fs/nfsserver/nfs_nfsdkrpc.c Tue Apr 21 04:47:42 2020 (r360141) @@ -394,8 +394,7 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, SVC } else m = NULL; if ((nd->nd_flag & ND_HASSEQUENCE) != 0) - nfsrv_cache_session(nd->nd_sessionid, - nd->nd_slotid, nd->nd_repstat, ); + nfsrv_cache_session(nd, ); if (nd->nd_repstat == NFSERR_REPLYFROMCACHE) nd->nd_repstat = 0; cacherep = RC_REPLY; Modified: stable/12/sys/fs/nfsserver/nfs_nfsdstate.c == --- stable/12/sys/fs/nfsserver/nfs_nfsdstate.c Tue Apr 21 03:57:30 2020 (r360140) +++ stable/12/sys/fs/nfsserver/nfs_nfsdstate.c Tue Apr 21 04:47:42 2020 (r360141) @@ -6279,22 +6279,56 @@ nfsrv_checkreclaimcomplete(struct nfsrv_descript *nd, * Cache the reply in a session slot. */ void -nfsrv_cache_session(uint8_t *sessionid, uint32_t slotid, int repstat, - struct mbuf **m) +nfsrv_cache_session(struct nfsrv_descript *nd, struct mbuf **m) { struct nfsdsession *sep; struct nfssessionhash *shp; + char *buf, *cp; +#ifdef INET + struct sockaddr_in *sin; +#endif +#ifdef INET6 + struct sockaddr_in6 *sin6; +#endif - shp = NFSSESSIONHASH(sessionid); + shp = NFSSESSIONHASH(nd->nd_sessionid); NFSLOCKSESSION(shp); - sep = nfsrv_findsession(sessionid); + sep = nfsrv_findsession(nd->nd_sessionid); if (sep == NULL) { NFSUNLOCKSESSION(shp); - printf("nfsrv_cache_session: no session\n"); + if ((nfsrv_stablefirst.nsf_flags & NFSNSF_GRACEOVER) != 0) { + buf = malloc(INET6_ADDRSTRLEN, M_TEMP, M_WAITOK); + switch (nd->nd_nam->sa_family) { +#ifdef INET + case AF_INET: + sin = (struct sockaddr_in *)nd->nd_nam; + cp = inet_ntop(sin->sin_family, + >sin_addr.s_addr, buf, + INET6_ADDRSTRLEN); + break; +#endif +#ifdef INET6 + case AF_INET6: + sin6 = (struct sockaddr_in6 *)nd->nd_nam; + cp = inet_ntop(sin6->sin6_family, + >sin6_addr, buf, INET6_ADDRSTRLEN); + break; +#endif + default: + cp = NULL; + } +
svn commit: r360110 - stable/11/sys/rpc
Author: rmacklem Date: Mon Apr 20 01:26:18 2020 New Revision: 360110 URL: https://svnweb.freebsd.org/changeset/base/360110 Log: MFC: r359643 Change the xid for client side krpc over UDP to a global value. Without this patch, the xid used for the client side krpc requests over UDP was initialized for each "connection". A "connection" for UDP is rather sketchy and for the kernel NLM a new one is created every 2minutes. A problem with client side interoperability with a Netapp server for the NLM was reported and it is believed to be caused by reuse of the same xid. Although this was never completely diagnosed by the reporter, I could see how the same xid might get reused, since it is initialized to a value based on the TOD clock every two minutes. I suspect initializing the value for every "connection" was inherited from userland library code, where having a global xid was not practical. However, implementing a global "xid" for the kernel rpc is straightforward and will ensure that an xid value is not reused for a long time. This patch does that and is hoped it will fix the Netapp interoperability problem. PR: 245022 Modified: stable/11/sys/rpc/clnt_dg.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/rpc/clnt_dg.c == --- stable/11/sys/rpc/clnt_dg.c Mon Apr 20 01:17:00 2020(r360109) +++ stable/11/sys/rpc/clnt_dg.c Mon Apr 20 01:26:18 2020(r360110) @@ -92,6 +92,8 @@ static struct clnt_ops clnt_dg_ops = { .cl_control = clnt_dg_control }; +static volatile uint32_t rpc_xid = 0; + /* * A pending RPC request which awaits a reply. Requests which have * received their reply will have cr_xid set to zero and cr_mrep to @@ -191,6 +193,7 @@ clnt_dg_create( struct __rpc_sockinfo si; XDR xdrs; int error; + uint32_t newxid; if (svcaddr == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNADDR; @@ -243,8 +246,10 @@ clnt_dg_create( cu->cu_sent = 0; cu->cu_cwnd_wait = FALSE; (void) getmicrotime(); - cu->cu_xid = __RPC_GETXID(); - call_msg.rm_xid = cu->cu_xid; + /* Clip at 28bits so that it will not wrap around. */ + newxid = __RPC_GETXID() & 0xfff; + atomic_cmpset_32(_xid, 0, newxid); + call_msg.rm_xid = atomic_fetchadd_32(_xid, 1); call_msg.rm_call.cb_prog = program; call_msg.rm_call.cb_vers = version; xdrmem_create(, cu->cu_mcallc, MCALL_MSG_SIZE, XDR_ENCODE); @@ -420,8 +425,7 @@ clnt_dg_call( call_again: mtx_assert(>cs_lock, MA_OWNED); - cu->cu_xid++; - xid = cu->cu_xid; + xid = atomic_fetchadd_32(_xid, 1); send_again: mtx_unlock(>cs_lock); @@ -867,13 +871,13 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info) (void) memcpy(>cu_raddr, addr, addr->sa_len); break; case CLGET_XID: - *(uint32_t *)info = cu->cu_xid; + *(uint32_t *)info = atomic_load_32(_xid); break; case CLSET_XID: /* This will set the xid of the NEXT call */ /* decrement by 1 as clnt_dg_call() increments once */ - cu->cu_xid = *(uint32_t *)info - 1; + atomic_store_32(_xid, *(uint32_t *)info - 1); break; case CLGET_VERS: ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360109 - stable/12/sys/rpc
Author: rmacklem Date: Mon Apr 20 01:17:00 2020 New Revision: 360109 URL: https://svnweb.freebsd.org/changeset/base/360109 Log: MFC: r359643 Change the xid for client side krpc over UDP to a global value. Without this patch, the xid used for the client side krpc requests over UDP was initialized for each "connection". A "connection" for UDP is rather sketchy and for the kernel NLM a new one is created every 2minutes. A problem with client side interoperability with a Netapp server for the NLM was reported and it is believed to be caused by reuse of the same xid. Although this was never completely diagnosed by the reporter, I could see how the same xid might get reused, since it is initialized to a value based on the TOD clock every two minutes. I suspect initializing the value for every "connection" was inherited from userland library code, where having a global xid was not practical. However, implementing a global "xid" for the kernel rpc is straightforward and will ensure that an xid value is not reused for a long time. This patch does that and is hoped it will fix the Netapp interoperability problem. PR: 245022 Modified: stable/12/sys/rpc/clnt_dg.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/rpc/clnt_dg.c == --- stable/12/sys/rpc/clnt_dg.c Mon Apr 20 00:47:28 2020(r360108) +++ stable/12/sys/rpc/clnt_dg.c Mon Apr 20 01:17:00 2020(r360109) @@ -94,6 +94,8 @@ static struct clnt_ops clnt_dg_ops = { .cl_control = clnt_dg_control }; +static volatile uint32_t rpc_xid = 0; + /* * A pending RPC request which awaits a reply. Requests which have * received their reply will have cr_xid set to zero and cr_mrep to @@ -193,6 +195,7 @@ clnt_dg_create( struct __rpc_sockinfo si; XDR xdrs; int error; + uint32_t newxid; if (svcaddr == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNADDR; @@ -245,8 +248,10 @@ clnt_dg_create( cu->cu_sent = 0; cu->cu_cwnd_wait = FALSE; (void) getmicrotime(); - cu->cu_xid = __RPC_GETXID(); - call_msg.rm_xid = cu->cu_xid; + /* Clip at 28bits so that it will not wrap around. */ + newxid = __RPC_GETXID() & 0xfff; + atomic_cmpset_32(_xid, 0, newxid); + call_msg.rm_xid = atomic_fetchadd_32(_xid, 1); call_msg.rm_call.cb_prog = program; call_msg.rm_call.cb_vers = version; xdrmem_create(, cu->cu_mcallc, MCALL_MSG_SIZE, XDR_ENCODE); @@ -418,8 +423,7 @@ clnt_dg_call( call_again: mtx_assert(>cs_lock, MA_OWNED); - cu->cu_xid++; - xid = cu->cu_xid; + xid = atomic_fetchadd_32(_xid, 1); send_again: mtx_unlock(>cs_lock); @@ -865,13 +869,13 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info) (void) memcpy(>cu_raddr, addr, addr->sa_len); break; case CLGET_XID: - *(uint32_t *)info = cu->cu_xid; + *(uint32_t *)info = atomic_load_32(_xid); break; case CLSET_XID: /* This will set the xid of the NEXT call */ /* decrement by 1 as clnt_dg_call() increments once */ - cu->cu_xid = *(uint32_t *)info - 1; + atomic_store_32(_xid, *(uint32_t *)info - 1); break; case CLGET_VERS: ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360081 - head/usr.sbin/nfscbd
Author: rmacklem Date: Sat Apr 18 23:46:58 2020 New Revision: 360081 URL: https://svnweb.freebsd.org/changeset/base/360081 Log: Change the type of "len" to avoid warnings. The "len" variable is used as the last argument to getsockname(2) and accept(2). It was declared an "int" and this patch changes it to "socklen_t". Modified: head/usr.sbin/nfscbd/nfscbd.c Modified: head/usr.sbin/nfscbd/nfscbd.c == --- head/usr.sbin/nfscbd/nfscbd.c Sat Apr 18 20:55:43 2020 (r360080) +++ head/usr.sbin/nfscbd/nfscbd.c Sat Apr 18 23:46:58 2020 (r360081) @@ -101,13 +101,14 @@ main(int argc, char *argv[]) struct nfsd_nfscbd_args nfscbdargs2; struct sockaddr_in inetaddr, inetpeer; fd_set ready, sockbits; - int ch, connect_type_cnt, len, maxsock, msgsock, error; + int ch, connect_type_cnt, maxsock, msgsock, error; int nfssvc_flag, on, sock, tcpsock, ret, mustfreeai = 0; char *cp, princname[128]; char myname[MAXHOSTNAMELEN], *myfqdnname = NULL; struct addrinfo *aip, hints; pid_t pid; short myport = NFSV4_CBPORT; + socklen_t len; if (modfind("nfscl") < 0) { /* Not present in kernel, try loading it */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360055 - in head/sys/fs: nfs nfsserver
Author: rmacklem Date: Fri Apr 17 21:17:51 2020 New Revision: 360055 URL: https://svnweb.freebsd.org/changeset/base/360055 Log: Replace all instances of the typedef mbuf_t with "struct mbuf *". The typedef mbuf_t was used for the Mac OS/X port of the code long ago. Since this port is no longer used and the use of mbuf_t obscures what the code does (and is not consistent with style(9)), it is no longer needed. This patch replaces all instances of mbuf_t with "struct mbuf *", so that it is no longer used. This patch should not result in any semantic change. Modified: head/sys/fs/nfs/nfs.h head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfs_var.h head/sys/fs/nfs/nfsrvcache.h head/sys/fs/nfsserver/nfs_nfsdcache.c head/sys/fs/nfsserver/nfs_nfsdserv.c head/sys/fs/nfsserver/nfs_nfsdstate.c head/sys/fs/nfsserver/nfs_nfsdsubs.c Modified: head/sys/fs/nfs/nfs.h == --- head/sys/fs/nfs/nfs.h Fri Apr 17 20:20:03 2020(r360054) +++ head/sys/fs/nfs/nfs.h Fri Apr 17 21:17:51 2020(r360055) @@ -638,10 +638,10 @@ struct nfsgss_mechlist { * This structure is used by the server for describing each request. */ struct nfsrv_descript { - mbuf_t nd_mrep;/* Request mbuf list */ - mbuf_t nd_md; /* Current dissect mbuf */ - mbuf_t nd_mreq;/* Reply mbuf list */ - mbuf_t nd_mb; /* Current build mbuf */ + struct mbuf *nd_mrep; /* Request mbuf list */ + struct mbuf *nd_md; /* Current dissect mbuf */ + struct mbuf *nd_mreq; /* Reply mbuf list */ + struct mbuf *nd_mb; /* Current build mbuf */ NFSSOCKADDR_T nd_nam; /* and socket addr */ NFSSOCKADDR_T nd_nam2;/* return socket addr */ caddr_t nd_dpos;/* Current dissect pos */ Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cFri Apr 17 20:20:03 2020 (r360054) +++ head/sys/fs/nfs/nfs_commonsubs.cFri Apr 17 21:17:51 2020 (r360055) @@ -611,7 +611,7 @@ nfsm_mbufuio(struct nfsrv_descript *nd, struct uio *ui { char *mbufcp, *uiocp; int xfer, left, len; - mbuf_t mp; + struct mbuf *mp; long uiosiz, rem; int error = 0; @@ -694,7 +694,7 @@ out: APPLESTATIC void * nfsm_dissct(struct nfsrv_descript *nd, int siz, int how) { - mbuf_t mp2; + struct mbuf *mp2; int siz2, xfer; caddr_t p; int left; @@ -808,9 +808,9 @@ out: APPLESTATIC int nfsm_strtom(struct nfsrv_descript *nd, const char *cp, int siz) { - mbuf_t m2; + struct mbuf *m2; int xfer, left; - mbuf_t m1; + struct mbuf *m1; int rem, bytesize; u_int32_t *tl; char *cp2; @@ -1014,7 +1014,7 @@ APPLESTATIC void newnfs_trimleading(nd) struct nfsrv_descript *nd; { - mbuf_t m, n; + struct mbuf *m, *n; int offs; /* @@ -1059,7 +1059,7 @@ newnfs_trimleading(nd) APPLESTATIC void newnfs_trimtrailing(nd, mb, bpos) struct nfsrv_descript *nd; - mbuf_t mb; + struct mbuf *mb; caddr_t bpos; { @@ -2423,7 +2423,7 @@ nfsrv_mtostr(struct nfsrv_descript *nd, char *str, int { char *cp; int xfer, len; - mbuf_t mp; + struct mbuf *mp; int rem, error = 0; mp = nd->nd_md; @@ -4437,7 +4437,7 @@ nfsrv_refstrbigenough(int siz, u_char **cpp, u_char ** APPLESTATIC void nfsrvd_rephead(struct nfsrv_descript *nd) { - mbuf_t mreq; + struct mbuf *mreq; /* * If this is a big reply, use a cluster. Modified: head/sys/fs/nfs/nfs_var.h == --- head/sys/fs/nfs/nfs_var.h Fri Apr 17 20:20:03 2020(r360054) +++ head/sys/fs/nfs/nfs_var.h Fri Apr 17 21:17:51 2020(r360055) @@ -325,7 +325,7 @@ int nfsm_fhtom(struct nfsrv_descript *, u_int8_t *, in int nfsm_advance(struct nfsrv_descript *, int, int); void *nfsm_dissct(struct nfsrv_descript *, int, int); void newnfs_trimleading(struct nfsrv_descript *); -void newnfs_trimtrailing(struct nfsrv_descript *, mbuf_t, +void newnfs_trimtrailing(struct nfsrv_descript *, struct mbuf *, caddr_t); void newnfs_copycred(struct nfscred *, struct ucred *); void newnfs_copyincred(struct ucred *, struct nfscred *); @@ -390,7 +390,7 @@ int nfsv4_fillattr(struct nfsrv_descript *, struct mou struct vattr *, fhandle_t *, int, nfsattrbit_t *, struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *); void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *); -void
svn commit: r360032 - head/sys/fs/nfsserver
Author: rmacklem Date: Fri Apr 17 02:21:46 2020 New Revision: 360032 URL: https://svnweb.freebsd.org/changeset/base/360032 Log: Add a sanity check for nes_numsecflavor to the NFS server. Ryan Moeller reported crashes in the NFS server that appear to be caused by stack corruption in nfsrv_compound(). It appears that the stack got corrupted just after a NFSv4.1 Lookup that crosses a server mount point. Although it is just a "theory" at this point, the most obvious way the stack could get corrupted would be if nfsvno_checkexp() somehow acquires an export with a bogus nes_numsecflavor value. This would cause the copying of the secflavors to run off the end of the array, which is allocated on the stack below where the corruption occurs. This sanity check is simple to do and would stop the stack corruption if the theory is correct. Otherwise, doing the sanity check seems to be a reasonable safety belt to add to the code. Reported by: freqlabs MFC after:2 weeks Modified: head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cFri Apr 17 02:09:31 2020 (r360031) +++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Apr 17 02:21:46 2020 (r360032) @@ -3066,6 +3066,11 @@ nfsvno_checkexp(struct mount *mp, struct sockaddr *nam exp->nes_numsecflavor = 0; error = 0; } + } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > + MAXSECFLAVORS) { + printf("nfsvno_checkexp: numsecflavors out of range\n"); + exp->nes_numsecflavor = 0; + error = EACCES; } else { /* Copy the security flavors. */ for (i = 0; i < exp->nes_numsecflavor; i++) @@ -3102,6 +3107,12 @@ nfsvno_fhtovp(struct mount *mp, fhandle_t *fhp, struct } else { vput(*vpp); } + } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > + MAXSECFLAVORS) { + printf("nfsvno_fhtovp: numsecflavors out of range\n"); + exp->nes_numsecflavor = 0; + error = EACCES; + vput(*vpp); } else { /* Copy the security flavors. */ for (i = 0; i < exp->nes_numsecflavor; i++) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359995 - in head/sys/fs: nfsclient nfsserver
Author: rmacklem Date: Wed Apr 15 21:27:52 2020 New Revision: 359995 URL: https://svnweb.freebsd.org/changeset/base/359995 Log: Fix the NFSv4.2 extended attribute support for remove extended attrbute. I missed the "atomic" field of the RemoveExtendedAttribute operation's reply when I implemented it. It worked between FreeBSD client and server, since it was missed for both, but it did not conform to RFC 8276. This patch adds the field for both client and server. Thanks go to Frank for doing interoperability testing of the extended attribute support against patches for Linux. Submitted by: Frank van der Linden Reported by: Frank van der Linden Modified: head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsserver/nfs_nfsdserv.c Modified: head/sys/fs/nfsclient/nfs_clrpcops.c == --- head/sys/fs/nfsclient/nfs_clrpcops.cWed Apr 15 21:06:38 2020 (r359994) +++ head/sys/fs/nfsclient/nfs_clrpcops.cWed Apr 15 21:27:52 2020 (r359995) @@ -8432,7 +8432,7 @@ nfsrpc_rmextattr(vnode_t vp, const char *name, struct return (error); if (nd->nd_repstat == 0) { /* Just skip over the reply and Getattr op status. */ - NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_HYPER + 2 * + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_HYPER + 3 * NFSX_UNSIGNED); error = nfsm_loadattr(nd, nap); if (error == 0) Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c == --- head/sys/fs/nfsserver/nfs_nfsdserv.cWed Apr 15 21:06:38 2020 (r359994) +++ head/sys/fs/nfsserver/nfs_nfsdserv.cWed Apr 15 21:27:52 2020 (r359995) @@ -5729,7 +5729,8 @@ nfsrvd_rmxattr(struct nfsrv_descript *nd, __unused int if (nd->nd_repstat == 0) nd->nd_repstat = nfsvno_getattr(vp, , nd, p, 1, ); if (nd->nd_repstat == 0) { - NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + NFSX_UNSIGNED); + *tl++ = newnfs_true; txdr_hyper(ova.na_filerev, tl); tl += 2; txdr_hyper(nva.na_filerev, tl); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359941 - in head/sys/fs: nfsclient nfsserver
Author: rmacklem Date: Tue Apr 14 22:57:21 2020 New Revision: 359941 URL: https://svnweb.freebsd.org/changeset/base/359941 Log: Fix the NFSv2 extended attribute support to handle 0 length attributes. I did not realize that zero length attributes are allowed, but they are. This patch fixes the NFSv4.2 client and server to handle zero length extended attributes correctly. Submitted by: Frank van der Linden (earlier version) Reported by: Frank van der Linden Modified: head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsclient/nfs_clvnops.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdserv.c Modified: head/sys/fs/nfsclient/nfs_clrpcops.c == --- head/sys/fs/nfsclient/nfs_clrpcops.cTue Apr 14 22:48:33 2020 (r359940) +++ head/sys/fs/nfsclient/nfs_clrpcops.cTue Apr 14 22:57:21 2020 (r359941) @@ -8341,7 +8341,7 @@ nfsrpc_getextattr(vnode_t vp, const char *name, struct } else if (uiop == NULL && len > 0) { /* Just wants the length and not the data. */ error = nfsm_advance(nd, NFSM_RNDUP(len), -1); - } else + } else if (len > 0) error = ENOATTR; if (error != 0) goto nfsmout; Modified: head/sys/fs/nfsclient/nfs_clvnops.c == --- head/sys/fs/nfsclient/nfs_clvnops.c Tue Apr 14 22:48:33 2020 (r359940) +++ head/sys/fs/nfsclient/nfs_clvnops.c Tue Apr 14 22:57:21 2020 (r359941) @@ -3982,7 +3982,7 @@ nfs_setextattr(struct vop_setextattr_args *ap) } mtx_unlock(>nm_mtx); - if (ap->a_uio->uio_resid <= 0) + if (ap->a_uio->uio_resid < 0) return (EINVAL); cred = ap->a_cred; if (cred == NULL) Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cTue Apr 14 22:48:33 2020 (r359940) +++ head/sys/fs/nfsserver/nfs_nfsdport.cTue Apr 14 22:57:21 2020 (r359941) @@ -6159,8 +6159,14 @@ nfsvno_getxattr(struct vnode *vp, char *name, uint32_t return (NFSERR_XATTR2BIG); len = siz; tlen = NFSM_RNDUP(len); - uiop->uio_iovcnt = nfsrv_createiovec(tlen, , , ); - uiop->uio_iov = iv; + if (tlen > 0) { + uiop->uio_iovcnt = nfsrv_createiovec(tlen, , , ); + uiop->uio_iov = iv; + } else { + uiop->uio_iovcnt = 0; + uiop->uio_iov = iv = NULL; + m = m2 = NULL; + } uiop->uio_offset = 0; uiop->uio_resid = tlen; uiop->uio_rw = UIO_READ; @@ -6173,8 +6179,9 @@ nfsvno_getxattr(struct vnode *vp, char *name, uint32_t goto out; #endif - error = VOP_GETEXTATTR(vp, EXTATTR_NAMESPACE_USER, name, uiop, NULL, - cred, p); + if (tlen > 0) + error = VOP_GETEXTATTR(vp, EXTATTR_NAMESPACE_USER, name, uiop, + NULL, cred, p); if (error != 0) goto out; if (uiop->uio_resid > 0) { @@ -6191,7 +6198,8 @@ nfsvno_getxattr(struct vnode *vp, char *name, uint32_t out: if (error != 0) { - m_freem(m); + if (m != NULL) + m_freem(m); *lenp = 0; } free(iv, M_TEMP); @@ -6223,9 +6231,14 @@ nfsvno_setxattr(struct vnode *vp, char *name, int len, uiop->uio_td = p; uiop->uio_offset = 0; uiop->uio_resid = len; - error = nfsrv_createiovecw(len, m, cp, , ); - uiop->uio_iov = iv; - uiop->uio_iovcnt = cnt; + if (len > 0) { + error = nfsrv_createiovecw(len, m, cp, , ); + uiop->uio_iov = iv; + uiop->uio_iovcnt = cnt; + } else { + uiop->uio_iov = iv = NULL; + uiop->uio_iovcnt = 0; + } if (error == 0) { error = VOP_SETEXTATTR(vp, EXTATTR_NAMESPACE_USER, name, uiop, cred, p); Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c == --- head/sys/fs/nfsserver/nfs_nfsdserv.cTue Apr 14 22:48:33 2020 (r359940) +++ head/sys/fs/nfsserver/nfs_nfsdserv.cTue Apr 14 22:57:21 2020 (r359941) @@ -5564,9 +5564,11 @@ nfsrvd_getxattr(struct nfsrv_descript *nd, __unused in if (nd->nd_repstat == 0) { NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(len); - nd->nd_mb->m_next = mp; - nd->nd_mb = mpend; - nd->nd_bpos = mtod(mpend, caddr_t) + mpend->m_len; + if (len > 0) { +
svn commit: r359910 - in head/sys: conf fs/nfsserver modules/nfsd nfs
Author: rmacklem Date: Tue Apr 14 00:01:26 2020 New Revision: 359910 URL: https://svnweb.freebsd.org/changeset/base/359910 Log: Re-organize the NFS file handle affinity code for the NFS server. The file handle affinity code was configured to be used by both the old and new NFS servers. This no longer makes sense, since there is only one NFS server. This patch copies a majority of the code in sys/nfs/nfs_fha.c and sys/nfs/nfs_fha.h into sys/fs/nfsserver/nfs_fha_new.c and sys/fs/nfsserver/nfs_fha_new.h, so that the files in sys/nfs can be deleted. The code is simplified by deleting the function callback pointers used to call functions in either the old or new NFS server and they were replaced by calls to the functions. As well as a cleanup, this re-organization simplifies the changes required for handling of external page mbufs, which is required for KERN_TLS. This patch should not result in a semantic change to file handle affinity. Deleted: head/sys/nfs/nfs_fha.c head/sys/nfs/nfs_fha.h Modified: head/sys/conf/files head/sys/fs/nfsserver/nfs_fha_new.c head/sys/fs/nfsserver/nfs_fha_new.h head/sys/fs/nfsserver/nfs_nfsdkrpc.c head/sys/modules/nfsd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Apr 13 23:16:32 2020(r359909) +++ head/sys/conf/files Tue Apr 14 00:01:26 2020(r359910) @@ -4435,7 +4435,6 @@ netsmb/smb_usr.c optional netsmb nfs/bootp_subr.c optional bootp nfscl nfs/krpc_subr.coptional bootp nfscl nfs/nfs_diskless.c optional nfscl nfs_root -nfs/nfs_fha.c optional nfsd nfs/nfs_nfssvc.c optional nfscl | nfslockd | nfsd nlm/nlm_advlock.c optional nfslockd | nfsd nlm/nlm_prot_clnt.coptional nfslockd | nfsd Modified: head/sys/fs/nfsserver/nfs_fha_new.c == --- head/sys/fs/nfsserver/nfs_fha_new.c Mon Apr 13 23:16:32 2020 (r359909) +++ head/sys/fs/nfsserver/nfs_fha_new.c Tue Apr 14 00:01:26 2020 (r359910) @@ -29,29 +29,33 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include + #include +#include #include -#include -#include -#include -#include -#include -#include -static void fhanew_init(void *foo); -static void fhanew_uninit(void *foo); -rpcproc_t fhanew_get_procnum(rpcproc_t procnum); -int fhanew_realign(struct mbuf **mb, int malloc_flags); -int fhanew_get_fh(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos); -int fhanew_is_read(rpcproc_t procnum); -int fhanew_is_write(rpcproc_t procnum); -int fhanew_get_offset(struct mbuf **md, caddr_t *dpos, int v3, - struct fha_info *info); -int fhanew_no_offset(rpcproc_t procnum); -void fhanew_set_locktype(rpcproc_t procnum, struct fha_info *info); -static int fhenew_stats_sysctl(SYSCTL_HANDLER_ARGS); +static MALLOC_DEFINE(M_NFS_FHA, "NFS FHA", "NFS FHA"); +static voidfhanew_init(void *foo); +static voidfhanew_uninit(void *foo); +static rpcproc_t fhanew_get_procnum(rpcproc_t procnum); +static int fhanew_get_fh(uint64_t *fh, int v3, struct mbuf **md, + caddr_t *dpos); +static int fhanew_is_read(rpcproc_t procnum); +static int fhanew_is_write(rpcproc_t procnum); +static int fhanew_get_offset(struct mbuf **md, caddr_t *dpos, + int v3, struct fha_info *info); +static int fhanew_no_offset(rpcproc_t procnum); +static voidfhanew_set_locktype(rpcproc_t procnum, + struct fha_info *info); +static int fhenew_stats_sysctl(SYSCTL_HANDLER_ARGS); +static voidfha_extract_info(struct svc_req *req, + struct fha_info *i); + static struct fha_params fhanew_softc; SYSCTL_DECL(_vfs_nfsd); @@ -66,24 +70,12 @@ static void fhanew_init(void *foo) { struct fha_params *softc; + int i; softc = _softc; bzero(softc, sizeof(*softc)); - /* -* Setup the callbacks for this FHA personality. -*/ - softc->callbacks.get_procnum = fhanew_get_procnum; - softc->callbacks.realign = fhanew_realign; - softc->callbacks.get_fh = fhanew_get_fh; - softc->callbacks.is_read = fhanew_is_read; - softc->callbacks.is_write = fhanew_is_write; - softc->callbacks.get_offset = fhanew_get_offset; - softc->callbacks.no_offset = fhanew_no_offset; - softc->callbacks.set_locktype = fhanew_set_locktype; - softc->callbacks.fhe_stats_sysctl = fhenew_stats_sysctl; - snprintf(softc->server_name, sizeof(softc->server_name), FHANEW_SERVER_NAME); @@ -101,20 +93,68 @@ fhanew_init(void *foo) return; } -
svn commit: r359840 - head/sys/fs/nfs
Author: rmacklem Date: Mon Apr 13 00:07:37 2020 New Revision: 359840 URL: https://svnweb.freebsd.org/changeset/base/359840 Log: Delete the mbuf macros that were used for the Mac OS/X port. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since r359757, r359780, r359785, r359810, r359811 have removed all uses of these macros, this patch deleted the macros from the .h files. My eventual goal is deleting nfskpiport.h, but that will take some more editting to replace uses of the remaining macros. Modified: head/sys/fs/nfs/nfskpiport.h head/sys/fs/nfs/nfsport.h Modified: head/sys/fs/nfs/nfskpiport.h == --- head/sys/fs/nfs/nfskpiport.hSun Apr 12 22:22:53 2020 (r359839) +++ head/sys/fs/nfs/nfskpiport.hMon Apr 13 00:07:37 2020 (r359840) @@ -44,15 +44,6 @@ typedef struct vnode * vnode_t; #definevnode_vtype(v) ((v)->v_type) typedef struct mbuf * mbuf_t; -#definembuf_freem(m) m_freem(m) -#definembuf_data(m)mtod((m), void *) -#definembuf_len(m) ((m)->m_len) -#definembuf_next(m)((m)->m_next) -#definembuf_setlen(m, l) ((m)->m_len = (l)) -#definembuf_setnext(m, p) ((m)->m_next = (p)) -#definembuf_pkthdr_len(m) ((m)->m_pkthdr.len) -#definembuf_pkthdr_setlen(m, l) ((m)->m_pkthdr.len = (l)) -#definembuf_pkthdr_setrcvif(m, p) ((m)->m_pkthdr.rcvif = (p)) /* * This stuff is needed by Darwin for handling the uio structure. Modified: head/sys/fs/nfs/nfsport.h == --- head/sys/fs/nfs/nfsport.h Sun Apr 12 22:22:53 2020(r359839) +++ head/sys/fs/nfs/nfsport.h Mon Apr 13 00:07:37 2020(r359840) @@ -172,7 +172,6 @@ MGETHDR((m), M_WAITOK, MT_DATA);\ } \ } while (0) -#defineNFSMTOD mtod /* * Client side constant for size of a lockowner name. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359811 - in head/sys/fs: nfs nfsclient
Author: rmacklem Date: Sat Apr 11 23:37:58 2020 New Revision: 359811 URL: https://svnweb.freebsd.org/changeset/base/359811 Log: Replace mbuf macros with the code they would generate in the NFS code. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since porting to Mac OS/X is no longer a consideration, replacement of these macros with the code generated by them makes the code more readable. When support for external page mbufs is added as needed by the KERN_TLS, the patch becomes simpler if done without the macros. This patch should not result in any semantic change. This is the final patch of this series and the macros should now be able to be deleted from the .h files in a future commit. Modified: head/sys/fs/nfs/nfs_commonkrpc.c head/sys/fs/nfsclient/nfs_clrpcops.c Modified: head/sys/fs/nfs/nfs_commonkrpc.c == --- head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 20:57:15 2020 (r359810) +++ head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 23:37:58 2020 (r359811) @@ -893,7 +893,7 @@ tryagain: */ newnfs_realign(>nd_mrep, M_WAITOK); nd->nd_md = nd->nd_mrep; - nd->nd_dpos = NFSMTOD(nd->nd_md, caddr_t); + nd->nd_dpos = mtod(nd->nd_md, caddr_t); nd->nd_repstat = 0; if (nd->nd_procnum != NFSPROC_NULL && nd->nd_procnum != NFSV4PROC_CBNULL) { Modified: head/sys/fs/nfsclient/nfs_clrpcops.c == --- head/sys/fs/nfsclient/nfs_clrpcops.cSat Apr 11 20:57:15 2020 (r359810) +++ head/sys/fs/nfsclient/nfs_clrpcops.cSat Apr 11 23:37:58 2020 (r359811) @@ -238,7 +238,7 @@ nfsrpc_null(vnode_t vp, struct ucred *cred, NFSPROC_T error = nfscl_request(nd, vp, p, cred, NULL); if (nd->nd_repstat && !error) error = nd->nd_repstat; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -344,7 +344,7 @@ nfsrpc_accessrpc(vnode_t vp, u_int32_t mode, struct uc } else error = nd->nd_repstat; nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -679,7 +679,7 @@ nfsmout: *dpp = ndp; else if (ndp != NULL) free(ndp, M_NFSCLDELEG); - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -722,7 +722,7 @@ nfsrpc_opendowngrade(vnode_t vp, u_int32_t mode, struc if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -880,7 +880,7 @@ nfsrpc_closerpc(struct nfsrv_descript *nd, struct nfsm if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -922,7 +922,7 @@ nfsrpc_openconfirm(vnode_t vp, u_int8_t *nfhp, int fhl if (error == NFSERR_STALESTATEID) nfscl_initiate_recovery(op->nfso_own->nfsow_clp); nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -1077,7 +1077,7 @@ nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli tsep->nfsess_clientid.lval[1] = *tl++; confirm.lval[0] = *tl++; confirm.lval[1] = *tl; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); nd->nd_mrep = NULL; /* @@ -1095,7 +1095,7 @@ nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL); if (error) return (error); - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); nd->nd_mrep = NULL; if (nd->nd_repstat == 0) { nfscl_reqstart(nd, NFSPROC_GETATTR, nmp, nmp->nm_fh, @@ -1123,7 +1123,7 @@ nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli } error = nd->nd_repstat; nfsmout: - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -1150,7 +1150,7 @@ nfsrpc_getattr(vnode_t vp, struct ucred *cred, NFSPROC error = nfsm_loadattr(nd, nap); else error = nd->nd_repstat; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return (error); } @@ -1190,7 +1190,7 @@ nfsrpc_getattrnovp(struct nfsmount *nmp, u_int8_t *fhp error = nfsm_loadattr(nd, nap); } else error = nd->nd_repstat; - mbuf_freem(nd->nd_mrep); + m_freem(nd->nd_mrep); return
svn commit: r359810 - in head/sys/fs: nfs nfsserver
Author: rmacklem Date: Sat Apr 11 20:57:15 2020 New Revision: 359810 URL: https://svnweb.freebsd.org/changeset/base/359810 Log: Replace mbuf macros with the code they would generate in the NFS code. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since porting to Mac OS/X is no longer a consideration, replacement of these macros with the code generated by them makes the code more readable. When support for external page mbufs is added as needed by the KERN_TLS, the patch becomes simpler if done without the macros. This patch should not result in any semantic change. Modified: head/sys/fs/nfs/nfs_commonkrpc.c head/sys/fs/nfs/nfsm_subs.h head/sys/fs/nfsserver/nfs_nfsdcache.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdserv.c head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfs/nfs_commonkrpc.c == --- head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 20:36:54 2020 (r359809) +++ head/sys/fs/nfs/nfs_commonkrpc.cSat Apr 11 20:57:15 2020 (r359810) @@ -1188,8 +1188,8 @@ tryagain: newnfs_restore_sigmask(td, ); return (0); nfsmout: - mbuf_freem(nd->nd_mrep); - mbuf_freem(nd->nd_mreq); + m_freem(nd->nd_mrep); + m_freem(nd->nd_mreq); if (usegssname == 0) AUTH_DESTROY(auth); if (rep != NULL) Modified: head/sys/fs/nfs/nfsm_subs.h == --- head/sys/fs/nfs/nfsm_subs.h Sat Apr 11 20:36:54 2020(r359809) +++ head/sys/fs/nfs/nfsm_subs.h Sat Apr 11 20:57:15 2020(r359810) @@ -68,8 +68,8 @@ nfsm_build(struct nfsrv_descript *nd, int siz) NFSMCLGET(mb2, M_NOWAIT); if (siz > MLEN) panic("build > MLEN"); - mbuf_setlen(mb2, 0); - nd->nd_bpos = NFSMTOD(mb2, caddr_t); + mb2->m_len = 0; + nd->nd_bpos = mtod(mb2, caddr_t); nd->nd_mb->m_next = mb2; nd->nd_mb = mb2; } @@ -87,7 +87,7 @@ nfsm_dissect(struct nfsrv_descript *nd, int siz) int tt1; void *retp; - tt1 = NFSMTOD(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; + tt1 = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; if (tt1 >= siz) { retp = (void *)nd->nd_dpos; nd->nd_dpos += siz; @@ -103,7 +103,7 @@ nfsm_dissect_nonblock(struct nfsrv_descript *nd, int s int tt1; void *retp; - tt1 = NFSMTOD(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; + tt1 = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; if (tt1 >= siz) { retp = (void *)nd->nd_dpos; nd->nd_dpos += siz; Modified: head/sys/fs/nfsserver/nfs_nfsdcache.c == --- head/sys/fs/nfsserver/nfs_nfsdcache.c Sat Apr 11 20:36:54 2020 (r359809) +++ head/sys/fs/nfsserver/nfs_nfsdcache.c Sat Apr 11 20:57:15 2020 (r359810) @@ -486,7 +486,7 @@ nfsrvd_updatecache(struct nfsrv_descript *nd) mtx_unlock(mutex); nd->nd_repstat = 0; if (nd->nd_mreq) - mbuf_freem(nd->nd_mreq); + m_freem(nd->nd_mreq); if (!(rp->rc_flag & RC_REPMBUF)) panic("reply from cache"); nd->nd_mreq = m_copym(rp->rc_reply, 0, @@ -798,7 +798,7 @@ nfsrc_freecache(struct nfsrvcache *rp) } nfsrc_wanted(rp); if (rp->rc_flag & RC_REPMBUF) { - mbuf_freem(rp->rc_reply); + m_freem(rp->rc_reply); if (!(rp->rc_flag & RC_UDP)) atomic_add_int(_tcpsavedreplies, -1); } @@ -1020,8 +1020,8 @@ nfsrc_getlenandcksum(mbuf_t m1, u_int16_t *cksum) m = m1; while (m) { - len += mbuf_len(m); - m = mbuf_next(m); + len += m->m_len; + m = m->m_next; } cklen = (len > NFSRVCACHE_CHECKLEN) ? NFSRVCACHE_CHECKLEN : len; *cksum = in_cksum(m1, cklen); Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cSat Apr 11 20:36:54 2020 (r359809) +++ head/sys/fs/nfsserver/nfs_nfsdport.cSat Apr 11 20:57:15 2020 (r359810) @@ -903,18 +903,18 @@ nfsrv_createiovecw(int retlen, struct mbuf *m, char *c cnt = 0; len = retlen; mp = m; - i = mtod(mp, caddr_t) + mbuf_len(mp) - cp; + i = mtod(mp, caddr_t) +
svn commit: r359785 - head/sys/fs/nfsclient
Author: rmacklem Date: Fri Apr 10 22:42:14 2020 New Revision: 359785 URL: https://svnweb.freebsd.org/changeset/base/359785 Log: Replace mbuf macros with the code they would generate in the NFS code. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since porting to Mac OS/X is no longer a consideration, replacement of these macros with the code generated by them makes the code more readable. When support for external page mbufs is added as needed by the KERN_TLS, the patch becomes simpler if done without the macros. This patch should not result in any semantic change. This conversion will be committed one file at a time. Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c == --- head/sys/fs/nfsclient/nfs_clcomsubs.c Fri Apr 10 22:27:45 2020 (r359784) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Fri Apr 10 22:42:14 2020 (r359785) @@ -87,8 +87,8 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui NFSMCLGET(mp, M_WAITOK); else NFSMGET(mp); - mbuf_setlen(mp, 0); - mbuf_setnext(mp2, mp); + mp->m_len = 0; + mp2->m_next = mp; mp2 = mp; mlen = M_TRAILINGSPACE(mp); } @@ -97,17 +97,17 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui /* Not Yet.. */ if (uiop->uio_iov->iov_op != NULL) (*(uiop->uio_iov->iov_op)) - (uiocp, NFSMTOD(mp, caddr_t) + mbuf_len(mp), + (uiocp, mtod(mp, caddr_t) + mp->m_len, xfer); else #endif if (uiop->uio_segflg == UIO_SYSSPACE) - NFSBCOPY(uiocp, NFSMTOD(mp, caddr_t) + mbuf_len(mp), + NFSBCOPY(uiocp, mtod(mp, caddr_t) + mp->m_len, xfer); else - copyin(CAST_USER_ADDR_T(uiocp), NFSMTOD(mp, caddr_t) - + mbuf_len(mp), xfer); - mbuf_setlen(mp, mbuf_len(mp) + xfer); + copyin(CAST_USER_ADDR_T(uiocp), mtod(mp, caddr_t) + + mp->m_len, xfer); + mp->m_len += xfer; left -= xfer; uiocp += xfer; uiop->uio_offset += xfer; @@ -122,16 +122,16 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *ui if (rem > 0) { if (rem > M_TRAILINGSPACE(mp)) { NFSMGET(mp); - mbuf_setlen(mp, 0); - mbuf_setnext(mp2, mp); + mp->m_len = 0; + mp2->m_next = mp; } - cp = NFSMTOD(mp, caddr_t) + mbuf_len(mp); + cp = mtod(mp, caddr_t) + mp->m_len; for (left = 0; left < rem; left++) *cp++ = '\0'; - mbuf_setlen(mp, mbuf_len(mp) + rem); + mp->m_len += rem; nd->nd_bpos = cp; } else - nd->nd_bpos = NFSMTOD(mp, caddr_t) + mbuf_len(mp); + nd->nd_bpos = mtod(mp, caddr_t) + mp->m_len; nd->nd_mb = mp; } @@ -159,7 +159,7 @@ nfsm_uiombuflist(struct uio *uiop, int siz, struct mbu NFSMCLGET(mp, M_WAITOK); else NFSMGET(mp); - mbuf_setlen(mp, 0); + mp->m_len = 0; firstmp = mp2 = mp; while (siz > 0) { left = uiop->uio_iov->iov_len; @@ -174,19 +174,19 @@ nfsm_uiombuflist(struct uio *uiop, int siz, struct mbu NFSMCLGET(mp, M_WAITOK); else NFSMGET(mp); - mbuf_setlen(mp, 0); - mbuf_setnext(mp2, mp); + mp->m_len = 0; + mp2->m_next = mp; mp2 = mp; mlen = M_TRAILINGSPACE(mp); } xfer = (left > mlen) ? mlen : left; if (uiop->uio_segflg == UIO_SYSSPACE) - NFSBCOPY(uiocp, NFSMTOD(mp, caddr_t) + - mbuf_len(mp), xfer); +
svn commit: r359780 - head/sys/fs/nfsserver
Author: rmacklem Date: Fri Apr 10 21:25:35 2020 New Revision: 359780 URL: https://svnweb.freebsd.org/changeset/base/359780 Log: Replace mbuf macros with the code they would generate in the NFS code. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since porting to Mac OS/X is no longer a consideration, replacement of these macros with the code generated by them makes the code more readable. When support for external page mbufs is added as needed by the KERN_TLS, the patch becomes simpler if done without the macros. This patch should not result in any semantic change. This conversion will be committed one file at a time. Modified: head/sys/fs/nfsserver/nfs_nfsdsubs.c Modified: head/sys/fs/nfsserver/nfs_nfsdsubs.c == --- head/sys/fs/nfsserver/nfs_nfsdsubs.cFri Apr 10 20:42:11 2020 (r359779) +++ head/sys/fs/nfsserver/nfs_nfsdsubs.cFri Apr 10 21:25:35 2020 (r359780) @@ -1290,15 +1290,15 @@ nfsrv_adj(mbuf_t mp, int len, int nul) count = 0; m = mp; for (;;) { - count += mbuf_len(m); - if (mbuf_next(m) == NULL) + count += m->m_len; + if (m->m_next == NULL) break; - m = mbuf_next(m); + m = m->m_next; } - if (mbuf_len(m) > len) { - mbuf_setlen(m, mbuf_len(m) - len); + if (m->m_len > len) { + m->m_len -= len; if (nul > 0) { - cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul; + cp = mtod(m, caddr_t) + m->m_len - nul; for (i = 0; i < nul; i++) *cp++ = '\0'; } @@ -1312,20 +1312,20 @@ nfsrv_adj(mbuf_t mp, int len, int nul) * Find the mbuf with last data, adjust its length, * and toss data from remaining mbufs on chain. */ - for (m = mp; m; m = mbuf_next(m)) { - if (mbuf_len(m) >= count) { - mbuf_setlen(m, count); + for (m = mp; m; m = m->m_next) { + if (m->m_len >= count) { + m->m_len = count; if (nul > 0) { - cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul; + cp = mtod(m, caddr_t) + m->m_len - nul; for (i = 0; i < nul; i++) *cp++ = '\0'; } break; } - count -= mbuf_len(m); + count -= m->m_len; } - for (m = mbuf_next(m); m; m = mbuf_next(m)) - mbuf_setlen(m, 0); + for (m = m->m_next; m; m = m->m_next) + m->m_len = 0; } /* @@ -1879,16 +1879,16 @@ nfsrv_parsename(struct nfsrv_descript *nd, char *bufp, */ fromcp = nd->nd_dpos; md = nd->nd_md; - rem = NFSMTOD(md, caddr_t) + mbuf_len(md) - fromcp; + rem = mtod(md, caddr_t) + md->m_len - fromcp; for (i = 0; i < len; i++) { while (rem == 0) { - md = mbuf_next(md); + md = md->m_next; if (md == NULL) { error = EBADRPC; goto nfsmout; } - fromcp = NFSMTOD(md, caddr_t); - rem = mbuf_len(md); + fromcp = mtod(md, caddr_t); + rem = md->m_len; } if (*fromcp == '\0') { nd->nd_repstat = EACCES; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359757 - head/sys/fs/nfs
Author: rmacklem Date: Thu Apr 9 23:11:19 2020 New Revision: 359757 URL: https://svnweb.freebsd.org/changeset/base/359757 Log: Replace mbuf macros with the code they would generate in the NFS code. When the code was ported to Mac OS/X, mbuf handling functions were converted to using the Mac OS/X accessor functions. For FreeBSD, they are a simple set of macros in sys/fs/nfs/nfskpiport.h. Since porting to Mac OS/X is no longer a consideration, replacement of these macros with the code generated by them makes the code more readable. When support for external page mbufs is added as needed by the KERN_TLS, the patch becomes simpler if done without the macros. This patch should not result in any semantic change. This conversion will be committed one file at a time. Modified: head/sys/fs/nfs/nfs_commonsubs.c Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cThu Apr 9 21:24:17 2020 (r359756) +++ head/sys/fs/nfs/nfs_commonsubs.cThu Apr 9 23:11:19 2020 (r359757) @@ -360,9 +360,9 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum, NFSMCLGET(mb, M_WAITOK); else NFSMGET(mb); - mbuf_setlen(mb, 0); + mb->m_len = 0; nd->nd_mreq = nd->nd_mb = mb; - nd->nd_bpos = NFSMTOD(mb, caddr_t); + nd->nd_bpos = mtod(mb, caddr_t); /* * And fill the first file handle into the request. @@ -617,7 +617,7 @@ nfsm_mbufuio(struct nfsrv_descript *nd, struct uio *ui mp = nd->nd_md; mbufcp = nd->nd_dpos; - len = NFSMTOD(mp, caddr_t) + mbuf_len(mp) - mbufcp; + len = mtod(mp, caddr_t) + mp->m_len - mbufcp; rem = NFSM_RNDUP(siz) - siz; while (siz > 0) { if (uiop->uio_iovcnt <= 0 || uiop->uio_iov == NULL) { @@ -631,13 +631,13 @@ nfsm_mbufuio(struct nfsrv_descript *nd, struct uio *ui uiosiz = left; while (left > 0) { while (len == 0) { - mp = mbuf_next(mp); + mp = mp->m_next; if (mp == NULL) { error = EBADRPC; goto out; } - mbufcp = NFSMTOD(mp, caddr_t); - len = mbuf_len(mp); + mbufcp = mtod(mp, caddr_t); + len = mp->m_len; KASSERT(len >= 0, ("len %d, corrupted mbuf?", len)); } @@ -701,18 +701,18 @@ nfsm_dissct(struct nfsrv_descript *nd, int siz, int ho caddr_t retp; retp = NULL; - left = NFSMTOD(nd->nd_md, caddr_t) + mbuf_len(nd->nd_md) - nd->nd_dpos; + left = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos; while (left == 0) { - nd->nd_md = mbuf_next(nd->nd_md); + nd->nd_md = nd->nd_md->m_next; if (nd->nd_md == NULL) return (retp); - left = mbuf_len(nd->nd_md); - nd->nd_dpos = NFSMTOD(nd->nd_md, caddr_t); + left = nd->nd_md->m_len; + nd->nd_dpos = mtod(nd->nd_md, caddr_t); } if (left >= siz) { retp = nd->nd_dpos; nd->nd_dpos += siz; - } else if (mbuf_next(nd->nd_md) == NULL) { + } else if (nd->nd_md->m_next == NULL) { return (retp); } else if (siz > ncl_mbuf_mhlen) { panic("nfs S too big"); @@ -720,33 +720,33 @@ nfsm_dissct(struct nfsrv_descript *nd, int siz, int ho MGET(mp2, MT_DATA, how); if (mp2 == NULL) return (NULL); - mbuf_setnext(mp2, mbuf_next(nd->nd_md)); - mbuf_setnext(nd->nd_md, mp2); - mbuf_setlen(nd->nd_md, mbuf_len(nd->nd_md) - left); + mp2->m_next = nd->nd_md->m_next; + nd->nd_md->m_next = mp2; + nd->nd_md->m_len -= left; nd->nd_md = mp2; - retp = p = NFSMTOD(mp2, caddr_t); + retp = p = mtod(mp2, caddr_t); NFSBCOPY(nd->nd_dpos, p, left); /* Copy what was left */ siz2 = siz - left; p += left; - mp2 = mbuf_next(mp2); + mp2 = mp2->m_next; /* Loop around copying up the siz2 bytes */ while (siz2 > 0) { if (mp2 == NULL) return (NULL); - xfer = (siz2 > mbuf_len(mp2)) ? mbuf_len(mp2) : siz2; + xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2; if (xfer > 0) { -
svn commit: r359747 - head/sys/sys
Author: rmacklem Date: Thu Apr 9 15:33:13 2020 New Revision: 359747 URL: https://svnweb.freebsd.org/changeset/base/359747 Log: Bump version for r359745, since it removed a field from "struct proc" and that changed the offsets of fields within it. Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h == --- head/sys/sys/param.hThu Apr 9 15:30:21 2020(r359746) +++ head/sys/sys/param.hThu Apr 9 15:33:13 2020(r359747) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300089 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300090 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359745 - in head/sys: conf fs/nfs fs/nfsclient fs/nfsserver kern modules modules/nfslock nfs nlm sys
Author: rmacklem Date: Thu Apr 9 14:44:46 2020 New Revision: 359745 URL: https://svnweb.freebsd.org/changeset/base/359745 Log: Remove the old NFS lock device driver that uses Giant. This NFS lock device driver was replaced by the kernel NLM around FreeBSD7 and has not normally been used since then. To use it, the kernel had to be built without "options NFSLOCKD" and the nfslockd.ko had to be deleted as well. Since it uses Giant and is no longer used, this patch removes it. With this device driver removed, there is now a lot of unused code in the userland rpc.lockd. That will be removed on a future commit. Reviewed by: kib Differential Revision:https://reviews.freebsd.org/D22933 Deleted: head/sys/modules/nfslock/ head/sys/nfs/nfs_lock.c Modified: head/sys/conf/files head/sys/fs/nfs/nfs_commonport.c head/sys/fs/nfsclient/nfs_clport.c head/sys/fs/nfsclient/nfs_clvfsops.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/kern/kern_exit.c head/sys/kern/kern_thread.c head/sys/modules/Makefile head/sys/nlm/nlm_prot_impl.c head/sys/sys/proc.h Modified: head/sys/conf/files == --- head/sys/conf/files Thu Apr 9 08:34:27 2020(r359744) +++ head/sys/conf/files Thu Apr 9 14:44:46 2020(r359745) @@ -3489,10 +3489,10 @@ fs/msdosfs/msdosfs_iconv.c optional msdosfs_iconv fs/msdosfs/msdosfs_lookup.coptional msdosfs fs/msdosfs/msdosfs_vfsops.coptional msdosfs fs/msdosfs/msdosfs_vnops.c optional msdosfs -fs/nfs/nfs_commonkrpc.coptional nfscl | nfsd -fs/nfs/nfs_commonsubs.coptional nfscl | nfsd -fs/nfs/nfs_commonport.coptional nfscl | nfsd -fs/nfs/nfs_commonacl.c optional nfscl | nfsd +fs/nfs/nfs_commonkrpc.coptional nfscl | nfslockd | nfsd +fs/nfs/nfs_commonsubs.coptional nfscl | nfslockd | nfsd +fs/nfs/nfs_commonport.coptional nfscl | nfslockd | nfsd +fs/nfs/nfs_commonacl.c optional nfscl | nfslockd | nfsd fs/nfsclient/nfs_clcomsubs.c optional nfscl fs/nfsclient/nfs_clsubs.c optional nfscl fs/nfsclient/nfs_clstate.c optional nfscl @@ -4434,8 +4434,7 @@ nfs/bootp_subr.c optional bootp nfscl nfs/krpc_subr.coptional bootp nfscl nfs/nfs_diskless.c optional nfscl nfs_root nfs/nfs_fha.c optional nfsd -nfs/nfs_lock.c optional nfscl | nfslockd | nfsd -nfs/nfs_nfssvc.c optional nfscl | nfsd +nfs/nfs_nfssvc.c optional nfscl | nfslockd | nfsd nlm/nlm_advlock.c optional nfslockd | nfsd nlm/nlm_prot_clnt.coptional nfslockd | nfsd nlm/nlm_prot_impl.coptional nfslockd | nfsd Modified: head/sys/fs/nfs/nfs_commonport.c == --- head/sys/fs/nfs/nfs_commonport.cThu Apr 9 08:34:27 2020 (r359744) +++ head/sys/fs/nfs/nfs_commonport.cThu Apr 9 14:44:46 2020 (r359745) @@ -74,6 +74,8 @@ struct nfsdevicehead nfsrv_devidhead; volatile int nfsrv_devidcnt = 0; void (*nfsd_call_servertimer)(void) = NULL; void (*ncl_call_invalcaches)(struct vnode *) = NULL; +vop_advlock_t *nfs_advlock_p = NULL; +vop_reclaim_t *nfs_reclaim_p = NULL; int nfs_pnfsio(task_fn_t *, void *); Modified: head/sys/fs/nfsclient/nfs_clport.c == --- head/sys/fs/nfsclient/nfs_clport.c Thu Apr 9 08:34:27 2020 (r359744) +++ head/sys/fs/nfsclient/nfs_clport.c Thu Apr 9 14:44:46 2020 (r359745) @@ -1412,5 +1412,4 @@ MODULE_VERSION(nfscl, 1); MODULE_DEPEND(nfscl, nfscommon, 1, 1, 1); MODULE_DEPEND(nfscl, krpc, 1, 1, 1); MODULE_DEPEND(nfscl, nfssvc, 1, 1, 1); -MODULE_DEPEND(nfscl, nfslock, 1, 1, 1); Modified: head/sys/fs/nfsclient/nfs_clvfsops.c == --- head/sys/fs/nfsclient/nfs_clvfsops.cThu Apr 9 08:34:27 2020 (r359744) +++ head/sys/fs/nfsclient/nfs_clvfsops.cThu Apr 9 14:44:46 2020 (r359745) @@ -152,7 +152,6 @@ MODULE_VERSION(nfs, 1); MODULE_DEPEND(nfs, nfscommon, 1, 1, 1); MODULE_DEPEND(nfs, krpc, 1, 1, 1); MODULE_DEPEND(nfs, nfssvc, 1, 1, 1); -MODULE_DEPEND(nfs, nfslock, 1, 1, 1); /* * This structure is now defined in sys/nfs/nfs_diskless.c so that it Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cThu Apr 9 08:34:27 2020 (r359744) +++ head/sys/fs/nfsserver/nfs_nfsdport.cThu Apr 9 14:44:46 2020 (r359745) @@ -6443,7 +6443,6 @@ DECLARE_MODULE(nfsd, nfsd_mod, SI_SUB_VFS, SI_ORDER_AN /* So that loader and kldload(2) can find us, wherever we are.. */ MODULE_VERSION(nfsd, 1);
svn commit: r359720 - head/sys/fs/nfsserver
Author: rmacklem Date: Wed Apr 8 01:12:54 2020 New Revision: 359720 URL: https://svnweb.freebsd.org/changeset/base/359720 Log: Fix an interoperability issue w.r.t. the Linux client and the NFSv4 server. Luoqi Chen reported a problem on freebsd-fs@ where a Linux NFSv4 client was able to open and write to a file when the file's permissions were not set to allow the owner write access. Since NFS servers check file permissions on every write RPC, it is standard practice to allow the owner of the file to do writes, regardless of file permissions. This provides POSIX like behaviour, since POSIX only checks permissions upon open(2). The traditional way NFS clients handle this is to check access via the Access operation/RPC and use that to determine if an open(2) on the client is allowed. It appears that, for NFSv4, the Linux client expects the NFSv4 Open (not a POSIX open) operation to fail with NFSERR_ACCES if the file is not being created and file permissions do not allow owner access, unlike NFSv3. Since both the Linux and OpenSolaris NFSv4 servers seem to exhibit this behaviour, this patch changes the FreeBSD NFSv4 server to do the same. A sysctl called vfs.nfsd.v4openaccess can be set to 0 to return the NFSv4 server to its previous behaviour. Since both the Linux and FreeBSD NFSv4 clients seem to exhibit correct behaviour with the access check for file owner in Open enabled, it is enabled by default. Reported by: luoqi.c...@gmail.com MFC after:2 weeks Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c == --- head/sys/fs/nfsserver/nfs_nfsdserv.cTue Apr 7 23:17:44 2020 (r359719) +++ head/sys/fs/nfsserver/nfs_nfsdserv.cWed Apr 8 01:12:54 2020 (r359720) @@ -81,6 +81,10 @@ static int nfsrv_linux42server = 1; SYSCTL_INT(_vfs_nfsd, OID_AUTO, linux42server, CTLFLAG_RW, _linux42server, 0, "Enable Linux style NFSv4.2 server (non-RFC compliant)"); +static boolnfsrv_openaccess = true; +SYSCTL_BOOL(_vfs_nfsd, OID_AUTO, v4openaccess, CTLFLAG_RW, +_openaccess, 0, +"Enable Linux style NFSv4 Open access check"); /* * This list defines the GSS mechanisms supported. @@ -2742,7 +2746,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is u_int32_t *tl; int i, retext; struct nfsstate *stp = NULL; - int error = 0, create, claim, exclusive_flag = 0; + int error = 0, create, claim, exclusive_flag = 0, override; u_int32_t rflags = NFSV4OPEN_LOCKTYPEPOSIX, acemask; int how = NFSCREATE_UNCHECKED; int32_t cverf[2], tverf[2] = { 0, 0 }; @@ -3046,15 +3050,38 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is */ nd->nd_repstat = (vp->v_type == VDIR) ? NFSERR_ISDIR : NFSERR_SYMLINK; } + + /* +* If the Open is being done for a file that already exists, apply +* normal permission checking including for the file owner, if +* vfs.nfsd.v4openaccess is set. +* Previously, the owner was always allowed to open the file to +* be consistent with the NFS tradition of always allowing the +* owner of the file to write to the file regardless of permissions. +* It now appears that the Linux client expects the owner +* permissions to be checked for opens that are not creating the +* file. I believe the correct approach is to use the Access +* operation's results to be consistent with NFSv3, but that is +* not what the current Linux client appears to be doing. +* Since both the Linux and OpenSolaris NFSv4 servers do this check, +* I have enabled it by default. +* If this semantic change causes a problem, it can be disabled by +* setting the sysctl vfs.nfsd.v4openaccess to 0 to re-enable the +* previous semantics. +*/ + if (nfsrv_openaccess && create == NFSV4OPEN_NOCREATE) + override = NFSACCCHK_NOOVERRIDE; + else + override = NFSACCCHK_ALLOWOWNER; if (!nd->nd_repstat && (stp->ls_flags & NFSLCK_WRITEACCESS)) nd->nd_repstat = nfsvno_accchk(vp, VWRITE, nd->nd_cred, - exp, p, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, NULL); + exp, p, override, NFSACCCHK_VPISLOCKED, NULL); if (!nd->nd_repstat && (stp->ls_flags & NFSLCK_READACCESS)) { nd->nd_repstat = nfsvno_accchk(vp, VREAD, nd->nd_cred, - exp, p, NFSACCCHK_ALLOWOWNER, NFSACCCHK_VPISLOCKED, NULL); + exp, p, override, NFSACCCHK_VPISLOCKED, NULL); if (nd->nd_repstat) nd->nd_repstat = nfsvno_accchk(vp, VEXEC, - nd->nd_cred, exp, p, NFSACCCHK_ALLOWOWNER, + nd->nd_cred, exp, p, override,
svn commit: r359679 - in head/sys/fs: nfs nfsserver
Author: rmacklem Date: Mon Apr 6 23:21:39 2020 New Revision: 359679 URL: https://svnweb.freebsd.org/changeset/base/359679 Log: Fix noisy NFSv4 server printf. Peter reported that his dmesg was getting cluttered with nfsrv_cache_session: no session messages when he rebooted his NFS server and they did not seem useful. He was correct, in that these messages are "normal" and expected when NFSv4.1 or NFSv4.2 are mounted and the server is rebooted. This patch silences the printf() during the grace period after a reboot. It also adds the client IP address to the printf(), so that the message is more useful if/when it occurs. If this happens outside of the server's grace period, it does indicate something is not working correctly. Instead of adding yet another nd_XXX argument, the arguments for nfsrv_cache_session() were simplified to take a "struct nfsrv_descript *". Reported by: p...@lysator.liu.se MFC after:2 weeks Modified: head/sys/fs/nfs/nfs_var.h head/sys/fs/nfsserver/nfs_nfsdkrpc.c head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfs/nfs_var.h == --- head/sys/fs/nfs/nfs_var.h Mon Apr 6 23:20:20 2020(r359678) +++ head/sys/fs/nfs/nfs_var.h Mon Apr 6 23:21:39 2020(r359679) @@ -143,7 +143,7 @@ void nfsrv_throwawayallstate(NFSPROC_T *); int nfsrv_checksequence(struct nfsrv_descript *, uint32_t, uint32_t *, uint32_t *, int, uint32_t *, NFSPROC_T *); int nfsrv_checkreclaimcomplete(struct nfsrv_descript *, int); -void nfsrv_cache_session(uint8_t *, uint32_t, int, struct mbuf **); +void nfsrv_cache_session(struct nfsrv_descript *, struct mbuf **); void nfsrv_freeallbackchannel_xprts(void); int nfsrv_layoutcommit(struct nfsrv_descript *, vnode_t, int, int, uint64_t, uint64_t, uint64_t, int, struct timespec *, int, nfsv4stateid_t *, Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c == --- head/sys/fs/nfsserver/nfs_nfsdkrpc.cMon Apr 6 23:20:20 2020 (r359678) +++ head/sys/fs/nfsserver/nfs_nfsdkrpc.cMon Apr 6 23:21:39 2020 (r359679) @@ -393,8 +393,7 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, SVC } else m = NULL; if ((nd->nd_flag & ND_HASSEQUENCE) != 0) - nfsrv_cache_session(nd->nd_sessionid, - nd->nd_slotid, nd->nd_repstat, ); + nfsrv_cache_session(nd, ); if (nd->nd_repstat == NFSERR_REPLYFROMCACHE) nd->nd_repstat = 0; cacherep = RC_REPLY; Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c == --- head/sys/fs/nfsserver/nfs_nfsdstate.c Mon Apr 6 23:20:20 2020 (r359678) +++ head/sys/fs/nfsserver/nfs_nfsdstate.c Mon Apr 6 23:21:39 2020 (r359679) @@ -6294,22 +6294,56 @@ nfsrv_checkreclaimcomplete(struct nfsrv_descript *nd, * Cache the reply in a session slot. */ void -nfsrv_cache_session(uint8_t *sessionid, uint32_t slotid, int repstat, - struct mbuf **m) +nfsrv_cache_session(struct nfsrv_descript *nd, struct mbuf **m) { struct nfsdsession *sep; struct nfssessionhash *shp; + char *buf, *cp; +#ifdef INET + struct sockaddr_in *sin; +#endif +#ifdef INET6 + struct sockaddr_in6 *sin6; +#endif - shp = NFSSESSIONHASH(sessionid); + shp = NFSSESSIONHASH(nd->nd_sessionid); NFSLOCKSESSION(shp); - sep = nfsrv_findsession(sessionid); + sep = nfsrv_findsession(nd->nd_sessionid); if (sep == NULL) { NFSUNLOCKSESSION(shp); - printf("nfsrv_cache_session: no session\n"); + if ((nfsrv_stablefirst.nsf_flags & NFSNSF_GRACEOVER) != 0) { + buf = malloc(INET6_ADDRSTRLEN, M_TEMP, M_WAITOK); + switch (nd->nd_nam->sa_family) { +#ifdef INET + case AF_INET: + sin = (struct sockaddr_in *)nd->nd_nam; + cp = inet_ntop(sin->sin_family, + >sin_addr.s_addr, buf, + INET6_ADDRSTRLEN); + break; +#endif +#ifdef INET6 + case AF_INET6: + sin6 = (struct sockaddr_in6 *)nd->nd_nam; + cp = inet_ntop(sin6->sin6_family, + >sin6_addr, buf, INET6_ADDRSTRLEN); + break; +#endif + default: + cp = NULL; + } + if (cp != NULL) +
svn commit: r359643 - head/sys/rpc
Author: rmacklem Date: Sun Apr 5 21:08:17 2020 New Revision: 359643 URL: https://svnweb.freebsd.org/changeset/base/359643 Log: Change the xid for client side krpc over UDP to a global value. Without this patch, the xid used for the client side krpc requests over UDP was initialized for each "connection". A "connection" for UDP is rather sketchy and for the kernel NLM a new one is created every 2minutes. A problem with client side interoperability with a Netapp server for the NLM was reported and it is believed to be caused by reuse of the same xid. Although this was never completely diagnosed by the reporter, I could see how the same xid might get reused, since it is initialized to a value based on the TOD clock every two minutes. I suspect initializing the value for every "connection" was inherited from userland library code, where having a global xid was not practical. However, implementing a global "xid" for the kernel rpc is straightforward and will ensure that an xid value is not reused for a long time. This patch does that and is hoped it will fix the Netapp interoperability problem. PR: 245022 Reported by: da...@cs.huji.ac.il MFC after:2 weeks Modified: head/sys/rpc/clnt_dg.c Modified: head/sys/rpc/clnt_dg.c == --- head/sys/rpc/clnt_dg.c Sun Apr 5 19:25:46 2020(r359642) +++ head/sys/rpc/clnt_dg.c Sun Apr 5 21:08:17 2020(r359643) @@ -94,6 +94,8 @@ static struct clnt_ops clnt_dg_ops = { .cl_control = clnt_dg_control }; +static volatile uint32_t rpc_xid = 0; + /* * A pending RPC request which awaits a reply. Requests which have * received their reply will have cr_xid set to zero and cr_mrep to @@ -193,6 +195,7 @@ clnt_dg_create( struct __rpc_sockinfo si; XDR xdrs; int error; + uint32_t newxid; if (svcaddr == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNADDR; @@ -245,8 +248,10 @@ clnt_dg_create( cu->cu_sent = 0; cu->cu_cwnd_wait = FALSE; (void) getmicrotime(); - cu->cu_xid = __RPC_GETXID(); - call_msg.rm_xid = cu->cu_xid; + /* Clip at 28bits so that it will not wrap around. */ + newxid = __RPC_GETXID() & 0xfff; + atomic_cmpset_32(_xid, 0, newxid); + call_msg.rm_xid = atomic_fetchadd_32(_xid, 1); call_msg.rm_call.cb_prog = program; call_msg.rm_call.cb_vers = version; xdrmem_create(, cu->cu_mcallc, MCALL_MSG_SIZE, XDR_ENCODE); @@ -418,8 +423,7 @@ clnt_dg_call( call_again: mtx_assert(>cs_lock, MA_OWNED); - cu->cu_xid++; - xid = cu->cu_xid; + xid = atomic_fetchadd_32(_xid, 1); send_again: mtx_unlock(>cs_lock); @@ -865,13 +869,13 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info) (void) memcpy(>cu_raddr, addr, addr->sa_len); break; case CLGET_XID: - *(uint32_t *)info = cu->cu_xid; + *(uint32_t *)info = atomic_load_32(_xid); break; case CLSET_XID: /* This will set the xid of the NEXT call */ /* decrement by 1 as clnt_dg_call() increments once */ - cu->cu_xid = *(uint32_t *)info - 1; + atomic_store_32(_xid, *(uint32_t *)info - 1); break; case CLGET_VERS: ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359219 - head/sys/kern
Author: rmacklem Date: Sun Mar 22 18:18:30 2020 New Revision: 359219 URL: https://svnweb.freebsd.org/changeset/base/359219 Log: Fix an NFS mount attempt where VFS_STATFS() fails. r353150 added mnt_rootvnode and this seems to have broken NFS mounts when the VFS_STATFS() called just after VFS_MOUNT() returns an error. Then the code calls VFS_UNMOUNT(), which calls vflush(), which returns EBUSY. Then the thread get stuck sleeping on "mntref" in vfs_mount_destroy(). This patch fixes this problem. Reviewed by: kib, mjg Differential Revision:https://reviews.freebsd.org/D24022 Modified: head/sys/kern/vfs_mount.c Modified: head/sys/kern/vfs_mount.c == --- head/sys/kern/vfs_mount.c Sun Mar 22 17:59:36 2020(r359218) +++ head/sys/kern/vfs_mount.c Sun Mar 22 18:18:30 2020(r359219) @@ -900,7 +900,7 @@ vfs_domount_first( { struct vattr va; struct mount *mp; - struct vnode *newdp; + struct vnode *newdp, *rootvp; int error, error1; ASSERT_VOP_ELOCKED(vp, __func__); @@ -967,6 +967,9 @@ vfs_domount_first( (error1 = VFS_ROOT(mp, LK_EXCLUSIVE, )) != 0) { if (error1 != 0) { error = error1; + rootvp = vfs_cache_root_clear(mp); + if (rootvp != NULL) + vrele(rootvp); if ((error1 = VFS_UNMOUNT(mp, 0)) != 0) printf("VFS_UNMOUNT returned %d\n", error1); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358037 - stable/11/sys/fs/nfsserver
Author: rmacklem Date: Mon Feb 17 19:40:26 2020 New Revision: 358037 URL: https://svnweb.freebsd.org/changeset/base/358037 Log: MFC: r357149 Fix a crash in the NFSv4 server. The PR reported a crash that occurred when a file was removed while client(s) were actively doing lock operations on it. Since nfsvno_getvp() will return NULL when the file does not exist, the bug was obvious and easy to fix via this patch. It is a little surprising that this wasn't found sooner, but I guess the above case rarely occurs. PR: 242768 Modified: stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsserver/nfs_nfsdstate.c == --- stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Mon Feb 17 19:32:54 2020 (r358036) +++ stable/11/sys/fs/nfsserver/nfs_nfsdstate.c Mon Feb 17 19:40:26 2020 (r358037) @@ -1483,7 +1483,8 @@ nfsrv_freeallnfslocks(struct nfsstate *stp, vnode_t vp tvp = NULL; else if (vp == NULL && cansleep != 0) { tvp = nfsvno_getvp(>lf_fh); - NFSVOPUNLOCK(tvp, 0); + if (tvp != NULL) + NFSVOPUNLOCK(tvp, 0); } else tvp = vp; gottvp = 1; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358036 - stable/12/sys/fs/nfsserver
Author: rmacklem Date: Mon Feb 17 19:32:54 2020 New Revision: 358036 URL: https://svnweb.freebsd.org/changeset/base/358036 Log: MFC: r357149 Fix a crash in the NFSv4 server. The PR reported a crash that occurred when a file was removed while client(s) were actively doing lock operations on it. Since nfsvno_getvp() will return NULL when the file does not exist, the bug was obvious and easy to fix via this patch. It is a little surprising that this wasn't found sooner, but I guess the above case rarely occurs. PR: 242768 Modified: stable/12/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfsserver/nfs_nfsdstate.c == --- stable/12/sys/fs/nfsserver/nfs_nfsdstate.c Mon Feb 17 19:31:34 2020 (r358035) +++ stable/12/sys/fs/nfsserver/nfs_nfsdstate.c Mon Feb 17 19:32:54 2020 (r358036) @@ -1555,7 +1555,8 @@ nfsrv_freeallnfslocks(struct nfsstate *stp, vnode_t vp tvp = NULL; else if (vp == NULL && cansleep != 0) { tvp = nfsvno_getvp(>lf_fh); - NFSVOPUNLOCK(tvp, 0); + if (tvp != NULL) + NFSVOPUNLOCK(tvp, 0); } else tvp = vp; gottvp = 1; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r358035 - stable/10/sys/fs/nfsserver
Author: rmacklem Date: Mon Feb 17 19:31:34 2020 New Revision: 358035 URL: https://svnweb.freebsd.org/changeset/base/358035 Log: MFC: r357149 Fix a crash in the NFSv4 server. The PR reported a crash that occurred when a file was removed while client(s) were actively doing lock operations on it. Since nfsvno_getvp() will return NULL when the file does not exist, the bug was obvious and easy to fix via this patch. It is a little surprising that this wasn't found sooner, but I guess the above case rarely occurs. PR: 242768 Modified: stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/nfsserver/nfs_nfsdstate.c == --- stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Mon Feb 17 19:20:47 2020 (r358034) +++ stable/10/sys/fs/nfsserver/nfs_nfsdstate.c Mon Feb 17 19:31:34 2020 (r358035) @@ -1488,7 +1488,8 @@ nfsrv_freeallnfslocks(struct nfsstate *stp, vnode_t vp tvp = NULL; else if (vp == NULL && cansleep != 0) { tvp = nfsvno_getvp(>lf_fh); - NFSVOPUNLOCK(tvp, 0); + if (tvp != NULL) + NFSVOPUNLOCK(tvp, 0); } else tvp = vp; gottvp = 1; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357149 - head/sys/fs/nfsserver
Author: rmacklem Date: Sun Jan 26 17:59:05 2020 New Revision: 357149 URL: https://svnweb.freebsd.org/changeset/base/357149 Log: Fix a crash in the NFSv4 server. The PR reported a crash that occurred when a file was removed while client(s) were actively doing lock operations on it. Since nfsvno_getvp() will return NULL when the file does not exist, the bug was obvious and easy to fix via this patch. It is a little surprising that this wasn't found sooner, but I guess the above case rarely occurs. Tested by:iron.ud...@gmail.com PR: 242768 Reported by: iron.ud...@gmail.com MFC after:2 weeks Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c == --- head/sys/fs/nfsserver/nfs_nfsdstate.c Sun Jan 26 17:22:05 2020 (r357148) +++ head/sys/fs/nfsserver/nfs_nfsdstate.c Sun Jan 26 17:59:05 2020 (r357149) @@ -1554,7 +1554,8 @@ nfsrv_freeallnfslocks(struct nfsstate *stp, vnode_t vp tvp = NULL; else if (vp == NULL && cansleep != 0) { tvp = nfsvno_getvp(>lf_fh); - NFSVOPUNLOCK(tvp); + if (tvp != NULL) + NFSVOPUNLOCK(tvp); } else tvp = vp; gottvp = 1; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356244 - head/usr.bin/nfsstat
Author: rmacklem Date: Tue Dec 31 22:25:06 2019 New Revision: 356244 URL: https://svnweb.freebsd.org/changeset/base/356244 Log: Update the man page to reflect that "-M" and "-N" are deprecated and ignored. r356242 updated nfsstat.c to report that the "-M" and "-N" options were being ignored. These options have never had any meaning for the new NFS code (which is now the only NFS code). This patch updates the man page to reflect this. This is a content change. Modified: head/usr.bin/nfsstat/nfsstat.1 Modified: head/usr.bin/nfsstat/nfsstat.1 == --- head/usr.bin/nfsstat/nfsstat.1 Tue Dec 31 22:20:54 2019 (r356243) +++ head/usr.bin/nfsstat/nfsstat.1 Tue Dec 31 22:25:06 2019 (r356244) @@ -28,7 +28,7 @@ .\" From: @(#)nfsstat.18.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd December 21, 2019 +.Dd December 31, 2019 .Dt NFSSTAT 1 .Os .Sh NAME @@ -40,8 +40,6 @@ statistics .Nm .Op Fl -libxo .Op Fl cdEemszW -.Op Fl M Ar core -.Op Fl N Ar system .Op Fl w Ar wait .Sh DESCRIPTION The @@ -94,17 +92,14 @@ or .Fl E can be specified. .It Fl M -Extract values associated with the name list from the specified core -instead of the default -.Pa /dev/kmem . +Deprecated and ignored. .It Fl m Report the mount options for all NFS client mounts. This option overrides all others and .Nm will exit after completing the report. .It Fl N -Extract the name list from the specified system instead of the default -.Pa /boot/kernel/kernel . +Deprecated and ignored. .It Fl s Only display server side statistics. .It Fl W @@ -133,13 +128,6 @@ in a selection of different human and machine readable See .Xr xo_parse_args 3 for details on command line arguments. -.El -.Sh FILES -.Bl -tag -width ".Pa /boot/kernel/kernel" -compact -.It Pa /boot/kernel/kernel -default kernel namelist -.It Pa /dev/kmem -default memory file .El .Sh SEE ALSO .Xr fstat 1 , ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356242 - head/usr.bin/nfsstat
Author: rmacklem Date: Tue Dec 31 22:19:33 2019 New Revision: 356242 URL: https://svnweb.freebsd.org/changeset/base/356242 Log: Get rid of old nfsstat options no longer used. The "-M" and "-N" options for nfsstat were used by the old NFS code and have never done anything for the new NFS code. This patch replaces code that assigns values to variables that are never used with printf()s noting the options are ignored. This has the side effect that it gets rid of warnings w.r.t. these variables being assigned but never used, that occur for some builds. Noticed during integration of the NFSv4.2 code. Modified: head/usr.bin/nfsstat/nfsstat.c Modified: head/usr.bin/nfsstat/nfsstat.c == --- head/usr.bin/nfsstat/nfsstat.c Tue Dec 31 22:01:08 2019 (r356241) +++ head/usr.bin/nfsstat/nfsstat.c Tue Dec 31 22:19:33 2019 (r356242) @@ -149,14 +149,12 @@ main(int argc, char **argv) int serverOnly = -1; int newStats = 0; int ch; - char *memf, *nlistf; int mntlen, i; char buf[1024]; struct statfs *mntbuf; struct nfscl_dumpmntopts dumpmntopts; interval = 0; - memf = nlistf = NULL; argc = xo_parse_args(argc, argv); if (argc < 0) @@ -167,7 +165,7 @@ main(int argc, char **argv) while ((ch = getopt(argc, argv, "cdEesWM:mN:w:zq")) != -1) switch(ch) { case 'M': - memf = optarg; + printf("*** -M option deprecated, ignored\n\n"); break; case 'm': /* Display mount options for NFS mount points. */ @@ -191,7 +189,7 @@ main(int argc, char **argv) } exit(0); case 'N': - nlistf = optarg; + printf("*** -N option deprecated, ignored\n\n"); break; case 'W': widemode = 1; @@ -239,14 +237,8 @@ main(int argc, char **argv) #defineBACKWARD_COMPATIBILITY #ifdef BACKWARD_COMPATIBILITY - if (*argv) { + if (*argv) interval = atoi(*argv); - if (*++argv) { - nlistf = *argv; - if (*++argv) - memf = *argv; - } - } #endif if (modfind("nfscommon") < 0) xo_err(1, "NFS client/server not loaded"); @@ -529,7 +521,7 @@ static void usage(void) { (void)fprintf(stderr, - "usage: nfsstat [-cdemszW] [-M core] [-N system] [-w wait]\n"); + "usage: nfsstat [-cdemszW] [-w wait]\n"); exit(1); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356239 - stable/11/sys/fs/nfsclient
Author: rmacklem Date: Tue Dec 31 18:28:25 2019 New Revision: 356239 URL: https://svnweb.freebsd.org/changeset/base/356239 Log: MFC: r356066 Fix nfsmount() so that it will return NFSERR_MINORVERMISMATCH. If nfsrpc_getdirpath() returns NFSERR_MINORVERMISMATCH, it would erroneously get mapped to EIO. This was not particularily harmful, but would make it hard for sysadmins to diagnose why an NFSv4 mount is failing. mount_nfs.c still needs to be fixed so that it does not report NFSERR_MINORVERMISMATCH as an unknown error 10021. Modified: stable/11/sys/fs/nfsclient/nfs_clvfsops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsclient/nfs_clvfsops.c == --- stable/11/sys/fs/nfsclient/nfs_clvfsops.c Tue Dec 31 18:10:34 2019 (r356238) +++ stable/11/sys/fs/nfsclient/nfs_clvfsops.c Tue Dec 31 18:28:25 2019 (r356239) @@ -1541,10 +1541,8 @@ mountnfs(struct nfs_args *argp, struct mount *mp, stru if (error) (void) nfs_catnap(PZERO, error, "nfsgetdirp"); } while (error && --trycnt > 0); - if (error) { - error = nfscl_maperr(td, error, (uid_t)0, (gid_t)0); + if (error) goto bad; - } } /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356238 - stable/12/sys/fs/nfsclient
Author: rmacklem Date: Tue Dec 31 18:10:34 2019 New Revision: 356238 URL: https://svnweb.freebsd.org/changeset/base/356238 Log: MFC: r356066 Fix nfsmount() so that it will return NFSERR_MINORVERMISMATCH. If nfsrpc_getdirpath() returns NFSERR_MINORVERMISMATCH, it would erroneously get mapped to EIO. This was not particularily harmful, but would make it hard for sysadmins to diagnose why an NFSv4 mount is failing. mount_nfs.c still needs to be fixed so that it does not report NFSERR_MINORVERMISMATCH as an unknown error 10021. Modified: stable/12/sys/fs/nfsclient/nfs_clvfsops.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfsclient/nfs_clvfsops.c == --- stable/12/sys/fs/nfsclient/nfs_clvfsops.c Tue Dec 31 17:57:12 2019 (r356237) +++ stable/12/sys/fs/nfsclient/nfs_clvfsops.c Tue Dec 31 18:10:34 2019 (r356238) @@ -1544,10 +1544,8 @@ mountnfs(struct nfs_args *argp, struct mount *mp, stru if (error) (void) nfs_catnap(PZERO, error, "nfsgetdirp"); } while (error && --trycnt > 0); - if (error) { - error = nfscl_maperr(td, error, (uid_t)0, (gid_t)0); + if (error) goto bad; - } } /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356219 - head/sys/nfs
Author: rmacklem Date: Tue Dec 31 05:39:27 2019 New Revision: 356219 URL: https://svnweb.freebsd.org/changeset/base/356219 Log: Switch r356210 to use gone_in() instead of printf(). Suggested by: cem Modified: head/sys/nfs/nfs_lock.c Modified: head/sys/nfs/nfs_lock.c == --- head/sys/nfs/nfs_lock.c Tue Dec 31 04:53:50 2019(r356218) +++ head/sys/nfs/nfs_lock.c Tue Dec 31 05:39:27 2019(r356219) @@ -89,8 +89,7 @@ nfslock_open(struct cdev *dev, int oflags, int devtype { int error; - printf("WARNING: uses Giant and will be removed before FreeBSD 13\n" - "\tuse the kernel NFSLOCKD/nfslockd.ko\n"); + gone_in(13, "uses Giant; replace with NFSLOCKD/nfslockd.ko"); error = priv_check(td, PRIV_NFS_LOCKD); if (error) return (error); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356213 - head/usr.bin/nfsstat
Author: rmacklem Date: Tue Dec 31 00:07:10 2019 New Revision: 356213 URL: https://svnweb.freebsd.org/changeset/base/356213 Log: Replace .h files included from old NFS directories with the new NFS ones. Prior to this patch, nfsstat.c includes files from sys/nfs, sys/nfsclient and sys/nfsserver. These .h files (particularily the ones in sys/nfsclient and sys/nfsserver) are from the old NFS code and should eventually be deprecated/removed. This patch changes nfsstat.c to include files from the new/current NFS code instead of the old ones in preparation for eventual removal. Modified: head/usr.bin/nfsstat/nfsstat.c Modified: head/usr.bin/nfsstat/nfsstat.c == --- head/usr.bin/nfsstat/nfsstat.c Tue Dec 31 00:05:06 2019 (r356212) +++ head/usr.bin/nfsstat/nfsstat.c Tue Dec 31 00:07:10 2019 (r356213) @@ -79,11 +79,9 @@ static const char rcsid[] = #include #include #include -#include -#include -#include #include +#include #include #include ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356210 - head/sys/nfs
Author: rmacklem Date: Mon Dec 30 22:39:29 2019 New Revision: 356210 URL: https://svnweb.freebsd.org/changeset/base/356210 Log: Add warning printf w.r.t. removal of sys/nfs/nfs_lock.c. The code in sys/nfs/nfs_lock.c has not been run by default since March 2008 when it was replaced by the in kernel sys/nlm code. It uses Giant, so it needs to be removed before the FreeBSD 13 release. This will happen in a couple of months, since few if any users run the code anyhow and can easily switch to the default in kernel NFSLOCKD. Modified: head/sys/nfs/nfs_lock.c Modified: head/sys/nfs/nfs_lock.c == --- head/sys/nfs/nfs_lock.c Mon Dec 30 22:05:57 2019(r356209) +++ head/sys/nfs/nfs_lock.c Mon Dec 30 22:39:29 2019(r356210) @@ -89,6 +89,8 @@ nfslock_open(struct cdev *dev, int oflags, int devtype { int error; + printf("WARNING: uses Giant and will be removed before FreeBSD 13\n" + "\tuse the kernel NFSLOCKD/nfslockd.ko\n"); error = priv_check(td, PRIV_NFS_LOCKD); if (error) return (error); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356190 - stable/12/sys/fs/nfsclient
Author: rmacklem Date: Mon Dec 30 00:04:17 2019 New Revision: 356190 URL: https://svnweb.freebsd.org/changeset/base/356190 Log: MFC: r355530 Delete an unused external declaration. Since nfsv4_opflag is no longer used in nfs_clcomsubs.c, delete the external declaration of it. Found during NFSv4.2 code merge. Modified: stable/12/sys/fs/nfsclient/nfs_clcomsubs.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfsclient/nfs_clcomsubs.c == --- stable/12/sys/fs/nfsclient/nfs_clcomsubs.c Sun Dec 29 23:56:31 2019 (r356189) +++ stable/12/sys/fs/nfsclient/nfs_clcomsubs.c Mon Dec 30 00:04:17 2019 (r356190) @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include extern struct nfsstatsv1 nfsstatsv1; -extern struct nfsv4_opflag nfsv4_opflag[NFSV41_NOPS]; extern int ncl_mbuf_mlen; extern enum vtype newnv2tov_type[8]; extern enum vtype nv34tov_type[8]; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356189 - stable/11/sys/fs/nfs
Author: rmacklem Date: Sun Dec 29 23:56:31 2019 New Revision: 356189 URL: https://svnweb.freebsd.org/changeset/base/356189 Log: MFC: r355509 Fix kernel handling of a NFSERR_MINORVERSMISMATCH NFSv4 server reply. When an NFSv4 server replies NFSERR_MINORVERSMISMATCH, it does not generate a status result for the first operation in the compound. Without this patch, this will result in a bogus EBADXDR error return. Returning EBADXDR is relatively harmless, but a correct reply of NFSERR_MINORVERSMISMATCH is needed by the pNFS client to select the correct minor version to use for a File Layout DS now that there can be NFSv4.2 DS servers. mount_nfs.c still needs to be fixed for this, although how the mount fails is only useful to help sysadmins isolate why a mount fails. Found during testing of the NFSv4.2 client and server. Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c == --- stable/11/sys/fs/nfs/nfs_commonkrpc.c Sun Dec 29 23:48:48 2019 (r356188) +++ stable/11/sys/fs/nfs/nfs_commonkrpc.c Sun Dec 29 23:56:31 2019 (r356189) @@ -831,7 +831,8 @@ tryagain: * Get rid of the tag, return count and SEQUENCE result for * NFSv4. */ - if ((nd->nd_flag & ND_NFSV4) != 0) { + if ((nd->nd_flag & ND_NFSV4) != 0 && nd->nd_repstat != + NFSERR_MINORVERMISMATCH) { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); error = nfsm_advance(nd, NFSM_RNDUP(i), -1); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356188 - stable/12/sys/fs/nfs
Author: rmacklem Date: Sun Dec 29 23:48:48 2019 New Revision: 356188 URL: https://svnweb.freebsd.org/changeset/base/356188 Log: MFC: r355509 Fix kernel handling of a NFSERR_MINORVERSMISMATCH NFSv4 server reply. When an NFSv4 server replies NFSERR_MINORVERSMISMATCH, it does not generate a status result for the first operation in the compound. Without this patch, this will result in a bogus EBADXDR error return. Returning EBADXDR is relatively harmless, but a correct reply of NFSERR_MINORVERSMISMATCH is needed by the pNFS client to select the correct minor version to use for a File Layout DS now that there can be NFSv4.2 DS servers. mount_nfs.c still needs to be fixed for this, although how the mount fails is only useful to help sysadmins isolate why a mount fails. Found during testing of the NFSv4.2 client and server. Modified: stable/12/sys/fs/nfs/nfs_commonkrpc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfs/nfs_commonkrpc.c == --- stable/12/sys/fs/nfs/nfs_commonkrpc.c Sun Dec 29 21:46:50 2019 (r356187) +++ stable/12/sys/fs/nfs/nfs_commonkrpc.c Sun Dec 29 23:48:48 2019 (r356188) @@ -920,7 +920,8 @@ tryagain: * Get rid of the tag, return count and SEQUENCE result for * NFSv4. */ - if ((nd->nd_flag & ND_NFSV4) != 0) { + if ((nd->nd_flag & ND_NFSV4) != 0 && nd->nd_repstat != + NFSERR_MINORVERMISMATCH) { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); error = nfsm_advance(nd, NFSM_RNDUP(i), -1); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356161 - stable/11/sys/fs/nfs
Author: rmacklem Date: Sat Dec 28 22:32:14 2019 New Revision: 356161 URL: https://svnweb.freebsd.org/changeset/base/356161 Log: MFC: r355194 Fix two races while handling nfsuserd daemon start/stop. A crash was reported where the nr_client field was NULL during an upcall to the nfsuserd daemon. Since nr_client == NULL only occurs when the nfsuserd daemon is being shut down, it appeared to be caused by a race between doing an upcall and the daemon shutting down. By inspection two races were identified: 1 - The nfsrv_nfsuserd variable is used to indicate whether or not the daemon is running. However it did not handle the intermediate phase where the daemon is starting or stopping. This was fixed by making nfsrv_nfsuserd tri-state and having the functions that are called during start/stop to obey the intermediate state. 2 - nfsrv_nfsuserd was checked to see that the daemon was running at the beginning of an upcall, but nothing prevented the daemon from being shut down while an upcall was still in progress. This race probably caused the crash. The patch fixes this by adding a count of upcalls in progress and having the shut down function delay until this count goes to zero before getting rid of nr_client and related data used by an upcall. Modified: stable/11/sys/fs/nfs/nfs.h stable/11/sys/fs/nfs/nfs_commonport.c stable/11/sys/fs/nfs/nfs_commonsubs.c stable/11/sys/fs/nfs/nfsport.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfs.h == --- stable/11/sys/fs/nfs/nfs.h Sat Dec 28 22:24:16 2019(r356160) +++ stable/11/sys/fs/nfs/nfs.h Sat Dec 28 22:32:14 2019(r356161) @@ -751,6 +751,9 @@ struct nfsslot { struct mbuf *nfssl_reply; }; +/* Enumerated type for nfsuserd state. */ +typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state; + #endif /* _KERNEL */ #endif /* _NFS_NFS_H */ Modified: stable/11/sys/fs/nfs/nfs_commonport.c == --- stable/11/sys/fs/nfs/nfs_commonport.c Sat Dec 28 22:24:16 2019 (r356160) +++ stable/11/sys/fs/nfs/nfs_commonport.c Sat Dec 28 22:32:14 2019 (r356161) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); #include extern int nfscl_ticks; -extern int nfsrv_nfsuserd; +extern nfsuserd_state nfsrv_nfsuserd; extern struct nfssockreq nfsrv_nfsuserdsock; extern void (*nfsd_call_recall)(struct vnode *, int, struct ucred *, struct thread *); @@ -713,7 +713,7 @@ nfscommon_modevent(module_t mod, int type, void *data) break; case MOD_UNLOAD: - if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != 0 || + if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != NOTRUNNING || nfs_numnfscbd != 0) { error = EBUSY; break; Modified: stable/11/sys/fs/nfs/nfs_commonsubs.c == --- stable/11/sys/fs/nfs/nfs_commonsubs.c Sat Dec 28 22:24:16 2019 (r356160) +++ stable/11/sys/fs/nfs/nfs_commonsubs.c Sat Dec 28 22:32:14 2019 (r356161) @@ -62,7 +62,8 @@ struct timeval nfsboottime; /* Copy boottime once, so int nfscl_ticks; int nfsrv_useacl = 1; struct nfssockreq nfsrv_nfsuserdsock; -int nfsrv_nfsuserd = 0; +nfsuserd_state nfsrv_nfsuserd = NOTRUNNING; +static int nfsrv_userdupcalls = 0; struct nfsreqhead nfsd_reqq; uid_t nfsrv_defaultuid = UID_NOBODY; gid_t nfsrv_defaultgid = GID_NOGROUP; @@ -3105,18 +3106,22 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO int error; NFSLOCKNAMEID(); - if (nfsrv_nfsuserd) { + if (nfsrv_nfsuserd != NOTRUNNING) { NFSUNLOCKNAMEID(); error = EPERM; goto out; } - nfsrv_nfsuserd = 1; - NFSUNLOCKNAMEID(); + nfsrv_nfsuserd = STARTSTOP; /* * Set up the socket record and connect. +* Set nr_client NULL before unlocking, just to ensure that no other +* process/thread/core will use a bogus old value. This could only +* occur if the use of the nameid lock to protect nfsrv_nfsuserd is +* broken. */ rp = _nfsuserdsock; rp->nr_client = NULL; + NFSUNLOCKNAMEID(); rp->nr_sotype = SOCK_DGRAM; rp->nr_soproto = IPPROTO_UDP; rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST); @@ -3152,9 +3157,15 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO rp->nr_vers = RPCNFSUSERD_VERS; if (error == 0) error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); - if (error) { + if (error == 0) { + NFSLOCKNAMEID(); + nfsrv_nfsuserd = RUNNING; +
svn commit: r356160 - stable/12/sys/fs/nfs
Author: rmacklem Date: Sat Dec 28 22:24:16 2019 New Revision: 356160 URL: https://svnweb.freebsd.org/changeset/base/356160 Log: MFC: r355194 Fix two races while handling nfsuserd daemon start/stop. A crash was reported where the nr_client field was NULL during an upcall to the nfsuserd daemon. Since nr_client == NULL only occurs when the nfsuserd daemon is being shut down, it appeared to be caused by a race between doing an upcall and the daemon shutting down. By inspection two races were identified: 1 - The nfsrv_nfsuserd variable is used to indicate whether or not the daemon is running. However it did not handle the intermediate phase where the daemon is starting or stopping. This was fixed by making nfsrv_nfsuserd tri-state and having the functions that are called during start/stop to obey the intermediate state. 2 - nfsrv_nfsuserd was checked to see that the daemon was running at the beginning of an upcall, but nothing prevented the daemon from being shut down while an upcall was still in progress. This race probably caused the crash. The patch fixes this by adding a count of upcalls in progress and having the shut down function delay until this count goes to zero before getting rid of nr_client and related data used by an upcall. Modified: stable/12/sys/fs/nfs/nfs.h stable/12/sys/fs/nfs/nfs_commonport.c stable/12/sys/fs/nfs/nfs_commonsubs.c stable/12/sys/fs/nfs/nfsport.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfs/nfs.h == --- stable/12/sys/fs/nfs/nfs.h Sat Dec 28 19:04:29 2019(r356159) +++ stable/12/sys/fs/nfs/nfs.h Sat Dec 28 22:24:16 2019(r356160) @@ -797,6 +797,9 @@ struct nfsslot { struct mbuf *nfssl_reply; }; +/* Enumerated type for nfsuserd state. */ +typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state; + #endif /* _KERNEL */ #endif /* _NFS_NFS_H */ Modified: stable/12/sys/fs/nfs/nfs_commonport.c == --- stable/12/sys/fs/nfs/nfs_commonport.c Sat Dec 28 19:04:29 2019 (r356159) +++ stable/12/sys/fs/nfs/nfs_commonport.c Sat Dec 28 22:24:16 2019 (r356160) @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #include extern int nfscl_ticks; -extern int nfsrv_nfsuserd; +extern nfsuserd_state nfsrv_nfsuserd; extern struct nfssockreq nfsrv_nfsuserdsock; extern void (*nfsd_call_recall)(struct vnode *, int, struct ucred *, struct thread *); @@ -774,7 +774,7 @@ nfscommon_modevent(module_t mod, int type, void *data) break; case MOD_UNLOAD: - if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != 0 || + if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != NOTRUNNING || nfs_numnfscbd != 0) { error = EBUSY; break; Modified: stable/12/sys/fs/nfs/nfs_commonsubs.c == --- stable/12/sys/fs/nfs/nfs_commonsubs.c Sat Dec 28 19:04:29 2019 (r356159) +++ stable/12/sys/fs/nfs/nfs_commonsubs.c Sat Dec 28 22:24:16 2019 (r356160) @@ -64,7 +64,8 @@ struct timeval nfsboottime; /* Copy boottime once, so int nfscl_ticks; int nfsrv_useacl = 1; struct nfssockreq nfsrv_nfsuserdsock; -int nfsrv_nfsuserd = 0; +nfsuserd_state nfsrv_nfsuserd = NOTRUNNING; +static int nfsrv_userdupcalls = 0; struct nfsreqhead nfsd_reqq; uid_t nfsrv_defaultuid = UID_NOBODY; gid_t nfsrv_defaultgid = GID_NOGROUP; @@ -3524,18 +3525,22 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO int error; NFSLOCKNAMEID(); - if (nfsrv_nfsuserd) { + if (nfsrv_nfsuserd != NOTRUNNING) { NFSUNLOCKNAMEID(); error = EPERM; goto out; } - nfsrv_nfsuserd = 1; - NFSUNLOCKNAMEID(); + nfsrv_nfsuserd = STARTSTOP; /* * Set up the socket record and connect. +* Set nr_client NULL before unlocking, just to ensure that no other +* process/thread/core will use a bogus old value. This could only +* occur if the use of the nameid lock to protect nfsrv_nfsuserd is +* broken. */ rp = _nfsuserdsock; rp->nr_client = NULL; + NFSUNLOCKNAMEID(); rp->nr_sotype = SOCK_DGRAM; rp->nr_soproto = IPPROTO_UDP; rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST); @@ -3571,9 +3576,15 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO rp->nr_vers = RPCNFSUSERD_VERS; if (error == 0) error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); - if (error) { + if (error == 0) { + NFSLOCKNAMEID(); + nfsrv_nfsuserd = RUNNING; +
svn commit: r356101 - head/sbin/mount_nfs
Author: rmacklem Date: Thu Dec 26 22:33:20 2019 New Revision: 356101 URL: https://svnweb.freebsd.org/changeset/base/356101 Log: Fix mount_nfs to recognize the NFSv4 specific errors returned by nmount(2). When mount_nfs calls nmount(2), certain NFSv4 specific errors such as NFSERR_MINORVERMISMATCH can be returned. Without this patch, 10021 is reported as an unknown error. This is not particulcarily serious, but make it difficult for sysadmins to figure out why the mount attempt is failing. This patch uses nfsv4_errstr.h to convert 10021 and similar to error strings that can be printed out. A positive side effect of this patch is the removal of a reference to sys/nfsclient/nfs.h, which should no longer be used, since it is part of the old NFS client. This patch should only affect reporting of failed mount attempts and not the semantics of NFS mount attempts. Modified: head/sbin/mount_nfs/mount_nfs.c Modified: head/sbin/mount_nfs/mount_nfs.c == --- head/sbin/mount_nfs/mount_nfs.c Thu Dec 26 21:20:45 2019 (r356100) +++ head/sbin/mount_nfs/mount_nfs.c Thu Dec 26 22:33:20 2019 (r356101) @@ -61,7 +61,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include +#include #include @@ -155,7 +156,7 @@ main(int argc, char *argv[]) char *mntname, *p, *spec, *tmp; char mntpath[MAXPATHLEN], errmsg[255]; char hostname[MAXHOSTNAMELEN + 1], gssn[MAXHOSTNAMELEN + 50]; - const char *gssname; + const char *gssname, *nmount_errstr; iov = NULL; iovlen = 0; @@ -462,9 +463,14 @@ main(int argc, char *argv[]) build_iovec(, , "fspath", mntpath, (size_t)-1); build_iovec(, , "errmsg", errmsg, sizeof(errmsg)); - if (nmount(iov, iovlen, 0)) - err(1, "nmount: %s%s%s", mntpath, errmsg[0] ? ", " : "", - errmsg); + if (nmount(iov, iovlen, 0)) { + nmount_errstr = nfsv4_geterrstr(errno); + if (mountmode == V4 && nmount_errstr != NULL) + errx(1, "nmount: %s, %s", mntpath, nmount_errstr); + else + err(1, "nmount: %s%s%s", mntpath, errmsg[0] ? ", " : "", + errmsg); + } exit(0); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356099 - head/sys/fs/nfs
Author: rmacklem Date: Thu Dec 26 21:06:34 2019 New Revision: 356099 URL: https://svnweb.freebsd.org/changeset/base/356099 Log: Change NFSv4.1 and NFSv4.2 error strings to start with lower case letter. r356084 added error strings for NFSv4.1 and NFSv4.2, with the first character capitalized. Since the other error strings were not capitalized and these strings would usually be imbedded in an error, I decided to make the first characters lower cased. No real effect but more consistent. Modified: head/sys/fs/nfs/nfsv4_errstr.h Modified: head/sys/fs/nfs/nfsv4_errstr.h == --- head/sys/fs/nfs/nfsv4_errstr.h Thu Dec 26 21:00:06 2019 (r356098) +++ head/sys/fs/nfs/nfsv4_errstr.h Thu Dec 26 21:06:34 2019 (r356099) @@ -85,54 +85,54 @@ static const char *nfsv4_errstr[NFSERR_XATTR2BIG - 100 "open file blocks op", "lockowner state revoked", "callback path down" - "Bad IO mode", - "Bad layout", - "Bad session digest", - "Bad session", - "Bad slot", - "Complete already", - "Not bound to session", - "Delegation already wanted", - "Back channel busy", - "Layout try later", - "Layout unavailable", - "No matching layout", - "Recall conflict", - "Unknown layout type", - "Sequence misordered", - "Sequence position", - "Request too big", - "Reply too big", - "Reply too big to cache", - "Retry uncached reply", - "Unsafe compound", - "Too many operations", - "Operation not in session", - "Hash algorithm unsupported", - "Unknown error", - "ClientID busy", + "bad IO mode", + "bad layout", + "bad session digest", + "bad session", + "bad slot", + "complete already", + "not bound to session", + "delegation already wanted", + "back channel busy", + "layout try later", + "layout unavailable", + "no matching layout", + "recall conflict", + "unknown layout type", + "sequence misordered", + "sequence position", + "request too big", + "reply too big", + "reply too big to cache", + "retry uncached reply", + "unsafe compound", + "too many operations", + "operation not in session", + "hash algorithm unsupported", + "unknown error", + "clientID busy", "pNFS IO hole", - "Sequence false retry", - "Bad high slot", - "Dead session", - "Encrypt algorithm unsupported", + "sequence false retry", + "bad high slot", + "dead session", + "encrypt algorithm unsupported", "pNFS no layout", - "Not only operation", - "Wrong credential", - "Wrong type", - "Directory delegation unavailable", - "Reject delegation", - "Return conflict", - "Delegation revoked", - "Partner not supported", - "Partner no auth", - "Union not supported", - "Offload denied", - "Wrong LFS", - "Bad label", - "Offload no request", - "No extended attribute", - "Extended attribute too big", + "not only operation", + "wrong credential", + "wrong type", + "directory delegation unavailable", + "reject delegation", + "return conflict", + "delegation revoked", + "partner not supported", + "partner no auth", + "union not supported", + "offload denied", + "wrong LFS", + "bad label", + "offload no request", + "no extended attribute", + "extended attribute too big", }; /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356084 - head/sys/fs/nfs
Author: rmacklem Date: Wed Dec 25 22:25:30 2019 New Revision: 356084 URL: https://svnweb.freebsd.org/changeset/base/356084 Log: Add NFSv4.1 and NFSv4.2 errors to nfsv4_errstr.h. nfsv4_errstr.h only had strings for NFSv4.0 errors. This patch adds the errors for NFSv4.1 and NFSv4.2. At this time, this file is not used by any sources in the tree, so the change is not significant. I do plan on using nfsv4_errstr.h in a future patch to mount_nfs.c. Since I am doing this patch so that "minor version mismatch" will be recognized, I made that string less abbreviated. Modified: head/sys/fs/nfs/nfsv4_errstr.h Modified: head/sys/fs/nfs/nfsv4_errstr.h == --- head/sys/fs/nfs/nfsv4_errstr.h Wed Dec 25 22:19:23 2019 (r356083) +++ head/sys/fs/nfs/nfsv4_errstr.h Wed Dec 25 22:25:30 2019 (r356084) @@ -36,7 +36,7 @@ * a library of one function for this, since it is only currently used by * mount_newnfs.c. */ -static const char *nfsv4_errstr[48] = { +static const char *nfsv4_errstr[NFSERR_XATTR2BIG - 1] = { "Illegal filehandle", "Undefined NFSv4 err", "READDIR cookie is stale", @@ -57,7 +57,7 @@ static const char *nfsv4_errstr[48] = { "resource exhaustion", "filesystem relocated", "current FH is not set", - "minor vers not supp", + "minor version not supported", "server has rebooted", "server has rebooted", "state is out of sync", @@ -85,6 +85,54 @@ static const char *nfsv4_errstr[48] = { "open file blocks op", "lockowner state revoked", "callback path down" + "Bad IO mode", + "Bad layout", + "Bad session digest", + "Bad session", + "Bad slot", + "Complete already", + "Not bound to session", + "Delegation already wanted", + "Back channel busy", + "Layout try later", + "Layout unavailable", + "No matching layout", + "Recall conflict", + "Unknown layout type", + "Sequence misordered", + "Sequence position", + "Request too big", + "Reply too big", + "Reply too big to cache", + "Retry uncached reply", + "Unsafe compound", + "Too many operations", + "Operation not in session", + "Hash algorithm unsupported", + "Unknown error", + "ClientID busy", + "pNFS IO hole", + "Sequence false retry", + "Bad high slot", + "Dead session", + "Encrypt algorithm unsupported", + "pNFS no layout", + "Not only operation", + "Wrong credential", + "Wrong type", + "Directory delegation unavailable", + "Reject delegation", + "Return conflict", + "Delegation revoked", + "Partner not supported", + "Partner no auth", + "Union not supported", + "Offload denied", + "Wrong LFS", + "Bad label", + "Offload no request", + "No extended attribute", + "Extended attribute too big", }; /* @@ -95,7 +143,7 @@ static const char * nfsv4_geterrstr(int errval) { - if (errval < NFSERR_BADHANDLE || errval > NFSERR_CBPATHDOWN) + if (errval < NFSERR_BADHANDLE || errval > NFSERR_XATTR2BIG) return (NULL); return (nfsv4_errstr[errval - NFSERR_BADHANDLE]); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r356066 - head/sys/fs/nfsclient
Author: rmacklem Date: Wed Dec 25 01:15:38 2019 New Revision: 356066 URL: https://svnweb.freebsd.org/changeset/base/356066 Log: Fix nfsmount() so that it will return NFSERR_MINORVERMISMATCH. If nfsrpc_getdirpath() returns NFSERR_MINORVERMISMATCH, it would erroneously get mapped to EIO. This was not particularily harmful, but would make it hard for sysadmins to diagnose why an NFSv4 mount is failing. mount_nfs.c still needs to be fixed so that it does not report NFSERR_MINORVERMISMATCH as an unknown error 10021. MFC after:1 week Modified: head/sys/fs/nfsclient/nfs_clvfsops.c Modified: head/sys/fs/nfsclient/nfs_clvfsops.c == --- head/sys/fs/nfsclient/nfs_clvfsops.cTue Dec 24 23:43:29 2019 (r356065) +++ head/sys/fs/nfsclient/nfs_clvfsops.cWed Dec 25 01:15:38 2019 (r356066) @@ -1544,10 +1544,8 @@ mountnfs(struct nfs_args *argp, struct mount *mp, stru if (error) (void) nfs_catnap(PZERO, error, "nfsgetdirp"); } while (error && --trycnt > 0); - if (error) { - error = nfscl_maperr(td, error, (uid_t)0, (gid_t)0); + if (error) goto bad; - } } /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355993 - head/usr.bin/nfsstat
Author: rmacklem Date: Sun Dec 22 00:36:22 2019 New Revision: 355993 URL: https://svnweb.freebsd.org/changeset/base/355993 Log: Update the nfsstat man page to reflect r355992. r355992 added listing of NFSv4.2 procedure and operation counts. This patch updates the nfsstat.1 man page to reflect that change. This is a content change. Modified: head/usr.bin/nfsstat/nfsstat.1 Modified: head/usr.bin/nfsstat/nfsstat.1 == --- head/usr.bin/nfsstat/nfsstat.1 Sun Dec 22 00:12:22 2019 (r355992) +++ head/usr.bin/nfsstat/nfsstat.1 Sun Dec 22 00:36:22 2019 (r355993) @@ -28,7 +28,7 @@ .\" From: @(#)nfsstat.18.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd October 1, 2018 +.Dd December 21, 2019 .Dt NFSSTAT 1 .Os .Sh NAME @@ -86,8 +86,8 @@ server for NFSv4. .It Fl E Similar to .Fl e -except that the statistics include NFSv4.1 and the numbers aren't clipped -at one billion. +except that the statistics include NFSv4.1 and NFSv4.2 and the numbers aren't +clipped at one billion. Only one of .Fl e or ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355992 - head/usr.bin/nfsstat
Author: rmacklem Date: Sun Dec 22 00:12:22 2019 New Revision: 355992 URL: https://svnweb.freebsd.org/changeset/base/355992 Log: Update nfsstat to list the NFSv4.2 procedures and operations. r355677 added NFSv4.2 support to the NFS client and server. It also updated the nfsstats structure to keep counts for the new procedures (client) and operations (server) added for NFSv4.2. This patch updates the "-E" option of nfsstat so that it lists counts for these new procedures and operations. Modified: head/usr.bin/nfsstat/nfsstat.c Modified: head/usr.bin/nfsstat/nfsstat.c == --- head/usr.bin/nfsstat/nfsstat.c Sat Dec 21 22:32:24 2019 (r355991) +++ head/usr.bin/nfsstat/nfsstat.c Sun Dec 22 00:12:22 2019 (r355992) @@ -772,6 +772,31 @@ exp_intpr(int clientOnly, int serverOnly, int nfs41) (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_CREATELAYGET]); xo_close_container("nfsv41"); + + xo_open_container("nfsv42"); + + xo_emit("{T:IOAdvise/%13.13s}{T:Allocate/%13.13s}" + "{T:Copy/%13.13s}{T:Seek/%13.13s}" + "{T:SeekDataS/%13.13s}{T:GetExtattr/%13.13s}\n"); + xo_emit("{:ioadvise/%13ju}{:allocate/%13ju}" + "{:copy/%13ju}{:seek/%13ju}" + "{:seekdatas/%13ju}{:getextattr/%13ju}\n", + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_IOADVISE], + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_ALLOCATE], + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_COPY], + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SEEK], + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SEEKDS], + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_GETEXTATTR]); + + xo_emit("{T:SetExtattr/%13.13s}{T:RmExtattr/%13.13s}" + "{T:ListExtattr/%13.13s}\n"); + xo_emit("{:setextattr/%13ju}{:rmextattr/%13ju}" + "{:listextattr/%13ju}\n", + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SETEXTATTR], + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RMEXTATTR], + (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LISTEXTATTR]); + + xo_close_container("nfsv42"); } xo_close_container("operations"); @@ -993,6 +1018,48 @@ exp_intpr(int clientOnly, int serverOnly, int nfs41) (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RECLAIMCOMPL]); xo_close_container("nfsv41"); + + xo_open_container("nfsv42"); + + xo_emit("{T:Allocate/%13.13s}{T:Copy/%13.13s}" + "{T:CopyNotify/%13.13s}{T:Deallocate/%13.13s}" + "{T:IOAdvise/%13.13s}{T:LayoutError/%13.13s}\n"); + xo_emit("{:allocate/%13ju}{:copy/%13ju}" + "{:copynotify/%13ju}{:deallocate/%13ju}" + "{:ioadvise/%13ju}{:layouterror/%13ju}\n", + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_ALLOCATE], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_COPY], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_COPYNOTIFY], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_DEALLOCATE], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_IOADVISE], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LAYOUTERROR]); + + xo_emit("{T:LayoutStats/%13.13s}{T:OffloadCncl/%13.13s}" + "{T:OffloadStat/%13.13s}{T:ReadPlus/%13.13s}" + "{T:Seek/%13.13s}{T:WriteSame/%13.13s}\n"); + xo_emit("{:layoutstats/%13ju}{:offloadcncl/%13ju}" + "{:offloadstat/%13ju}{:readplus/%13ju}" + "{:seek/%13ju}{:writesame/%13ju}\n", + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LAYOUTSTATS], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OFFLOADCANCEL], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OFFLOADSTATUS], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READPLUS], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SEEK], + (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_WRITESAME]); + + xo_emit("{T:Clone/%13.13s}{T:GetExtattr/%13.13s}" + "{T:SetExtattr/%13.13s}{T:ListExtattr/%13.13s}" + "{T:RmExtattr/%13.13s}\n"); +
svn commit: r355967 - stable/11/sys/rpc/rpcsec_gss
Author: rmacklem Date: Fri Dec 20 23:08:10 2019 New Revision: 355967 URL: https://svnweb.freebsd.org/changeset/base/355967 Log: MFC: r355157, r355161 Add a cap on credential lifetime for Kerberized NFS. The kernel RPCSEC_GSS code sets the credential (called a client) lifetime to the lifetime of the Kerberos ticket, which is typically several hours. As such, when a user's credentials change such as being added to a new group, it can take several hours for this change to be recognized by the NFS server. This patch adds a sysctl called kern.rpc.gss.lifetime_max which can be set by a sysadmin to put a cap on the time to expire for the credentials, so that a sysadmin can reduce the timeout. It also fixes a bug, where time_uptime is added twice when GSS_C_INDEFINITE is returned for a lifetime. This has no effect in practice, since Kerberos never does this. PR: 242132 Modified: stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c == --- stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Fri Dec 20 22:53:23 2019(r355966) +++ stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Fri Dec 20 23:08:10 2019(r355967) @@ -177,6 +177,11 @@ SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, client_max, CTLFL _rpc_gss_client_max, 0, "Max number of rpc-gss clients"); +static u_int svc_rpc_gss_lifetime_max = 0; +SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, lifetime_max, CTLFLAG_RW, +_rpc_gss_lifetime_max, 0, +"Maximum lifetime (seconds) of rpc-gss clients"); + static u_int svc_rpc_gss_client_count; SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, client_count, CTLFLAG_RD, _rpc_gss_client_count, 0, @@ -947,8 +952,15 @@ svc_rpc_gss_accept_sec_context(struct svc_rpc_gss_clie * that out). */ if (cred_lifetime == GSS_C_INDEFINITE) - cred_lifetime = time_uptime + 24*60*60; + cred_lifetime = 24*60*60; + /* +* Cap cred_lifetime if sysctl kern.rpc.gss.lifetime_max is set. +*/ + if (svc_rpc_gss_lifetime_max > 0 && cred_lifetime > + svc_rpc_gss_lifetime_max) + cred_lifetime = svc_rpc_gss_lifetime_max; + client->cl_expiration = time_uptime + cred_lifetime; /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355966 - stable/12/sys/rpc/rpcsec_gss
Author: rmacklem Date: Fri Dec 20 22:53:23 2019 New Revision: 355966 URL: https://svnweb.freebsd.org/changeset/base/355966 Log: MFC: r355157, r355161 Add a cap on credential lifetime for Kerberized NFS. The kernel RPCSEC_GSS code sets the credential (called a client) lifetime to the lifetime of the Kerberos ticket, which is typically several hours. As such, when a user's credentials change such as being added to a new group, it can take several hours for this change to be recognized by the NFS server. This patch adds a sysctl called kern.rpc.gss.lifetime_max which can be set by a sysadmin to put a cap on the time to expire for the credentials, so that a sysadmin can reduce the timeout. It also fixes a bug, where time_uptime is added twice when GSS_C_INDEFINITE is returned for a lifetime. This has no effect in practice, since Kerberos never does this. Modified: stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c == --- stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Fri Dec 20 22:12:21 2019(r355965) +++ stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Fri Dec 20 22:53:23 2019(r355966) @@ -180,6 +180,11 @@ SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, client_max, CTLFL _rpc_gss_client_max, 0, "Max number of rpc-gss clients"); +static u_int svc_rpc_gss_lifetime_max = 0; +SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, lifetime_max, CTLFLAG_RW, +_rpc_gss_lifetime_max, 0, +"Maximum lifetime (seconds) of rpc-gss clients"); + static u_int svc_rpc_gss_client_count; SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, client_count, CTLFLAG_RD, _rpc_gss_client_count, 0, @@ -950,8 +955,15 @@ svc_rpc_gss_accept_sec_context(struct svc_rpc_gss_clie * that out). */ if (cred_lifetime == GSS_C_INDEFINITE) - cred_lifetime = time_uptime + 24*60*60; + cred_lifetime = 24*60*60; + /* +* Cap cred_lifetime if sysctl kern.rpc.gss.lifetime_max is set. +*/ + if (svc_rpc_gss_lifetime_max > 0 && cred_lifetime > + svc_rpc_gss_lifetime_max) + cred_lifetime = svc_rpc_gss_lifetime_max; + client->cl_expiration = time_uptime + cred_lifetime; /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355960 - head/usr.sbin/nfsd
Author: rmacklem Date: Fri Dec 20 21:45:20 2019 New Revision: 355960 URL: https://svnweb.freebsd.org/changeset/base/355960 Log: Update the man page to reflect the addition of NFSv4.2 (r355677). Update all the references to NFSv4.1, so that they apply to NFSv4.1 and NFSv4.2. Also, change the MDS->DS mounts to use NFSv4.2, so that both versions of the protocol can be used against the server with pNFS enabled. This is a content change. Modified: head/usr.sbin/nfsd/pnfsserver.4 Modified: head/usr.sbin/nfsd/pnfsserver.4 == --- head/usr.sbin/nfsd/pnfsserver.4 Fri Dec 20 21:42:10 2019 (r355959) +++ head/usr.sbin/nfsd/pnfsserver.4 Fri Dec 20 21:45:20 2019 (r355960) @@ -23,12 +23,12 @@ .\" .\" $FreeBSD$ .\" -.Dd August 8, 2018 +.Dd December 20, 2019 .Dt PNFSSERVER 4 .Os .Sh NAME .Nm pNFSserver -.Nd NFS Version 4.1 Parallel NFS Protocol Server +.Nd NFS Version 4.1 and 4.2 Parallel NFS Protocol Server .Sh DESCRIPTION A set of FreeBSD servers may be configured to provide a .Xr pnfs 4 @@ -37,13 +37,23 @@ One FreeBSD system needs to be configured as a MetaDat at least one additional FreeBSD system needs to be configured as one or more Data Servers (DS)s. .Pp -These FreeBSD systems are configured to be NFSv4.1 servers, see +These FreeBSD systems are configured to be NFSv4.1 and NFSv4.2 +servers, see .Xr nfsd 8 and .Xr exports 5 -if you are not familiar with configuring a NFSv4.1 server. +if you are not familiar with configuring a NFSv4.n server. +All DS(s) and the MDS should support NFSv4.2 as well as NFSv4.1. +Mixing an MDS that supports NFSv4.2 with any DS(s) that do not support +NFSv4.2 will not work correctly. +As such, all DS(s) must be upgraded from +.Fx 12 +to +.Fx 13 +before upgrading the MDS. .Sh DS server configuration -The DS(s) need to be configured as NFSv4.1 server(s), with a top level exported +The DS(s) need to be configured as NFSv4.1 and NFSv4.2 server(s), +with a top level exported directory used for storage of data files. This directory must be owned by .Dq root @@ -89,8 +99,8 @@ DS system. .Sh MDS server configuration The MDS must be a separate FreeBSD system from the FreeBSD DS system(s) and NFS clients. -It is configured as a NFSv4.1 server with file system(s) exported to -clients. +It is configured as a NFSv4.1 and NFSv4.2 server with +file system(s) exported to clients. However, the .Dq -p command line argument for @@ -99,7 +109,7 @@ is used to indicate that it is running as the MDS for .Pp The DS(s) must all be mounted on the MDS using the following mount options: .Bd -literal -offset indent -nfsv4,minorversion=1,soft,retrans=2 +nfsv4,minorversion=2,soft,retrans=2 .Ed .sp so that they can be defined as DSs in the @@ -112,10 +122,10 @@ For example, if there are four DSs named nfsv4-data[0- .Xr fstab 5 lines might look like: .Bd -literal -offset -nfsv4-data0:/ /data0 nfs rw,nfsv4,minorversion=1,soft,retrans=2 0 0 -nfsv4-data1:/ /data1 nfs rw,nfsv4,minorversion=1,soft,retrans=2 0 0 -nfsv4-data2:/ /data2 nfs rw,nfsv4,minorversion=1,soft,retrans=2 0 0 -nfsv4-data3:/ /data3 nfs rw,nfsv4,minorversion=1,soft,retrans=2 0 0 +nfsv4-data0:/ /data0 nfs rw,nfsv4,minorversion=2,soft,retrans=2 0 0 +nfsv4-data1:/ /data1 nfs rw,nfsv4,minorversion=2,soft,retrans=2 0 0 +nfsv4-data2:/ /data2 nfs rw,nfsv4,minorversion=2,soft,retrans=2 0 0 +nfsv4-data3:/ /data3 nfs rw,nfsv4,minorversion=2,soft,retrans=2 0 0 .Ed .sp The @@ -201,7 +211,8 @@ For a service that will store a large number of files set much larger, to avoid the number of entries in a subdirectory from getting too large. .Sh Client mounts -Once operational, NFSv4.1 FreeBSD client mounts done with the +Once operational, NFSv4.1 or NFSv4.2 FreeBSD client mounts +done with the .Dq pnfs option should do I/O directly on the DSs. The clients mounting the MDS must be running the @@ -325,7 +336,7 @@ directory for storage of data files just like it did w Mount it on the MDS exactly as you did before disabling it. For the nfsv4-data3 example, the command would be: .Bd -literal -offset -# mount -t nfs -o nfsv4,minorversion=1,soft,retrans=2 nfsv4-data3:/ /data3 +# mount -t nfs -o nfsv4,minorversion=2,soft,retrans=2 nfsv4-data3:/ /data3 .Ed .sp Then restart the nfsd to re-enable the DS. @@ -403,7 +414,7 @@ http://people.freebsd.org/~rmacklem/pnfs-planb-setup.t .Sh HISTORY The .Nm -command first appeared in +service first appeared in .Fx 12.0 . .Sh BUGS Since the MDS cannot be mirrored, it is a single point of failure just ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355958 - head/usr.sbin/nfsd
Author: rmacklem Date: Fri Dec 20 21:41:33 2019 New Revision: 355958 URL: https://svnweb.freebsd.org/changeset/base/355958 Log: Update the man page to reflect the addition of NFSv4.2 (r355677). Include references to NFSv4.2 and Flexible File layout, plus clarify when vfs.nfsd.flexlinuxhack needs to be set for Linux pNFS clients. Also update the man page to reflect the addition of SpaceUsed to the attributes stored in the extended attribute on the MDS (r354158). This is a content change. Modified: head/usr.sbin/nfsd/pnfs.4 Modified: head/usr.sbin/nfsd/pnfs.4 == --- head/usr.sbin/nfsd/pnfs.4 Fri Dec 20 21:33:12 2019(r355957) +++ head/usr.sbin/nfsd/pnfs.4 Fri Dec 20 21:41:33 2019(r355958) @@ -23,19 +23,21 @@ .\" .\" $FreeBSD$ .\" -.Dd August 5, 2018 +.Dd December 20, 2019 .Dt PNFS 4 .Os .Sh NAME .Nm pNFS -.Nd NFS Version 4.1 Parallel NFS Protocol +.Nd NFS Version 4.1 and 4.2 Parallel NFS Protocol .Sh DESCRIPTION -The NFSv4.1 client and server provides support for the +The NFSv4.1 and NFSv4.2 client and server provides support for the .Tn pNFS specification; see -.%T "Network File System (NFS) Version 4 Minor Version 1 Protocol RFC 5661" . -A pNFS service separates Read/Write operations from all other NFSv4.1 -operations, which are referred to as Metadata operations. +.%T "Network File System (NFS) Version 4 Minor Version 1 Protocol RFC 5661" , +.%T "Network File System (NFS) Version 4 Minor Version 2 Protocol RFC 7862" and +.%T "Parallel NFS (pNFS) Flexible File Layout RFC 8435" . +A pNFS service separates Read/Write operations from all other NFSv4.1 and +NFSv4.2 operations, which are referred to as Metadata operations. The Read/Write operations are performed directly on the Data Server (DS) where the file's data resides, bypassing the NFS server. All other file operations are performed on the NFS server, which is referred to @@ -45,8 +47,8 @@ NFS clients that do not support perform Read/Write operations on the MDS, which acts as a proxy for the appropriate DS(s). .Pp -The NFSv4.1 protocol provides two pieces of information to pNFS aware -clients that allow them to perform Read/Write operations directly on +The NFSv4.1 and NFSv4.2 protocols provide two pieces of information to pNFS +aware clients that allow them to perform Read/Write operations directly on the DS. .Pp The first is DeviceInfo, which is static information defining the DS @@ -72,20 +74,21 @@ at least for certain layout types such as the Flexible .Pp The FreeBSD client and server supports two layout types. .Pp -The File Layout is described in RFC5661 and uses the NFSv4.1 protocol +The File Layout is described in RFC5661 and uses the NFSv4.1 or NFSv4.2 protocol to perform I/O on the DS. It does not support client aware DS mirroring and, as such, the FreeBSD server only provides File Layout support for non-mirrored configurations. .Pp -The Flexible File Layout allows the use of the NFSv3, NFSv4.0 or NFSv4.1 -protocol to perform I/O on the DS and does support client aware mirroring. +The Flexible File Layout allows the use of the NFSv3, NFSv4.0, NFSv4.1 or +NFSv4.2 protocol to perform I/O on the DS and does support client aware +mirroring. As such, the FreeBSD server uses Flexible File Layout layouts for the mirrored DS configurations. The FreeBSD server supports the .Dq tightly coupled -variant and all DSs use the -NFSv4.1 protocol for I/O operations. +variant and all DSs allow use of the +NFSv4.2 or NFSv4.1 protocol for I/O operations. Clients that support the Flexible File Layout will do writes and commits to all DS mirrors in the mirror set. .Pp @@ -107,6 +110,7 @@ A FreeBSD client must be running the .Xr nfscbd 8 daemon and use the mount options +.Dq nfsv4,minorversion=2,pnfs or .Dq nfsv4,minorversion=1,pnfs . .Pp When files are created, the MDS creates a file tree identical to what a @@ -120,7 +124,7 @@ attribute name space: pnfsd.dsfile - This extended attrbute stores the information that the MDS needs to find the data file on a DS(s) for this file. pnfsd.dsattr - This extended attribute stores the Size, AccessTime, -ModifyTime and Change attributes for the file. +ModifyTime, Change and SpaceUsed attributes for the file. .Ed .Pp For each regular (VREG) file, the MDS creates a data file on one @@ -142,7 +146,8 @@ or Flexible File Layout layouts and associated DeviceInfo. For non-pNFS aware NFS clients, the pNFS service appears just like a normal NFS service. -For the non-pNFS aware client, the MDS will perform I/O operations on the appropriate DS(s), acting as +For the non-pNFS aware client, the MDS will perform I/O operations on the +appropriate DS(s), acting as a proxy for the non-pNFS aware client. This is also true for NFSv3 and NFSv4.0 mounts, since these are always non-pNFS aware. @@ -182,16 +187,17 @@ For Linux 4.17-rc2 kernels, I have not seen client
svn commit: r355956 - head/usr.sbin/nfsd
Author: rmacklem Date: Fri Dec 20 21:31:08 2019 New Revision: 355956 URL: https://svnweb.freebsd.org/changeset/base/355956 Log: Update the man page to reflect the addition of NFSv4.2 (r355677). Include references to NFSv4.2 and associated RFCs and note new features present in NFSv4.2. This is a content change. Modified: head/usr.sbin/nfsd/nfsv4.4 Modified: head/usr.sbin/nfsd/nfsv4.4 == --- head/usr.sbin/nfsd/nfsv4.4 Fri Dec 20 21:30:51 2019(r355955) +++ head/usr.sbin/nfsd/nfsv4.4 Fri Dec 20 21:31:08 2019(r355956) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 19, 2017 +.Dd December 20, 2019 .Dt NFSV4 4 .Os .Sh NAME @@ -34,8 +34,11 @@ The NFS client and server provides support for the .Tn NFSv4 specification; see -.%T "Network File System (NFS) Version 4 Protocol RFC 7530" and -.%T "Network File System (NFS) Version 4 Minor Version 1 Protocol RFC 5661" . +.%T "Network File System (NFS) Version 4 Protocol RFC 7530" , +.%T "Network File System (NFS) Version 4 Minor Version 1 Protocol RFC 5661" , +.%T "Network File System (NFS) Version 4 Minor Version 2 Protocol RFC 7862" , +.%T "File System Extended Attributes in NFSv4 RFC 8276" and +.%T "Parallel NFS (pNFS) Flexible File Layout RFC 8435" . The protocol is somewhat similar to NFS Version 3, but differs in significant ways. It uses a single compound RPC that concatenates operations to-gether. @@ -76,6 +79,12 @@ It provides several optional features not present in N (not yet implemented) - Delegations, which allow a client to operate on a file locally - pNFS, where I/O operations are separated from Metadata operations +And for NFSv4.2 only +- User namespace extended attributes +- lseek(SEEK_DATA/SEEK_HOLE) +- File copying done locally on the server for copy_file_range(2) +- posix_fallocate(2) +- posix_fadvise(POSIX_FADV_WILLNEED/POSIX_FADV_DONTNEED) .Ed .Pp The @@ -306,7 +315,7 @@ N.N.N.N.N.N where the first 4 Ns are the host IP address and the last two are the port# in network byte order (all decimal #s in the range 0-255). .Pp -For NFSv4.1, the callback path (called a backchannel) uses the same TCP connection as the mount, +For NFSv4.1 and NFSv4.2, the callback path (called a backchannel) uses the same TCP connection as the mount, so none of the above applies and should work through gateways without any issues. .Pp ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355954 - head/usr.sbin/nfsd
Author: rmacklem Date: Fri Dec 20 21:25:51 2019 New Revision: 355954 URL: https://svnweb.freebsd.org/changeset/base/355954 Log: Update the man page to reflect the addition of NFSv4.2 (r355677). Include references to NFSv4.2 and associated RFCs. Also clarify when a Linux client needs to set vfs.nfsd.flexlinuxhack if a pNFS server is in use. This is a content change. Modified: head/usr.sbin/nfsd/nfsd.8 Modified: head/usr.sbin/nfsd/nfsd.8 == --- head/usr.sbin/nfsd/nfsd.8 Fri Dec 20 21:25:22 2019(r355953) +++ head/usr.sbin/nfsd/nfsd.8 Fri Dec 20 21:25:51 2019(r355954) @@ -28,7 +28,7 @@ .\"@(#)nfsd.8 8.4 (Berkeley) 3/29/95 .\" $FreeBSD$ .\" -.Dd February 14, 2019 +.Dd December 20, 2019 .Dt NFSD 8 .Os .Sh NAME @@ -222,9 +222,15 @@ RFC1094, .%T "NFS: Network File System Version 3 Protocol Specification" , RFC1813, .%T "Network File System (NFS) Version 4 Protocol" , -RFC3530 and +RFC7530, .%T "Network File System (NFS) Version 4 Minor Version 1 Protocol" , -RFC5661. +RFC5661, +.%T "Network File System (NFS) Version 4 Minor Version 2 Protocol" , +RFC7862, +.%T "File System Extended Attributes in NFSv4" , +RFC8276 and +.%T "Parallel NFS (pNFS) Flexible File Layout" , +RFC8435. .Pp If .Nm @@ -323,13 +329,13 @@ and then restart it, after the .Xr gssd 8 is running. .Pp -If mirroring is enabled via the -.Fl m -option and there are Linux clients doing NFSv4.1 mounts, those clients -need to be patched to support the -.Dq tightly coupled -variant of -the Flexible File layout or the +For a Flexible File Layout pNFS server, +if there are Linux clients doing NFSv4.1 or NFSv4.2 mounts, those +clients might need the .Xr sysctl 8 vfs.nfsd.flexlinuxhack -must be set to one on the MDS as a workaround. +to be set to one on the MDS as a workaround. +.Pp +Linux 5.n kernels appear to have been patched such that this +.Xr sysctl 8 +does not need to be set. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355758 - head/sbin/mount_nfs
Author: rmacklem Date: Sat Dec 14 21:49:47 2019 New Revision: 355758 URL: https://svnweb.freebsd.org/changeset/base/355758 Log: Update the mount_nfs.8 man page to include NFSv4.2. r355677 added NFSv4.2 support to the NFS client. This patch updates the mount_nfs.8 man page to reflect that. It also clarifies that the "nolockd" option does not apply to NFSv4 mounts. This is a content change. Modified: head/sbin/mount_nfs/mount_nfs.8 Modified: head/sbin/mount_nfs/mount_nfs.8 == --- head/sbin/mount_nfs/mount_nfs.8 Sat Dec 14 19:44:42 2019 (r355757) +++ head/sbin/mount_nfs/mount_nfs.8 Sat Dec 14 21:49:47 2019 (r355758) @@ -28,7 +28,7 @@ .\"@(#)mount_nfs.8 8.3 (Berkeley) 3/29/95 .\" $FreeBSD$ .\" -.Dd April 13, 2017 +.Dd December 14, 2019 .Dt MOUNT_NFS 8 .Os .Sh NAME @@ -59,9 +59,11 @@ on to the file system tree at the point .Ar node . This command is normally executed by .Xr mount 8 . -It implements the mount protocol as described in RFC 1094, Appendix A and -.%T "NFS: Network File System Version 3 Protocol Specification" , -Appendix I. +For NFSv2 and NFSv3, +it implements the mount protocol as described in RFC 1094, Appendix A and +RFC 1813, Appendix I. +For NFSv4, it uses the NFSv4 protocol as described in RFC 7530, RFC 5661 and +RFC 7862. .Pp By default, .Nm @@ -197,20 +199,20 @@ This option will force the mount to use TCP transport. .It Cm minorversion Ns = Ns Aq Ar value Override the default of 0 for the minor version of the NFS Version 4 protocol. -The only minor version currently supported is 1. +The minor versions other than 0 currently supported are 1 and 2. This option is only meaningful when used with the .Cm nfsv4 option. .It Cm oneopenown -Make a minor version 1 of the NFS Version 4 protocol mount use a single OpenOwner -for all Opens. +Make a minor version 1 or 2 of the NFS Version 4 protocol mount use a single +OpenOwner for all Opens. This may be useful for a server with a very low limit on OpenOwners, such as AmazonEFS. -It can only be used with an NFSv4.1 mount. +It ca only be used with an NFSv4.1 or NFSv4.2 mount. It may not work correctly when Delegations are being issued by a server, but note that the AmazonEFS server does not issued delegations at this time. .It Cm pnfs -Enable support for parallel NFS (pNFS) for minor version 1 of the +Enable support for parallel NFS (pNFS) for minor version 1 or 2 of the NFS Version 4 protocol. This option is only meaningful when used with the .Cm minorversion @@ -250,9 +252,9 @@ Do .Em not forward .Xr fcntl 2 -locks over the wire. +locks over the wire via the NLM protocol for NFSv3 mounts. All locks will be local and not seen by the server -and likewise not seen by other NFS clients. +and likewise not seen by other NFS clients for NFSv3 mounts. This removes the need to run the .Xr rpcbind 8 service and the @@ -263,6 +265,9 @@ servers on the client. Note that this option will only be honored when performing the initial mount, it will be silently ignored if used while updating the mount options. +Also, note that NFSv4 mounts do not use these daemons and handle locks over the +wire in the NFSv4 protocol. +As such, this option is meaningless for NFSv4 mounts. .It Cm noncontigwr This mount option allows the NFS client to combine non-contiguous byte ranges being written ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355733 - in head/sys/fs: nfsclient nfsserver
Author: rmacklem Date: Fri Dec 13 21:38:08 2019 New Revision: 355733 URL: https://svnweb.freebsd.org/changeset/base/355733 Log: Silence some "might not be initialized" warnings for riscv64. None of these case were actually using the variable(s) uninitialized, but I figured that silencing the warnings via initializing them made sense. Some of these predated r355677. Modified: head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdserv.c head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfsclient/nfs_clrpcops.c == --- head/sys/fs/nfsclient/nfs_clrpcops.cFri Dec 13 21:03:12 2019 (r355732) +++ head/sys/fs/nfsclient/nfs_clrpcops.cFri Dec 13 21:38:08 2019 (r355733) @@ -5001,6 +5001,8 @@ nfsrpc_getdeviceinfo(struct nfsmount *nmp, uint8_t *de uint8_t stripeindex; sa_family_t af, safilled; + ssin.sin_port = 0; /* To shut up compiler. */ + ssin.sin_addr.s_addr = 0; /* ditto */ *ndip = NULL; ndi = NULL; gotdspp = NULL; @@ -5436,7 +5438,7 @@ nfsrpc_fillsa(struct nfsmount *nmp, struct sockaddr_in struct nfsclds *dsp, *tdsp; int error, firsttry; enum nfsclds_state retv; - uint32_t sequenceid; + uint32_t sequenceid = 0; KASSERT(nmp->nm_sockreq.nr_cred != NULL, ("nfsrpc_fillsa: NULL nr_cred")); Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 21:03:12 2019 (r355732) +++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 21:38:08 2019 (r355733) @@ -4670,7 +4670,7 @@ nfsrv_dsgetsockmnt(struct vnode *vp, int lktype, char char *devid, char *fnamep, struct vnode **nvpp, struct nfsmount **newnmpp, struct nfsmount *curnmp, int *ippos, int *dsdirp) { - struct vnode *dvp, *nvp, **tdvpp; + struct vnode *dvp, *nvp = NULL, **tdvpp; struct mount *mp; struct nfsmount *nmp, *newnmp; struct sockaddr *sad; Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c == --- head/sys/fs/nfsserver/nfs_nfsdserv.cFri Dec 13 21:03:12 2019 (r355732) +++ head/sys/fs/nfsserver/nfs_nfsdserv.cFri Dec 13 21:38:08 2019 (r355733) @@ -4594,7 +4594,7 @@ nfsrvd_layoutcommit(struct nfsrv_descript *nd, __unuse nfsv4stateid_t stateid; int error = 0, hasnewoff, hasnewmtime, layouttype, maxcnt, reclaim; int hasnewsize; - uint64_t offset, len, newoff, newsize; + uint64_t offset, len, newoff = 0, newsize; struct timespec newmtime; char *layp; struct thread *p = curthread; Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c == --- head/sys/fs/nfsserver/nfs_nfsdstate.c Fri Dec 13 21:03:12 2019 (r355732) +++ head/sys/fs/nfsserver/nfs_nfsdstate.c Fri Dec 13 21:38:08 2019 (r355733) @@ -4056,10 +4056,10 @@ nfsrv_getclientipaddr(struct nfsrv_descript *nd, struc int i, j, maxalen = 0, minalen = 0; sa_family_t af; #ifdef INET - struct sockaddr_in *rin, *sin; + struct sockaddr_in *rin = NULL, *sin; #endif #ifdef INET6 - struct sockaddr_in6 *rin6, *sin6; + struct sockaddr_in6 *rin6 = NULL, *sin6; #endif u_char *addr; int error = 0, cantparse = 0; @@ -7075,7 +7075,7 @@ nfsrv_recalloldlayout(NFSPROC_T *p) nfsquad_t clientid; nfsv4stateid_t stateid; fhandle_t fh; - int error, laytype, ret; + int error, laytype = 0, ret; lhyp = [arc4random() % nfsrv_layouthashsize]; NFSLOCKLAYOUT(lhyp); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355715 - head
Author: rmacklem Date: Fri Dec 13 16:28:48 2019 New Revision: 355715 URL: https://svnweb.freebsd.org/changeset/base/355715 Log: Add an entry to RELNOTES for r355677. Modified: head/RELNOTES Modified: head/RELNOTES == --- head/RELNOTES Fri Dec 13 14:48:44 2019(r355714) +++ head/RELNOTES Fri Dec 13 16:28:48 2019(r355715) @@ -10,6 +10,28 @@ newline. Entries should be separated by a newline. Changes to this file should not be MFCed. +r355677: + Adds support for NFSv4.2 (RFC-7862) and Extended Attributes + (RFC-8276) to the NFS client and server. + NFSv4.2 is comprised of several optional features that can be supported + in addition to NFSv4.1. This patch adds the following optional features: + - posix_fadvise(POSIX_FADV_WILLNEED/POSIX_FADV_DONTNEED) + - posix_fallocate() + - intra server file range copying via the copy_file_range(2) syscall + --> Avoiding data tranfer over the wire to/from the NFS client. + - lseek(SEEK_DATA/SEEK_HOLE) + - Extended attribute syscalls for "user" namespace attributes as defined + by RFC-8276. + + For the client, NFSv4.2 is only used if the mount command line option + minorversion=2 is specified. + For the server, two new sysctls called vfs.nfsd.server_min_minorversion4 + and vfs.nfsd.server_max_minorversion4 have been added that allow + sysadmins to limit the minor versions of NFSv4 supported by the nfsd + server. + Setting vfs.nfsd.server_max_minorversion4 to 0 or 1 will disable NFSv4.2 + on the server. + r354517: iwm(4) now supports most Intel 9260, 9460 and 9560 Wi-Fi devices. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355684 - in head/sys/fs: nfsclient nfsserver
Author: rmacklem Date: Fri Dec 13 01:34:25 2019 New Revision: 355684 URL: https://svnweb.freebsd.org/changeset/base/355684 Log: Add some more initializations to quiet riscv build. The one case in nfs_copy_file_range() was a legitimate case, although it would probably never occur in practice. Modified: head/sys/fs/nfsclient/nfs_clvnops.c head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfsclient/nfs_clvnops.c == --- head/sys/fs/nfsclient/nfs_clvnops.c Fri Dec 13 01:17:20 2019 (r355683) +++ head/sys/fs/nfsclient/nfs_clvnops.c Fri Dec 13 01:34:25 2019 (r355684) @@ -3639,6 +3639,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a off_t inoff, outoff; bool consecutive, must_commit, tryoutcred; + ret = ret2 = 0; nmp = VFSTONFS(invp->v_mount); mtx_lock(>nm_mtx); /* NFSv4.2 Copy is not permitted for infile == outfile. */ Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 01:17:20 2019 (r355683) +++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 01:34:25 2019 (r355684) @@ -5155,7 +5155,7 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s NFSPROC_T *p, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt, struct mbuf **mpp, char *cp, int *failposp) { - struct nfsrvwritedsdorpc *drpc, *tdrpc; + struct nfsrvwritedsdorpc *drpc, *tdrpc = NULL; struct nfsvattr na; struct mbuf *m; int error, i, offs, ret, timo; @@ -5322,7 +5322,7 @@ nfsrv_allocatedsrpc(fhandle_t *fhp, off_t off, off_t l NFSPROC_T *p, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt, int *failposp) { - struct nfsrvallocatedsdorpc *drpc, *tdrpc; + struct nfsrvallocatedsdorpc *drpc, *tdrpc = NULL; struct nfsvattr na; int error, i, ret, timo; @@ -5506,7 +5506,7 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt, struct nfsvattr *nap, int *failposp) { - struct nfsrvsetattrdsdorpc *drpc, *tdrpc; + struct nfsrvsetattrdsdorpc *drpc, *tdrpc = NULL; struct nfsvattr na; int error, i, ret, timo; @@ -5655,7 +5655,7 @@ nfsrv_setacldsrpc(fhandle_t *fhp, struct ucred *cred, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt, struct acl *aclp, int *failposp) { - struct nfsrvsetacldsdorpc *drpc, *tdrpc; + struct nfsrvsetacldsdorpc *drpc, *tdrpc = NULL; int error, i, ret, timo; NFSD_DEBUG(4, "in nfsrv_setacldsrpc\n"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355682 - head/sys/fs/nfsserver
Author: rmacklem Date: Fri Dec 13 00:45:14 2019 New Revision: 355682 URL: https://svnweb.freebsd.org/changeset/base/355682 Log: Fix the build for MAC not defined and a couple of might not be initialized. r355677 broke the build for the not MAC defined case and a couple of might not be initialized warnings were generated for riscv. Others seem to be erroneous. Hopefully there won't be too many more build errors. Pointy hat goes on me. Modified: head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 00:14:12 2019 (r355681) +++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 00:45:14 2019 (r355682) @@ -3980,7 +3980,7 @@ static void nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, struct ucred *cred, NFSPROC_T *p) { - struct nfsrvdscreate *dsc, *tdsc; + struct nfsrvdscreate *dsc, *tdsc = NULL; struct nfsdevice *ds, *tds, *fds; struct mount *mp; struct pnfsdsfile *pf, *tpf; @@ -5890,7 +5890,7 @@ nfsrv_pnfssetfh(struct vnode *vp, struct pnfsdsfile *p char *fnamep, struct vnode *nvp, NFSPROC_T *p) { struct nfsnode *np; - int ret; + int ret = 0; np = VTONFS(nvp); NFSBCOPY(np->n_fhp->nfh_fh, >dsf_fh, NFSX_MYFH); @@ -6210,12 +6210,13 @@ nfsvno_setxattr(struct vnode *vp, char *name, int len, struct uio uio, *uiop = int cnt, error; + error = 0; #ifdef MAC error = mac_vnode_check_setextattr(cred, vp, EXTATTR_NAMESPACE_USER, name); +#endif if (error != 0) goto out; -#endif uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; @@ -6263,9 +6264,7 @@ nfsvno_rmxattr(struct nfsrv_descript *nd, struct vnode if (error == EOPNOTSUPP) error = VOP_SETEXTATTR(vp, EXTATTR_NAMESPACE_USER, name, NULL, cred, p); -#ifdef MAC out: -#endif NFSEXITCODE(error); return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355681 - in head/sys: kern sys
Author: rmacklem Date: Fri Dec 13 00:14:12 2019 New Revision: 355681 URL: https://svnweb.freebsd.org/changeset/base/355681 Log: r355677 requires that vop_stdioctl() be global so it can be called from NFS. r355677 modified the NFS client so that it does lseek(SEEK_DATA/SEEK_HOLE) for NFSv4.2, but calls vop_stdioctl() otherwise. As such, vop_stdioctl() needs to be a global function. Missed during the code merge for r355677. Modified: head/sys/kern/vfs_default.c head/sys/sys/vnode.h Modified: head/sys/kern/vfs_default.c == --- head/sys/kern/vfs_default.c Thu Dec 12 23:55:34 2019(r355680) +++ head/sys/kern/vfs_default.c Fri Dec 13 00:14:12 2019(r355681) @@ -87,7 +87,6 @@ static int vop_stdadd_writecount(struct vop_add_writec static int vop_stdcopy_file_range(struct vop_copy_file_range_args *ap); static int vop_stdfdatasync(struct vop_fdatasync_args *ap); static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); -static int vop_stdioctl(struct vop_ioctl_args *ap); /* * This vnode table stores what we want to do if the filesystem doesn't @@ -1249,7 +1248,7 @@ vop_stdneed_inactive(struct vop_need_inactive_args *ap return (1); } -static int +int vop_stdioctl(struct vop_ioctl_args *ap) { struct vnode *vp; Modified: head/sys/sys/vnode.h == --- head/sys/sys/vnode.hThu Dec 12 23:55:34 2019(r355680) +++ head/sys/sys/vnode.hFri Dec 13 00:14:12 2019(r355681) @@ -760,6 +760,7 @@ int vop_stdfsync(struct vop_fsync_args *); intvop_stdgetwritemount(struct vop_getwritemount_args *); intvop_stdgetpages(struct vop_getpages_args *); intvop_stdinactive(struct vop_inactive_args *); +intvop_stdioctl(struct vop_ioctl_args *); intvop_stdneed_inactive(struct vop_need_inactive_args *); intvop_stdkqfilter(struct vop_kqfilter_args *); intvop_stdlock(struct vop_lock1_args *); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355679 - head/sys/sys
Author: rmacklem Date: Thu Dec 12 23:37:04 2019 New Revision: 355679 URL: https://svnweb.freebsd.org/changeset/base/355679 Log: Bump __FreeBSD_version since r355677 changes the internal interface between the NFS modules such that they all need to be upgraded to post r355677 simultaneously. Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h == --- head/sys/sys/param.hThu Dec 12 23:33:32 2019(r355678) +++ head/sys/sys/param.hThu Dec 12 23:37:04 2019(r355679) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300065 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300066 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355678 - head
Author: rmacklem Date: Thu Dec 12 23:33:32 2019 New Revision: 355678 URL: https://svnweb.freebsd.org/changeset/base/355678 Log: Add an entry to UPDATING for r355677. Modified: head/UPDATING Modified: head/UPDATING == --- head/UPDATING Thu Dec 12 23:22:55 2019(r355677) +++ head/UPDATING Thu Dec 12 23:33:32 2019(r355678) @@ -26,6 +26,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20191212: + r355677 has modified the internal interface used between the + NFS modules in the kernel. As such, they must all be upgraded + simultaneously. I will do a version bump for this. + 20191205: The root certificates of the Mozilla CA Certificate Store have been imported into the base system and can be managed with the certctl(8) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355677 - in head/sys/fs: nfs nfsclient nfsserver
Author: rmacklem Date: Thu Dec 12 23:22:55 2019 New Revision: 355677 URL: https://svnweb.freebsd.org/changeset/base/355677 Log: Add support for NFSv4.2 to the NFS client and server. This patch adds support for NFSv4.2 (RFC-7862) and Extended Attributes (RFC-8276) to the NFS client and server. NFSv4.2 is comprised of several optional features that can be supported in addition to NFSv4.1. This patch adds the following optional features: - posix_fadvise(POSIX_FADV_WILLNEED/POSIX_FADV_DONTNEED) - posix_fallocate() - intra server file range copying via the copy_file_range(2) syscall --> Avoiding data tranfer over the wire to/from the NFS client. - lseek(SEEK_DATA/SEEK_HOLE) - Extended attribute syscalls for "user" namespace attributes as defined by RFC-8276. Although this patch is fairly large, it should not affect support for the other versions of NFS. However it does add two new sysctls that allow a sysadmin to limit which minor versions of NFSv4 a server supports, allowing a sysadmin to disable NFSv4.2. Unfortunately, when the NFS stats structure was last revised, it was assumed that there would be no additional operations added beyond what was specified in RFC-7862. However RFC-8276 did add additional operations, forcing the NFS stats structure to revised again. It now has extra unused entries in all arrays, so that future extensions to NFSv4.2 can be accomodated without revising this structure again. A future commit will update nfsstat(1) to report counts for the new NFSv4.2 specific operations/procedures. This patch affects the internal interface between the nfscommon, nfscl and nfsd modules and, as such, they all must be upgraded simultaneously. I will do a version bump (although arguably not needed), due to this. This code has survived a "make universe" but has not been built with a recent GCC. If you encounter build problems, please email me. Relnotes: yes Modified: head/sys/fs/nfs/nfs.h head/sys/fs/nfs/nfs_commonport.c head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfs_var.h head/sys/fs/nfs/nfsclstate.h head/sys/fs/nfs/nfsport.h head/sys/fs/nfs/nfsproto.h head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsclient/nfs_clstate.c head/sys/fs/nfsclient/nfs_clvfsops.c head/sys/fs/nfsclient/nfs_clvnops.c head/sys/fs/nfsclient/nfsmount.h head/sys/fs/nfsserver/nfs_nfsdkrpc.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdserv.c head/sys/fs/nfsserver/nfs_nfsdsocket.c head/sys/fs/nfsserver/nfs_nfsdstate.c head/sys/fs/nfsserver/nfs_nfsdsubs.c Modified: head/sys/fs/nfs/nfs.h == --- head/sys/fs/nfs/nfs.h Thu Dec 12 22:59:22 2019(r355676) +++ head/sys/fs/nfs/nfs.h Thu Dec 12 23:22:55 2019(r355677) @@ -668,6 +668,8 @@ struct nfsrv_descript { uint32_t*nd_sequence; /* Sequence Op. ptr */ nfsv4stateid_t nd_curstateid; /* Current StateID */ nfsv4stateid_t nd_savedcurstateid; /* Saved Current StateID */ + uint32_tnd_maxreq; /* Max. request (session). */ + uint32_tnd_maxresp; /* Max. reply (session). */ }; #definend_princlen nd_gssnamelen Modified: head/sys/fs/nfs/nfs_commonport.c == --- head/sys/fs/nfs/nfs_commonport.cThu Dec 12 22:59:22 2019 (r355676) +++ head/sys/fs/nfs/nfs_commonport.cThu Dec 12 23:22:55 2019 (r355677) @@ -80,6 +80,7 @@ int nfs_pnfsio(task_fn_t *, void *); static int nfs_realign_test; static int nfs_realign_count; static struct ext_nfsstats oldnfsstats; +static struct nfsstatsov1 nfsstatsov1; SYSCTL_NODE(_vfs, OID_AUTO, nfs, CTLFLAG_RW, 0, "NFS filesystem"); SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, _realign_test, @@ -580,11 +581,143 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, } else { error = copyin(uap->argp, , sizeof(nfsstatver)); - if (error == 0 && nfsstatver.vers != NFSSTATS_V1) - error = EPERM; - if (error == 0) - error = copyout(, uap->argp, - sizeof (nfsstatsv1)); + if (error == 0) { + if (nfsstatver.vers == NFSSTATS_OV1) { + /* Copy nfsstatsv1 to nfsstatsov1. */ + nfsstatsov1.attrcache_hits = + nfsstatsv1.attrcache_hits; + nfsstatsov1.attrcache_misses = + nfsstatsv1.attrcache_misses; +
svn commit: r355674 - in stable/12/sys/fs: nfs nfsserver
Author: rmacklem Date: Thu Dec 12 22:00:10 2019 New Revision: 355674 URL: https://svnweb.freebsd.org/changeset/base/355674 Log: MFC: r354989 Fix the pNFS server's reporting of SpaceUsed (va_bytes). The pNFS server currently reports SpaceUsed (va_bytes) for the metadata file. This in not correct, since the metadata file is always empty and, as such, va_bytes is just the allocation for the empty file. This patch adds va_bytes to the list of attributes acquired from the DS for a file, so that it includes the allocated data size and is updated when the file is written. For files created on a pNFS server before this patch is applied, the va_bytes value is estimated by rounding va_size up to a multiple of BLKDEV_IOSIZE. Once the file is written after this patch has been applied to the metadata server, the va_bytes returned for the file will be correct. This patch only affects a pNFS metadata server. Found during testing of the NFSv4.2 pNFS server for the Allocate operation. (Not yet in head/current.) Modified: stable/12/sys/fs/nfs/nfsrvstate.h stable/12/sys/fs/nfsserver/nfs_nfsdport.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfs/nfsrvstate.h == --- stable/12/sys/fs/nfs/nfsrvstate.h Thu Dec 12 21:33:00 2019 (r355673) +++ stable/12/sys/fs/nfs/nfsrvstate.h Thu Dec 12 22:00:10 2019 (r355674) @@ -355,14 +355,24 @@ struct nfsdevice { }; /* - * This structure holds the va_size, va_filerev, va_atime and va_mtime for the - * DS file and is stored in the metadata file's extended attribute pnfsd.dsattr. + * This structure holds the va_size, va_filerev, va_atime, va_mtime and + * va_bytes for the DS file and is stored in the metadata file's extended + * attribute pnfsd.dsattr. + * opnfsdsattr was missing the va_bytes field and, as such, it was updated. */ +struct opnfsdsattr { + uint64_tdsa_filerev; + uint64_tdsa_size; + struct timespec dsa_atime; + struct timespec dsa_mtime; +}; + struct pnfsdsattr { uint64_tdsa_filerev; uint64_tdsa_size; struct timespec dsa_atime; struct timespec dsa_mtime; + uint64_tdsa_bytes; }; /* Modified: stable/12/sys/fs/nfsserver/nfs_nfsdport.c == --- stable/12/sys/fs/nfsserver/nfs_nfsdport.c Thu Dec 12 21:33:00 2019 (r355673) +++ stable/12/sys/fs/nfsserver/nfs_nfsdport.c Thu Dec 12 22:00:10 2019 (r355674) @@ -277,7 +277,8 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap } /* -* Acquire the Change, Size and TimeModify attributes, as required. +* Acquire the Change, Size, TimeAccess, TimeModify and SpaceUsed +* attributes, as required. * This needs to be done for regular files if: * - non-NFSv4 RPCs or * - when attrbitp == NULL or @@ -292,7 +293,8 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_CHANGE) || NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SIZE) || NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEACCESS) || - NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFY))) { + NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFY) || + NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SPACEUSED))) { error = nfsrv_proxyds(nd, vp, 0, 0, nd->nd_cred, p, NFSPROC_GETATTR, NULL, NULL, NULL, , NULL); if (error == 0) @@ -312,6 +314,7 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap nvap->na_mtime = na.na_mtime; nvap->na_filerev = na.na_filerev; nvap->na_size = na.na_size; + nvap->na_bytes = na.na_bytes; } NFSD_DEBUG(4, "nfsvno_getattr: gotattr=%d err=%d chg=%ju\n", gotattr, error, (uintmax_t)na.na_filerev); @@ -3880,6 +3883,7 @@ nfsrv_dscreate(struct vnode *dvp, struct vattr *vap, s dsa->dsa_size = va.va_size; dsa->dsa_atime = va.va_atime; dsa->dsa_mtime = va.va_mtime; + dsa->dsa_bytes = va.va_bytes; } } if (error == 0) { @@ -4404,6 +4408,7 @@ nfsrv_proxyds(struct nfsrv_descript *nd, struct vnode struct vnode *dvp[NFSDEV_MAXMIRRORS]; struct nfsdevice *ds; struct pnfsdsattr dsattr; + struct opnfsdsattr odsattr; char *buf; int buflen, error, failpos, i, mirrorcnt, origmircnt, trycnt; @@ -4428,15 +4433,31 @@ nfsrv_proxyds(struct nfsrv_descript *nd, struct vnode error = vn_extattr_get(vp, IO_NODELOCKED,
svn commit: r355530 - head/sys/fs/nfsclient
Author: rmacklem Date: Sun Dec 8 16:59:36 2019 New Revision: 355530 URL: https://svnweb.freebsd.org/changeset/base/355530 Log: Delete an unused external declaration. Since nfsv4_opflag is no longer used in nfs_clcomsubs.c, delete the external declaration of it. Found during NFSv4.2 code merge. MFC after:2 weeks Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c == --- head/sys/fs/nfsclient/nfs_clcomsubs.c Sun Dec 8 15:24:03 2019 (r355529) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Sun Dec 8 16:59:36 2019 (r355530) @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include extern struct nfsstatsv1 nfsstatsv1; -extern struct nfsv4_opflag nfsv4_opflag[NFSV41_NOPS]; extern int ncl_mbuf_mlen; extern enum vtype newnv2tov_type[8]; extern enum vtype nv34tov_type[8]; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355509 - head/sys/fs/nfs
Author: rmacklem Date: Sun Dec 8 00:06:00 2019 New Revision: 355509 URL: https://svnweb.freebsd.org/changeset/base/355509 Log: Fix kernel handling of a NFSERR_MINORVERSMISMATCH NFSv4 server reply. When an NFSv4 server replies NFSERR_MINORVERSMISMATCH, it does not generate a status result for the first operation in the compound. Without this patch, this will result in a bogus EBADXDR error return. Returning EBADXDR is relatively harmless, but a correct reply of NFSERR_MINORVERSMISMATCH is needed by the pNFS client to select the correct minor version to use for a File Layout DS now that there can be NFSv4.2 DS servers. mount_nfs.c still needs to be fixed for this, although how the mount fails is only useful to help sysadmins isolate why a mount fails. Found during testing of the NFSv4.2 client and server. MFC after:2 weeks Modified: head/sys/fs/nfs/nfs_commonkrpc.c Modified: head/sys/fs/nfs/nfs_commonkrpc.c == --- head/sys/fs/nfs/nfs_commonkrpc.cSun Dec 8 00:02:36 2019 (r355508) +++ head/sys/fs/nfs/nfs_commonkrpc.cSun Dec 8 00:06:00 2019 (r355509) @@ -918,7 +918,8 @@ tryagain: * Get rid of the tag, return count and SEQUENCE result for * NFSv4. */ - if ((nd->nd_flag & ND_NFSV4) != 0) { + if ((nd->nd_flag & ND_NFSV4) != 0 && nd->nd_repstat != + NFSERR_MINORVERMISMATCH) { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); error = nfsm_advance(nd, NFSM_RNDUP(i), -1); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355507 - head/sys/fs/nfs
Author: rmacklem Date: Sat Dec 7 23:13:51 2019 New Revision: 355507 URL: https://svnweb.freebsd.org/changeset/base/355507 Log: Add some definitions for NFSv4.2 which will be used by subsequent commits. This is a preliminary commit of NFSv4.2 definitions that will be used by subsequent commits which adds NFSv4.2 support to the NFS client and server. There will be a series of these preliminary commits that will prepare for a major commit of the NFSv4.2 client/server changes currently found in subversion under projects/nfsv42/sys. Modified: head/sys/fs/nfs/nfsport.h Modified: head/sys/fs/nfs/nfsport.h == --- head/sys/fs/nfs/nfsport.h Sat Dec 7 20:01:55 2019(r355506) +++ head/sys/fs/nfs/nfsport.h Sat Dec 7 23:13:51 2019(r355507) @@ -257,9 +257,38 @@ /* * Must be one more than last op#. - * NFSv4.2 isn't implemented yet, but define the op# limit for it. */ #defineNFSV41_NOPS 59 + +/* + * Additional operations for NFSv4.2. + */ +#defineNFSV4OP_ALLOCATE59 +#defineNFSV4OP_COPY60 +#defineNFSV4OP_COPYNOTIFY 61 +#defineNFSV4OP_DEALLOCATE 62 +#defineNFSV4OP_IOADVISE63 +#defineNFSV4OP_LAYOUTERROR 64 +#defineNFSV4OP_LAYOUTSTATS 65 +#defineNFSV4OP_OFFLOADCANCEL 66 +#defineNFSV4OP_OFFLOADSTATUS 67 +#defineNFSV4OP_READPLUS68 +#defineNFSV4OP_SEEK69 +#defineNFSV4OP_WRITESAME 70 +#defineNFSV4OP_CLONE 71 + +/* One greater than the last Operation # defined in RFC-7862. */ +#defineNFSV42_PURENOPS 72 + +/* and the optional Extended attribute operations (RFC-8276). */ +#defineNFSV4OP_GETXATTR72 +#defineNFSV4OP_SETXATTR73 +#defineNFSV4OP_LISTXATTRS 74 +#defineNFSV4OP_REMOVEXATTR 75 + +/* + * Must be one more than the last NFSv4.2 op#. + */ #defineNFSV42_NOPS 72 /* Quirky case if the illegal op code */ @@ -309,6 +338,12 @@ #defineNFSV4OP_CBNOTIFYDEVID 14 #defineNFSV41_CBNOPS 15 + +/* + * Additional callback operations for NFSv4.2. + */ +#defineNFSV4OP_CBOFFLOAD 15 + #defineNFSV42_CBNOPS 16 /* @@ -366,6 +401,24 @@ * Must be defined as one higher than the last NFSv4.1 Proc# above. */ #defineNFSV41_NPROCS 56 + +/* Additional procedures for NFSv4.2. */ +#defineNFSPROC_IOADVISE56 +#defineNFSPROC_ALLOCATE57 +#defineNFSPROC_COPY58 +#defineNFSPROC_SEEK59 +#defineNFSPROC_SEEKDS 60 + +/* and the ones for the optional Extended attribute support (RFC-8276). */ +#defineNFSPROC_GETEXTATTR 61 +#defineNFSPROC_SETEXTATTR 62 +#defineNFSPROC_RMEXTATTR 63 +#defineNFSPROC_LISTEXTATTR 64 + +/* + * Must be defined as one higher than the last NFSv4.2 Proc# above. + */ +#defineNFSV42_NPROCS 65 #endif /* NFS_V3NPROCS */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355479 - head/sys/fs/nfs
Author: rmacklem Date: Sat Dec 7 01:10:38 2019 New Revision: 355479 URL: https://svnweb.freebsd.org/changeset/base/355479 Log: Set the XATTRSUPPORT attribute bit for NFSv4.2, always cleared for now. Since r355472 added code which clears the XATTRSUPPORT bit for non-NFSv4.2 mounts, it is now safe to set it. There will be a series of these preliminary commits that will prepare for a major commit of the NFSv4.2 client/server changes currently found in subversion under projects/nfsv42/sys. This commit completes updates to nfsproto.h required by the NFSv4.2. Modified: head/sys/fs/nfs/nfsproto.h Modified: head/sys/fs/nfs/nfsproto.h == --- head/sys/fs/nfs/nfsproto.h Sat Dec 7 00:53:22 2019(r355478) +++ head/sys/fs/nfs/nfsproto.h Sat Dec 7 01:10:38 2019(r355479) @@ -1154,7 +1154,8 @@ struct nfsv3_sattr { (NFSATTRBM_LAYOUTTYPE | \ NFSATTRBM_LAYOUTBLKSIZE | \ NFSATTRBM_LAYOUTALIGNMENT | \ - NFSATTRBM_SUPPATTREXCLCREAT) + NFSATTRBM_SUPPATTREXCLCREAT | \ + NFSATTRBM_XATTRSUPPORT) /* * These are the set only attributes. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355472 - head/sys/fs/nfs
Author: rmacklem Date: Fri Dec 6 23:51:11 2019 New Revision: 355472 URL: https://svnweb.freebsd.org/changeset/base/355472 Log: Add a couple of definitions for NFSv4.2 and update macros to use them. This patch adds code to macros to clear attribute bits not supported by NFSv4.2. For now, these bits are never set anyhow, but this prepares the code for the addition of NFSv4.2 support in a future commit. There will be a series of these preliminary commits that will prepare for a major commit of the NFSv4.2 client/server changes currently found in subversion under projects/nfsv42/sys. Modified: head/sys/fs/nfs/nfs.h Modified: head/sys/fs/nfs/nfs.h == --- head/sys/fs/nfs/nfs.h Fri Dec 6 23:49:37 2019(r355471) +++ head/sys/fs/nfs/nfs.h Fri Dec 6 23:51:11 2019(r355472) @@ -335,6 +335,7 @@ struct nfsreferral { #defineLCL_NFSV41 0x0002 #defineLCL_DONEBINDCONN0x0004 #defineLCL_RECLAIMONEFS0x0008 +#defineLCL_NFSV42 0x0010 #defineLCL_GSS LCL_KERBV /* Or of all mechs */ @@ -431,6 +432,8 @@ typedef struct { (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1; \ (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2; \ } \ + if (((n)->nd_flag & ND_NFSV42) == 0)\ + (b)->bits[2] &= ~NFSATTRBIT_NFSV42_2; \ } while (0) #defineNFSISSET_ATTRBIT(b, p) ((b)->bits[(p) / 32] & (1 << ((p) % 32))) @@ -457,6 +460,8 @@ typedef struct { (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1; \ (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2; \ } \ + if (((n)->nd_flag & ND_NFSV42) == 0)\ + (b)->bits[2] &= ~NFSATTRBIT_NFSV42_2; \ } while (0) #defineNFSCLRNOTSETABLE_ATTRBIT(b, n) do { \ @@ -465,6 +470,8 @@ typedef struct { (b)->bits[2] &= NFSATTRBIT_SETABLE2;\ if (((n)->nd_flag & ND_NFSV41) == 0)\ (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2; \ + if (((n)->nd_flag & ND_NFSV42) == 0)\ + (b)->bits[2] &= ~NFSATTRBIT_NFSV42_2; \ } while (0) #defineNFSNONZERO_ATTRBIT(b) ((b)->bits[0] || (b)->bits[1] || (b)->bits[2]) @@ -701,6 +708,7 @@ struct nfsrv_descript { #defineND_CURSTATEID 0x8000 #defineND_SAVEDCURSTATEID 0x1 #defineND_HASSLOTID0x2 +#defineND_NFSV42 0x4 /* * ND_GSS should be the "or" of all GSS type authentications. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355435 - head/sys/fs/nfs
Author: rmacklem Date: Fri Dec 6 01:53:02 2019 New Revision: 355435 URL: https://svnweb.freebsd.org/changeset/base/355435 Log: Add some definitions for NFSv4.2 which will be used by subsequent commits. This is a preliminary commit of NFSv4.2 definitions that will be used by subsequent commits which adds NFSv4.2 support to the NFS client and server. There will be a series of these preliminary commits that will prepare for a major commit of the NFSv4.2 client/server changes currently found in subversion under projects/nfsv42/sys. Modified: head/sys/fs/nfs/nfsproto.h Modified: head/sys/fs/nfs/nfsproto.h == --- head/sys/fs/nfs/nfsproto.h Fri Dec 6 00:29:16 2019(r355434) +++ head/sys/fs/nfs/nfsproto.h Fri Dec 6 01:53:02 2019(r355435) @@ -705,6 +705,7 @@ /* Flags for File Layout. */ #defineNFSFLAYUTIL_DENSE 0x1 #defineNFSFLAYUTIL_COMMIT_THRU_MDS 0x2 +#defineNFSFLAYUTIL_IOADVISE_THRU_MDS 0x4 #defineNFSFLAYUTIL_STRIPE_MASK 0xffc0 /* Flags for Flex File Layout. */ @@ -874,6 +875,24 @@ struct nfsv3_sattr { u_int32_t sa_mtimetype; nfstime3 sa_mtime; }; + +/* + * IO Advise hint bits for NFSv4.2. + * Since these go on the wire as a bitmap, the NFSATTRBIT macros are + * used to manipulate these bits. + */ +#defineNFSV4IOHINT_NORMAL 0 +#defineNFSV4IOHINT_SEQUENTIAL 1 +#defineNFSV4IOHINT_SEQUENTIALBACK 2 +#defineNFSV4IOHINT_RANDOM 3 +#defineNFSV4IOHINT_WILLNEED4 +#defineNFSV4IOHINT_WILLNEEDOPTUN 5 +#defineNFSV4IOHINT_DONTNEED6 +#defineNFSV4IOHINT_NOREUSE 7 +#defineNFSV4IOHINT_READ8 +#defineNFSV4IOHINT_WRITE 9 +#defineNFSV4IOHINT_INITPROXIMITY 10 + #endif /* _KERNEL */ /* @@ -960,6 +979,12 @@ struct nfsv3_sattr { #defineNFSATTRBIT_MODESETMASKED74 #defineNFSATTRBIT_SUPPATTREXCLCREAT75 #defineNFSATTRBIT_FSCHARSETCAP 76 +#defineNFSATTRBIT_CLONEBLKSIZE 77 +#defineNFSATTRBIT_SPACEFREED 78 +#defineNFSATTRBIT_CHANGEATTRTYPE 79 +#defineNFSATTRBIT_SECLABEL 80 +/* Not sure what attribute bit #81 is? */ +#defineNFSATTRBIT_XATTRSUPPORT 82 #defineNFSATTRBM_SUPPORTEDATTRS0x0001 #defineNFSATTRBM_TYPE 0x0002 @@ -1038,6 +1063,12 @@ struct nfsv3_sattr { #defineNFSATTRBM_MODESETMASKED 0x0400 #defineNFSATTRBM_SUPPATTREXCLCREAT 0x0800 #defineNFSATTRBM_FSCHARSETCAP 0x1000 +#defineNFSATTRBM_CLONEBLKSIZE 0x2000 +#defineNFSATTRBM_SPACEFREED0x4000 +#defineNFSATTRBM_CHANGEATTRTYPE0x8000 +#defineNFSATTRBM_SECLABEL 0x0001 +/* Not sure what attribute bit#81/0x0002 is? */ +#defineNFSATTRBM_XATTRSUPPORT 0x0004 #defineNFSATTRBIT_MAX 77 @@ -1162,6 +1193,11 @@ struct nfsv3_sattr { NFSATTRBM_SUPPATTREXCLCREAT) /* + * NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2. + */ +#defineNFSATTRBIT_NFSV42_2 NFSATTRBM_XATTRSUPPORT + +/* * Set of attributes that the getattr vnode op needs. * OR of the following bits. * NFSATTRBIT_GETATTR0 - bits 0<->31 @@ -1462,5 +1498,14 @@ typedef struct nfsv4stateid nfsv4stateid_t; #defineNFSV4LAYOUTRET_FILE 1 #defineNFSV4LAYOUTRET_FSID 2 #defineNFSV4LAYOUTRET_ALL 3 + +/* Seek Contents. */ +#defineNFSV4CONTENT_DATA 0 +#defineNFSV4CONTENT_HOLE 1 + +/* Options for Set Extended attribute (RFC-8276). */ +#defineNFSV4SXATTR_EITHER 0 +#defineNFSV4SXATTR_CREATE 1 +#defineNFSV4SXATTR_REPLACE 2 #endif /* _NFS_NFSPROTO_H_ */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355406 - head/sys/fs/nfs
Author: rmacklem Date: Wed Dec 4 23:24:40 2019 New Revision: 355406 URL: https://svnweb.freebsd.org/changeset/base/355406 Log: Add some definitions for NFSv4.2 which will be used by subsequent commits. This is a preliminary commit of NFSv4.2 definitions that will be used by subsequent commits which adds NFSv4.2 support to the NFS client and server. There will be a series of these preliminary commits that will prepare for a major commit of the NFSv4.2 client/server changes currently found in subversion under projects/nfsv42/sys. Modified: head/sys/fs/nfs/nfsproto.h Modified: head/sys/fs/nfs/nfsproto.h == --- head/sys/fs/nfs/nfsproto.h Wed Dec 4 22:41:52 2019(r355405) +++ head/sys/fs/nfs/nfsproto.h Wed Dec 4 23:24:40 2019(r355406) @@ -78,6 +78,7 @@ #defineNFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ #defineNFSV4_MINORVERSION 0 /* V4 Minor version */ #defineNFSV41_MINORVERSION 1 /* V4 Minor version */ +#defineNFSV42_MINORVERSION 2 /* V4 Minor version */ #defineNFSV4_CBVERS1 /* V4 CB Version */ #defineNFSV41_CBVERS 4 /* V4.1 CB Version */ #defineNFSV4_SMALLSTR 50 /* Strings small enough for stack */ @@ -214,6 +215,22 @@ #defineNFSERR_RETURNCONFLICT 10086 #defineNFSERR_DELEGREVOKED 10087 +/* NFSv4.2 specific errors. */ +#defineNFSERR_PARTNERNOTSUPP 10088 +#defineNFSERR_PARTNERNOAUTH10089 +#defineNFSERR_UNIONNOTSUPP 10090 +#defineNFSERR_OFFLOADDENIED10091 +#defineNFSERR_WRONGLFS 10092 +#defineNFSERR_BADLABEL 10093 +#defineNFSERR_OFFLOADNOREQS10094 + +/* NFSv4.2 Extended Attribute errors. */ +#defineNFSERR_NOXATTR 10095 +#defineNFSERR_XATTR2BIG10096 + +/* Maximum value of all the NFS error values. */ +#defineNFSERR_MAXERRVALNFSERR_XATTR2BIG + #defineNFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */ #defineNFSERR_DONTREPLY30003 /* Don't process request */ #defineNFSERR_RETVOID 30004 /* Return void, not error */ @@ -364,6 +381,24 @@ */ #defineNFSV41_NPROCS 56 +/* Additional procedures for NFSv4.2. */ +#defineNFSPROC_IOADVISE56 +#defineNFSPROC_ALLOCATE57 +#defineNFSPROC_COPY58 +#defineNFSPROC_SEEK59 +#defineNFSPROC_SEEKDS 60 + +/* and the ones for the optional Extended attribute support (RFC-8276). */ +#defineNFSPROC_GETEXTATTR 61 +#defineNFSPROC_SETEXTATTR 62 +#defineNFSPROC_RMEXTATTR 63 +#defineNFSPROC_LISTEXTATTR 64 + +/* + * Must be defined as one higher than the last NFSv4.2 Proc# above. + */ +#defineNFSV42_NPROCS 65 + #endif /* NFS_V3NPROCS */ /* @@ -593,6 +628,11 @@ #defineNFSACCESS_EXTEND0x08 #defineNFSACCESS_DELETE0x10 #defineNFSACCESS_EXECUTE 0x20 + +/* Additional Extended Attribute access bits RFC-8276. */ +#defineNFSACCESS_XAREAD0x40 +#defineNFSACCESS_XAWRITE 0x80 +#defineNFSACCESS_XALIST0x100 #defineNFSWRITE_UNSTABLE 0 #defineNFSWRITE_DATASYNC 1 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355194 - head/sys/fs/nfs
Author: rmacklem Date: Thu Nov 28 23:34:23 2019 New Revision: 355194 URL: https://svnweb.freebsd.org/changeset/base/355194 Log: Fix two races while handling nfsuserd daemon start/stop. A crash was reported where the nr_client field was NULL during an upcall to the nfsuserd daemon. Since nr_client == NULL only occurs when the nfsuserd daemon is being shut down, it appeared to be caused by a race between doing an upcall and the daemon shutting down. By inspection two races were identified: 1 - The nfsrv_nfsuserd variable is used to indicate whether or not the daemon is running. However it did not handle the intermediate phase where the daemon is starting or stopping. This was fixed by making nfsrv_nfsuserd tri-state and having the functions that are called during start/stop to obey the intermediate state. 2 - nfsrv_nfsuserd was checked to see that the daemon was running at the beginning of an upcall, but nothing prevented the daemon from being shut down while an upcall was still in progress. This race probably caused the crash. The patch fixes this by adding a count of upcalls in progress and having the shut down function delay until this count goes to zero before getting rid of nr_client and related data used by an upcall. Tested by:avg (Panzura QA) Reported by: avg Reviewed by: avg MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D22377 Modified: head/sys/fs/nfs/nfs.h head/sys/fs/nfs/nfs_commonport.c head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfsport.h Modified: head/sys/fs/nfs/nfs.h == --- head/sys/fs/nfs/nfs.h Thu Nov 28 21:50:34 2019(r355193) +++ head/sys/fs/nfs/nfs.h Thu Nov 28 23:34:23 2019(r355194) @@ -797,6 +797,9 @@ struct nfsslot { struct mbuf *nfssl_reply; }; +/* Enumerated type for nfsuserd state. */ +typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state; + #endif /* _KERNEL */ #endif /* _NFS_NFS_H */ Modified: head/sys/fs/nfs/nfs_commonport.c == --- head/sys/fs/nfs/nfs_commonport.cThu Nov 28 21:50:34 2019 (r355193) +++ head/sys/fs/nfs/nfs_commonport.cThu Nov 28 23:34:23 2019 (r355194) @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #include extern int nfscl_ticks; -extern int nfsrv_nfsuserd; +extern nfsuserd_state nfsrv_nfsuserd; extern struct nfssockreq nfsrv_nfsuserdsock; extern void (*nfsd_call_recall)(struct vnode *, int, struct ucred *, struct thread *); @@ -774,7 +774,7 @@ nfscommon_modevent(module_t mod, int type, void *data) break; case MOD_UNLOAD: - if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != 0 || + if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != NOTRUNNING || nfs_numnfscbd != 0) { error = EBUSY; break; Modified: head/sys/fs/nfs/nfs_commonsubs.c == --- head/sys/fs/nfs/nfs_commonsubs.cThu Nov 28 21:50:34 2019 (r355193) +++ head/sys/fs/nfs/nfs_commonsubs.cThu Nov 28 23:34:23 2019 (r355194) @@ -64,7 +64,8 @@ struct timeval nfsboottime; /* Copy boottime once, so int nfscl_ticks; int nfsrv_useacl = 1; struct nfssockreq nfsrv_nfsuserdsock; -int nfsrv_nfsuserd = 0; +nfsuserd_state nfsrv_nfsuserd = NOTRUNNING; +static int nfsrv_userdupcalls = 0; struct nfsreqhead nfsd_reqq; uid_t nfsrv_defaultuid = UID_NOBODY; gid_t nfsrv_defaultgid = GID_NOGROUP; @@ -3522,18 +3523,22 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO int error; NFSLOCKNAMEID(); - if (nfsrv_nfsuserd) { + if (nfsrv_nfsuserd != NOTRUNNING) { NFSUNLOCKNAMEID(); error = EPERM; goto out; } - nfsrv_nfsuserd = 1; - NFSUNLOCKNAMEID(); + nfsrv_nfsuserd = STARTSTOP; /* * Set up the socket record and connect. +* Set nr_client NULL before unlocking, just to ensure that no other +* process/thread/core will use a bogus old value. This could only +* occur if the use of the nameid lock to protect nfsrv_nfsuserd is +* broken. */ rp = _nfsuserdsock; rp->nr_client = NULL; + NFSUNLOCKNAMEID(); rp->nr_sotype = SOCK_DGRAM; rp->nr_soproto = IPPROTO_UDP; rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST); @@ -3569,9 +3574,15 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO rp->nr_vers = RPCNFSUSERD_VERS; if (error == 0) error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); - if (error) { + if (error == 0) { + NFSLOCKNAMEID(); +
svn commit: r355161 - head/sys/rpc/rpcsec_gss
Author: rmacklem Date: Thu Nov 28 02:18:51 2019 New Revision: 355161 URL: https://svnweb.freebsd.org/changeset/base/355161 Log: Change r355157 to make svc_rpc_gss_lifetime_max a static. MFC after:2 weeks Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c == --- head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cThu Nov 28 02:18:19 2019 (r355160) +++ head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cThu Nov 28 02:18:51 2019 (r355161) @@ -173,7 +173,6 @@ struct svc_rpc_gss_cookedcred { #define CLIENT_MAX 1024 u_int svc_rpc_gss_client_max = CLIENT_MAX; u_int svc_rpc_gss_client_hash_size = CLIENT_HASH_SIZE; -u_int svc_rpc_gss_lifetime_max = 0; SYSCTL_NODE(_kern, OID_AUTO, rpc, CTLFLAG_RW, 0, "RPC"); SYSCTL_NODE(_kern_rpc, OID_AUTO, gss, CTLFLAG_RW, 0, "GSS"); @@ -186,6 +185,7 @@ SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, client_hash, CTLF _rpc_gss_client_hash_size, 0, "Size of rpc-gss client hash table"); +static u_int svc_rpc_gss_lifetime_max = 0; SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, lifetime_max, CTLFLAG_RW, _rpc_gss_lifetime_max, 0, "Maximum lifetime (seconds) of rpc-gss clients"); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355157 - head/sys/rpc/rpcsec_gss
Author: rmacklem Date: Thu Nov 28 02:05:31 2019 New Revision: 355157 URL: https://svnweb.freebsd.org/changeset/base/355157 Log: Add a cap on credential lifetime for Kerberized NFS. The kernel RPCSEC_GSS code sets the credential (called a client) lifetime to the lifetime of the Kerberos ticket, which is typically several hours. As such, when a user's credentials change such as being added to a new group, it can take several hours for this change to be recognized by the NFS server. This patch adds a sysctl called kern.rpc.gss.lifetime_max which can be set by a sysadmin to put a cap on the time to expire for the credentials, so that a sysadmin can reduce the timeout. It also fixes a bug, where time_uptime is added twice when GSS_C_INDEFINITE is returned for a lifetime. This has no effect in practice, sine Kerberos never does this. Tested by:p...@lysator.liu.se PR: 242132 Submitted by: p...@lysator.liu.se MFC after:2 weeks Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c Modified: head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c == --- head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cThu Nov 28 00:46:33 2019 (r355156) +++ head/sys/rpc/rpcsec_gss/svc_rpcsec_gss.cThu Nov 28 02:05:31 2019 (r355157) @@ -173,6 +173,7 @@ struct svc_rpc_gss_cookedcred { #define CLIENT_MAX 1024 u_int svc_rpc_gss_client_max = CLIENT_MAX; u_int svc_rpc_gss_client_hash_size = CLIENT_HASH_SIZE; +u_int svc_rpc_gss_lifetime_max = 0; SYSCTL_NODE(_kern, OID_AUTO, rpc, CTLFLAG_RW, 0, "RPC"); SYSCTL_NODE(_kern_rpc, OID_AUTO, gss, CTLFLAG_RW, 0, "GSS"); @@ -185,6 +186,10 @@ SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, client_hash, CTLF _rpc_gss_client_hash_size, 0, "Size of rpc-gss client hash table"); +SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, lifetime_max, CTLFLAG_RW, +_rpc_gss_lifetime_max, 0, +"Maximum lifetime (seconds) of rpc-gss clients"); + static u_int svc_rpc_gss_client_count; SYSCTL_UINT(_kern_rpc_gss, OID_AUTO, client_count, CTLFLAG_RD, _rpc_gss_client_count, 0, @@ -956,8 +961,15 @@ svc_rpc_gss_accept_sec_context(struct svc_rpc_gss_clie * that out). */ if (cred_lifetime == GSS_C_INDEFINITE) - cred_lifetime = time_uptime + 24*60*60; + cred_lifetime = 24*60*60; + /* +* Cap cred_lifetime if sysctl kern.rpc.gss.lifetime_max is set. +*/ + if (svc_rpc_gss_lifetime_max > 0 && cred_lifetime > + svc_rpc_gss_lifetime_max) + cred_lifetime = svc_rpc_gss_lifetime_max; + client->cl_expiration = time_uptime + cred_lifetime; /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r354989 - in head/sys/fs: nfs nfsserver
Author: rmacklem Date: Fri Nov 22 00:22:55 2019 New Revision: 354989 URL: https://svnweb.freebsd.org/changeset/base/354989 Log: Fix the pNFS server's reporting of SpaceUsed (va_bytes). The pNFS server currently reports SpaceUsed (va_bytes) for the metadata file. This in not correct, since the metadata file is always empty and, as such, va_bytes is just the allocation for the empty file. This patch adds va_bytes to the list of attributes acquired from the DS for a file, so that it includes the allocated data size and is updated when the file is written. For files created on a pNFS server before this patch is applied, the va_bytes value is estimated by rounding va_size up to a multiple of BLKDEV_IOSIZE. Once the file is written after this patch has been applied to the metadata server, the va_bytes returned for the file will be correct. This patch only affects a pNFS metadata server. Found during testing of the NFSv4.2 pNFS server for the Allocate operation. (Not yet in head/current.) MFC after:2 weeks Modified: head/sys/fs/nfs/nfsrvstate.h head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfs/nfsrvstate.h == --- head/sys/fs/nfs/nfsrvstate.hThu Nov 21 23:55:43 2019 (r354988) +++ head/sys/fs/nfs/nfsrvstate.hFri Nov 22 00:22:55 2019 (r354989) @@ -355,14 +355,24 @@ struct nfsdevice { }; /* - * This structure holds the va_size, va_filerev, va_atime and va_mtime for the - * DS file and is stored in the metadata file's extended attribute pnfsd.dsattr. + * This structure holds the va_size, va_filerev, va_atime, va_mtime and + * va_bytes for the DS file and is stored in the metadata file's extended + * attribute pnfsd.dsattr. + * opnfsdsattr was missing the va_bytes field and, as such, it was updated. */ +struct opnfsdsattr { + uint64_tdsa_filerev; + uint64_tdsa_size; + struct timespec dsa_atime; + struct timespec dsa_mtime; +}; + struct pnfsdsattr { uint64_tdsa_filerev; uint64_tdsa_size; struct timespec dsa_atime; struct timespec dsa_mtime; + uint64_tdsa_bytes; }; /* Modified: head/sys/fs/nfsserver/nfs_nfsdport.c == --- head/sys/fs/nfsserver/nfs_nfsdport.cThu Nov 21 23:55:43 2019 (r354988) +++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Nov 22 00:22:55 2019 (r354989) @@ -277,7 +277,8 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap } /* -* Acquire the Change, Size and TimeModify attributes, as required. +* Acquire the Change, Size, TimeAccess, TimeModify and SpaceUsed +* attributes, as required. * This needs to be done for regular files if: * - non-NFSv4 RPCs or * - when attrbitp == NULL or @@ -292,7 +293,8 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_CHANGE) || NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SIZE) || NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEACCESS) || - NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFY))) { + NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFY) || + NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SPACEUSED))) { error = nfsrv_proxyds(vp, 0, 0, nd->nd_cred, p, NFSPROC_GETATTR, NULL, NULL, NULL, , NULL); if (error == 0) @@ -312,6 +314,7 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap nvap->na_mtime = na.na_mtime; nvap->na_filerev = na.na_filerev; nvap->na_size = na.na_size; + nvap->na_bytes = na.na_bytes; } NFSD_DEBUG(4, "nfsvno_getattr: gotattr=%d err=%d chg=%ju\n", gotattr, error, (uintmax_t)na.na_filerev); @@ -3881,6 +3884,7 @@ nfsrv_dscreate(struct vnode *dvp, struct vattr *vap, s dsa->dsa_size = va.va_size; dsa->dsa_atime = va.va_atime; dsa->dsa_mtime = va.va_mtime; + dsa->dsa_bytes = va.va_bytes; } } if (error == 0) { @@ -4405,6 +4409,7 @@ nfsrv_proxyds(struct vnode *vp, off_t off, int cnt, st struct vnode *dvp[NFSDEV_MAXMIRRORS]; struct nfsdevice *ds; struct pnfsdsattr dsattr; + struct opnfsdsattr odsattr; char *buf; int buflen, error, failpos, i, mirrorcnt, origmircnt, trycnt; @@ -4429,15 +4434,31 @@ nfsrv_proxyds(struct vnode *vp, off_t off, int cnt, st error = vn_extattr_get(vp, IO_NODELOCKED, EXTATTR_NAMESPACE_SYSTEM, "pnfsd.dsattr", , buf,
svn commit: r354576 - head/share/man/man9
Author: rmacklem Date: Sun Nov 10 01:21:10 2019 New Revision: 354576 URL: https://svnweb.freebsd.org/changeset/base/354576 Log: Update the VOP_COPY_FILE_RANGE man page to reflect the semantic change made by r354574. This is a content change. Modified: head/share/man/man9/VOP_COPY_FILE_RANGE.9 Modified: head/share/man/man9/VOP_COPY_FILE_RANGE.9 == --- head/share/man/man9/VOP_COPY_FILE_RANGE.9 Sun Nov 10 01:13:41 2019 (r354575) +++ head/share/man/man9/VOP_COPY_FILE_RANGE.9 Sun Nov 10 01:21:10 2019 (r354576) @@ -25,12 +25,13 @@ .\" .\" $FreeBSD$ .\" -.Dd November 8, 2019 +.Dd November 9, 2019 .Dt VOP_COPY_FILE_RANGE 9 .Os .Sh NAME .Nm VOP_COPY_FILE_RANGE -.Nd copy a byte range from one regular file to another within a file system +.Nd copy a byte range from one file to another or within one file +in a single file system .Sh SYNOPSIS .In sys/param.h .In sys/vnode.h @@ -46,8 +47,17 @@ .Fa "struct ucred *outcred" .Fa "struct thread *fsize_td" .Sh DESCRIPTION -This entry point copies a byte range from one regular file to another within a -file system. +This entry point copies a byte range from one regular file to another +or within one file in a single file system. +.Fa invp +and +.Fa outvp +can refer to the same file. +For this case, the byte ranges defined by +.Fa *inoff , +.Fa *outoff and +.Fa *len +will not overlap. .Pp The arguments are: .Bl -tag -width ioflag ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"