Deleted Added
full compact
nfs_nfsdserv.c (281628) nfs_nfsdserv.c (283635)
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdserv.c 281628 2015-04-16 22:35:15Z rmacklem $");
35__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdserv.c 283635 2015-05-27 22:00:05Z rmacklem $");
36
37/*
38 * nfs version 2, 3 and 4 server calls to vnode ops
39 * - these routines generally have 3 phases
40 * 1 - break down and validate rpc request in mbuf list
41 * 2 - do the vnode ops for the request, usually by calling a nfsvno_XXX()
42 * function in nfsd_port.c
43 * 3 - build the rpc reply in an mbuf list

--- 4 unchanged lines hidden (view full) ---

48#include <fs/nfs/nfsport.h>
49
50/* Global vars */
51extern u_int32_t newnfs_false, newnfs_true;
52extern enum vtype nv34tov_type[8];
53extern struct timeval nfsboottime;
54extern int nfs_rootfhset;
55extern int nfsrv_enable_crossmntpt;
36
37/*
38 * nfs version 2, 3 and 4 server calls to vnode ops
39 * - these routines generally have 3 phases
40 * 1 - break down and validate rpc request in mbuf list
41 * 2 - do the vnode ops for the request, usually by calling a nfsvno_XXX()
42 * function in nfsd_port.c
43 * 3 - build the rpc reply in an mbuf list

--- 4 unchanged lines hidden (view full) ---

48#include <fs/nfs/nfsport.h>
49
50/* Global vars */
51extern u_int32_t newnfs_false, newnfs_true;
52extern enum vtype nv34tov_type[8];
53extern struct timeval nfsboottime;
54extern int nfs_rootfhset;
55extern int nfsrv_enable_crossmntpt;
56extern int nfsrv_statehashsize;
56#endif /* !APPLEKEXT */
57
58static int nfs_async = 0;
59SYSCTL_DECL(_vfs_nfsd);
60SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0,
61 "Tell client that writes were synced even though they were not");
62
63/*

--- 3399 unchanged lines hidden (view full) ---

3463 i = fxdr_unsigned(int, *tl);
3464 if (i > NFSV4_OPAQUELIMIT || i <= 0) {
3465 nd->nd_repstat = NFSERR_BADXDR;
3466 goto nfsmout;
3467 }
3468 idlen = i;
3469 if (nd->nd_flag & ND_GSS)
3470 i += nd->nd_princlen;
57#endif /* !APPLEKEXT */
58
59static int nfs_async = 0;
60SYSCTL_DECL(_vfs_nfsd);
61SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0,
62 "Tell client that writes were synced even though they were not");
63
64/*

--- 3399 unchanged lines hidden (view full) ---

3464 i = fxdr_unsigned(int, *tl);
3465 if (i > NFSV4_OPAQUELIMIT || i <= 0) {
3466 nd->nd_repstat = NFSERR_BADXDR;
3467 goto nfsmout;
3468 }
3469 idlen = i;
3470 if (nd->nd_flag & ND_GSS)
3471 i += nd->nd_princlen;
3471 MALLOC(clp, struct nfsclient *, sizeof (struct nfsclient) + i,
3472 M_NFSDCLIENT, M_WAITOK);
3473 NFSBZERO((caddr_t)clp, sizeof (struct nfsclient) + i);
3472 clp = malloc(sizeof(struct nfsclient) + i, M_NFSDCLIENT, M_WAITOK |
3473 M_ZERO);
3474 clp->lc_stateid = malloc(sizeof(struct nfsstatehead) *
3475 nfsrv_statehashsize, M_NFSDCLIENT, M_WAITOK);
3474 NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
3475 NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
3476 NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
3477 clp->lc_req.nr_cred = NULL;
3478 NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
3479 clp->lc_idlen = idlen;
3480 error = nfsrv_mtostr(nd, clp->lc_id, idlen);
3481 if (error)

--- 43 unchanged lines hidden (view full) ---

3525 sprintf(addrbuf, "%d.%d.%d.%d.%d.%d", ucp[0] & 0xff,
3526 ucp[1] & 0xff, ucp[2] & 0xff, ucp[3] & 0xff,
3527 ucp2[0] & 0xff, ucp2[1] & 0xff);
3528 (void) nfsm_strtom(nd, addrbuf, strlen(addrbuf));
3529 }
3530 if (clp) {
3531 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3532 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3476 NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
3477 NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
3478 NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
3479 clp->lc_req.nr_cred = NULL;
3480 NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
3481 clp->lc_idlen = idlen;
3482 error = nfsrv_mtostr(nd, clp->lc_id, idlen);
3483 if (error)

--- 43 unchanged lines hidden (view full) ---

3527 sprintf(addrbuf, "%d.%d.%d.%d.%d.%d", ucp[0] & 0xff,
3528 ucp[1] & 0xff, ucp[2] & 0xff, ucp[3] & 0xff,
3529 ucp2[0] & 0xff, ucp2[1] & 0xff);
3530 (void) nfsm_strtom(nd, addrbuf, strlen(addrbuf));
3531 }
3532 if (clp) {
3533 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3534 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3533 free((caddr_t)clp, M_NFSDCLIENT);
3535 free(clp->lc_stateid, M_NFSDCLIENT);
3536 free(clp, M_NFSDCLIENT);
3534 }
3535 if (!nd->nd_repstat) {
3536 NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_HYPER);
3537 *tl++ = clientid.lval[0];
3538 *tl++ = clientid.lval[1];
3539 *tl++ = confirm.lval[0];
3540 *tl = confirm.lval[1];
3541 }
3542
3543out:
3544 NFSEXITCODE2(0, nd);
3545 return (0);
3546nfsmout:
3547 if (clp) {
3548 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3549 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3537 }
3538 if (!nd->nd_repstat) {
3539 NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_HYPER);
3540 *tl++ = clientid.lval[0];
3541 *tl++ = clientid.lval[1];
3542 *tl++ = confirm.lval[0];
3543 *tl = confirm.lval[1];
3544 }
3545
3546out:
3547 NFSEXITCODE2(0, nd);
3548 return (0);
3549nfsmout:
3550 if (clp) {
3551 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3552 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3550 free((caddr_t)clp, M_NFSDCLIENT);
3553 free(clp->lc_stateid, M_NFSDCLIENT);
3554 free(clp, M_NFSDCLIENT);
3551 }
3552 NFSEXITCODE2(error, nd);
3553 return (error);
3554}
3555
3556/*
3557 * nfsv4 set client id confirm service
3558 */

--- 174 unchanged lines hidden (view full) ---

3733 i = fxdr_unsigned(int, *tl);
3734 if (i > NFSV4_OPAQUELIMIT || i <= 0) {
3735 nd->nd_repstat = NFSERR_BADXDR;
3736 goto nfsmout;
3737 }
3738 idlen = i;
3739 if (nd->nd_flag & ND_GSS)
3740 i += nd->nd_princlen;
3555 }
3556 NFSEXITCODE2(error, nd);
3557 return (error);
3558}
3559
3560/*
3561 * nfsv4 set client id confirm service
3562 */

--- 174 unchanged lines hidden (view full) ---

3737 i = fxdr_unsigned(int, *tl);
3738 if (i > NFSV4_OPAQUELIMIT || i <= 0) {
3739 nd->nd_repstat = NFSERR_BADXDR;
3740 goto nfsmout;
3741 }
3742 idlen = i;
3743 if (nd->nd_flag & ND_GSS)
3744 i += nd->nd_princlen;
3741 clp = (struct nfsclient *)malloc(sizeof(struct nfsclient) + i,
3742 M_NFSDCLIENT, M_WAITOK | M_ZERO);
3745 clp = malloc(sizeof(struct nfsclient) + i, M_NFSDCLIENT, M_WAITOK |
3746 M_ZERO);
3747 clp->lc_stateid = malloc(sizeof(struct nfsstatehead) *
3748 nfsrv_statehashsize, M_NFSDCLIENT, M_WAITOK);
3743 NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
3744 NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
3745 NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
3746 clp->lc_req.nr_cred = NULL;
3747 NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
3748 clp->lc_idlen = idlen;
3749 error = nfsrv_mtostr(nd, clp->lc_id, idlen);
3750 if (error != 0)

--- 40 unchanged lines hidden (view full) ---

3791 * linked into the client list and clp should no longer be used
3792 * here. When an error is returned, it has not been linked in,
3793 * so it should be free'd.
3794 */
3795 nd->nd_repstat = nfsrv_setclient(nd, &clp, &clientid, &confirm, p);
3796 if (clp != NULL) {
3797 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3798 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3749 NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
3750 NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
3751 NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
3752 clp->lc_req.nr_cred = NULL;
3753 NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
3754 clp->lc_idlen = idlen;
3755 error = nfsrv_mtostr(nd, clp->lc_id, idlen);
3756 if (error != 0)

--- 40 unchanged lines hidden (view full) ---

3797 * linked into the client list and clp should no longer be used
3798 * here. When an error is returned, it has not been linked in,
3799 * so it should be free'd.
3800 */
3801 nd->nd_repstat = nfsrv_setclient(nd, &clp, &clientid, &confirm, p);
3802 if (clp != NULL) {
3803 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3804 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3805 free(clp->lc_stateid, M_NFSDCLIENT);
3799 free(clp, M_NFSDCLIENT);
3800 }
3801 if (nd->nd_repstat == 0) {
3802 if (confirm.lval[1] != 0)
3803 v41flags |= NFSV4EXCH_CONFIRMEDR;
3804 NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + 3 * NFSX_UNSIGNED);
3805 *tl++ = clientid.lval[0]; /* ClientID */
3806 *tl++ = clientid.lval[1];

--- 16 unchanged lines hidden (view full) ---

3823 txdr_nfsv4time(&verstime, tl);
3824 }
3825 NFSEXITCODE2(0, nd);
3826 return (0);
3827nfsmout:
3828 if (clp != NULL) {
3829 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3830 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3806 free(clp, M_NFSDCLIENT);
3807 }
3808 if (nd->nd_repstat == 0) {
3809 if (confirm.lval[1] != 0)
3810 v41flags |= NFSV4EXCH_CONFIRMEDR;
3811 NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + 3 * NFSX_UNSIGNED);
3812 *tl++ = clientid.lval[0]; /* ClientID */
3813 *tl++ = clientid.lval[1];

--- 16 unchanged lines hidden (view full) ---

3830 txdr_nfsv4time(&verstime, tl);
3831 }
3832 NFSEXITCODE2(0, nd);
3833 return (0);
3834nfsmout:
3835 if (clp != NULL) {
3836 NFSSOCKADDRFREE(clp->lc_req.nr_nam);
3837 NFSFREEMUTEX(&clp->lc_req.nr_mtx);
3838 free(clp->lc_stateid, M_NFSDCLIENT);
3831 free(clp, M_NFSDCLIENT);
3832 }
3833 NFSEXITCODE2(error, nd);
3834 return (error);
3835}
3836
3837/*
3838 * nfsv4 create session service

--- 252 unchanged lines hidden ---
3839 free(clp, M_NFSDCLIENT);
3840 }
3841 NFSEXITCODE2(error, nd);
3842 return (error);
3843}
3844
3845/*
3846 * nfsv4 create session service

--- 252 unchanged lines hidden ---