View | Details | Raw Unified | Return to bug 260011 | Differences between
and this patch

Collapse All | Expand All

(-)sys/fs/nfsclient/nfs_clrpcops.c (-109 / +98 lines)
Lines 239-245 nfsrpc_null(vnode_t vp, struct ucred *cred, NFSPROC_T Link Here
239
	int error;
239
	int error;
240
	struct nfsrv_descript nfsd, *nd = &nfsd;
240
	struct nfsrv_descript nfsd, *nd = &nfsd;
241
241
242
	NFSCL_REQSTART(nd, NFSPROC_NULL, vp);
242
	NFSCL_REQSTART(nd, NFSPROC_NULL, vp, NULL);
243
	error = nfscl_request(nd, vp, p, cred, NULL);
243
	error = nfscl_request(nd, vp, p, cred, NULL);
244
	if (nd->nd_repstat && !error)
244
	if (nd->nd_repstat && !error)
245
		error = nd->nd_repstat;
245
		error = nd->nd_repstat;
Lines 308-314 nfsrpc_accessrpc(vnode_t vp, u_int32_t mode, struct uc Link Here
308
308
309
	*attrflagp = 0;
309
	*attrflagp = 0;
310
	supported = mode;
310
	supported = mode;
311
	NFSCL_REQSTART(nd, NFSPROC_ACCESS, vp);
311
	NFSCL_REQSTART(nd, NFSPROC_ACCESS, vp, cred);
312
	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
312
	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
313
	*tl = txdr_unsigned(mode);
313
	*tl = txdr_unsigned(mode);
314
	if (nd->nd_flag & ND_NFSV4) {
314
	if (nd->nd_flag & ND_NFSV4) {
Lines 512-518 nfsrpc_openrpc(struct nfsmount *nmp, vnode_t vp, u_int Link Here
512
512
513
	dp = *dpp;
513
	dp = *dpp;
514
	*dpp = NULL;
514
	*dpp = NULL;
515
	nfscl_reqstart(nd, NFSPROC_OPEN, nmp, nfhp, fhlen, NULL, NULL, 0, 0);
515
	nfscl_reqstart(nd, NFSPROC_OPEN, nmp, nfhp, fhlen, NULL, NULL, 0, 0,
516
	    cred);
516
	NFSM_BUILD(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
517
	NFSM_BUILD(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
517
	*tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid);
518
	*tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid);
518
	*tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH);
519
	*tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH);
Lines 705-711 nfsrpc_opendowngrade(vnode_t vp, u_int32_t mode, struc Link Here
705
	struct nfsrv_descript nfsd, *nd = &nfsd;
706
	struct nfsrv_descript nfsd, *nd = &nfsd;
706
	int error;
707
	int error;
707
708
708
	NFSCL_REQSTART(nd, NFSPROC_OPENDOWNGRADE, vp);
709
	NFSCL_REQSTART(nd, NFSPROC_OPENDOWNGRADE, vp, cred);
709
	NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID + 3 * NFSX_UNSIGNED);
710
	NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID + 3 * NFSX_UNSIGNED);
710
	if (NFSHASNFSV4N(VFSTONFS(vp->v_mount)))
711
	if (NFSHASNFSV4N(VFSTONFS(vp->v_mount)))
711
		*tl++ = 0;
712
		*tl++ = 0;
Lines 870-876 nfsrpc_closerpc(struct nfsrv_descript *nd, struct nfsm Link Here
870
	int error;
871
	int error;
871
872
872
	nfscl_reqstart(nd, NFSPROC_CLOSE, nmp, op->nfso_fh,
873
	nfscl_reqstart(nd, NFSPROC_CLOSE, nmp, op->nfso_fh,
873
	    op->nfso_fhlen, NULL, NULL, 0, 0);
874
	    op->nfso_fhlen, NULL, NULL, 0, 0, cred);
874
	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_STATEID);
875
	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_STATEID);
875
	if (NFSHASNFSV4N(nmp)) {
876
	if (NFSHASNFSV4N(nmp)) {
876
		*tl++ = 0;
877
		*tl++ = 0;
Lines 916-922 nfsrpc_openconfirm(vnode_t vp, u_int8_t *nfhp, int fhl Link Here
916
	if (NFSHASNFSV4N(nmp))
917
	if (NFSHASNFSV4N(nmp))
917
		return (0);		/* No confirmation for NFSv4.1. */
918
		return (0);		/* No confirmation for NFSv4.1. */
918
	nfscl_reqstart(nd, NFSPROC_OPENCONFIRM, nmp, nfhp, fhlen, NULL, NULL,
919
	nfscl_reqstart(nd, NFSPROC_OPENCONFIRM, nmp, nfhp, fhlen, NULL, NULL,
919
	    0, 0);
920
	    0, 0, NULL);
920
	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_STATEID);
921
	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_STATEID);
921
	*tl++ = op->nfso_stateid.seqid;
922
	*tl++ = op->nfso_stateid.seqid;
922
	*tl++ = op->nfso_stateid.other[0];
923
	*tl++ = op->nfso_stateid.other[0];
Lines 1060-1067 nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli Link Here
1060
			 * in-progress RPCs.
1061
			 * in-progress RPCs.
1061
			 */
1062
			 */
1062
			tsep = NULL;
1063
			tsep = NULL;
1063
			if (TAILQ_FIRST(&nmp->nm_sess) != NULL)
1064
			if (TAILQ_FIRST(&nmp->nm_sess) != NULL) {
1064
				tsep = NFSMNT_MDSSESSION(nmp);
1065
				tsep = NFSMNT_MDSSESSION(nmp);
1066
				if (tsep->nfsess_defunct == 0)
1067
					printf("nfsrpc_setclient: "
1068
					    "nfsess_defunct not set\n");
1069
			}
1065
			TAILQ_INSERT_HEAD(&nmp->nm_sess, dsp,
1070
			TAILQ_INSERT_HEAD(&nmp->nm_sess, dsp,
1066
			    nfsclds_list);
1071
			    nfsclds_list);
1067
			/*
1072
			/*
Lines 1103-1109 nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli Link Here
1103
	tsep = NFSMNT_MDSSESSION(nmp);
1108
	tsep = NFSMNT_MDSSESSION(nmp);
1104
	NFSUNLOCKMNT(nmp);
1109
	NFSUNLOCKMNT(nmp);
1105
1110
1106
	nfscl_reqstart(nd, NFSPROC_SETCLIENTID, nmp, NULL, 0, NULL, NULL, 0, 0);
1111
	nfscl_reqstart(nd, NFSPROC_SETCLIENTID, nmp, NULL, 0, NULL, NULL, 0, 0,
1112
	    NULL);
1107
	NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
1113
	NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
1108
	*tl++ = txdr_unsigned(nfsboottime.tv_sec);
1114
	*tl++ = txdr_unsigned(nfsboottime.tv_sec);
1109
	*tl = txdr_unsigned(clp->nfsc_rev);
1115
	*tl = txdr_unsigned(clp->nfsc_rev);
Lines 1173-1179 nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli Link Here
1173
	     * and confirm it.
1179
	     * and confirm it.
1174
	     */
1180
	     */
1175
	    nfscl_reqstart(nd, NFSPROC_SETCLIENTIDCFRM, nmp, NULL, 0, NULL,
1181
	    nfscl_reqstart(nd, NFSPROC_SETCLIENTIDCFRM, nmp, NULL, 0, NULL,
1176
		NULL, 0, 0);
1182
		NULL, 0, 0, NULL);
1177
	    NFSM_BUILD(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
1183
	    NFSM_BUILD(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
1178
	    *tl++ = tsep->nfsess_clientid.lval[0];
1184
	    *tl++ = tsep->nfsess_clientid.lval[0];
1179
	    *tl++ = tsep->nfsess_clientid.lval[1];
1185
	    *tl++ = tsep->nfsess_clientid.lval[1];
Lines 1204-1210 nfsrpc_getattr(vnode_t vp, struct ucred *cred, NFSPROC Link Here
1204
	int error;
1210
	int error;
1205
	nfsattrbit_t attrbits;
1211
	nfsattrbit_t attrbits;
1206
1212
1207
	NFSCL_REQSTART(nd, NFSPROC_GETATTR, vp);
1213
	NFSCL_REQSTART(nd, NFSPROC_GETATTR, vp, cred);
1208
	if (nd->nd_flag & ND_NFSV4) {
1214
	if (nd->nd_flag & ND_NFSV4) {
1209
		NFSGETATTR_ATTRBIT(&attrbits);
1215
		NFSGETATTR_ATTRBIT(&attrbits);
1210
		(void) nfsrv_putattrbit(nd, &attrbits);
1216
		(void) nfsrv_putattrbit(nd, &attrbits);
Lines 1232-1238 nfsrpc_getattrnovp(struct nfsmount *nmp, u_int8_t *fhp Link Here
1232
	int error, vers = NFS_VER2;
1238
	int error, vers = NFS_VER2;
1233
	nfsattrbit_t attrbits;
1239
	nfsattrbit_t attrbits;
1234
1240
1235
	nfscl_reqstart(nd, NFSPROC_GETATTR, nmp, fhp, fhlen, NULL, NULL, 0, 0);
1241
	nfscl_reqstart(nd, NFSPROC_GETATTR, nmp, fhp, fhlen, NULL, NULL, 0, 0,
1242
	    cred);
1236
	if (nd->nd_flag & ND_NFSV4) {
1243
	if (nd->nd_flag & ND_NFSV4) {
1237
		vers = NFS_VER4;
1244
		vers = NFS_VER4;
1238
		NFSGETATTR_ATTRBIT(&attrbits);
1245
		NFSGETATTR_ATTRBIT(&attrbits);
Lines 1358-1364 nfsrpc_setattrrpc(vnode_t vp, struct vattr *vap, Link Here
1358
	nfsattrbit_t attrbits;
1365
	nfsattrbit_t attrbits;
1359
1366
1360
	*attrflagp = 0;
1367
	*attrflagp = 0;
1361
	NFSCL_REQSTART(nd, NFSPROC_SETATTR, vp);
1368
	NFSCL_REQSTART(nd, NFSPROC_SETATTR, vp, cred);
1362
	if (nd->nd_flag & ND_NFSV4)
1369
	if (nd->nd_flag & ND_NFSV4)
1363
		nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
1370
		nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
1364
	vap->va_type = vnode_vtype(vp);
1371
	vap->va_type = vnode_vtype(vp);
Lines 1426-1434 nfsrpc_lookup(vnode_t dvp, char *name, int len, struct Link Here
1426
	if (NFSHASNFSV4(nmp) && len == 2 &&
1433
	if (NFSHASNFSV4(nmp) && len == 2 &&
1427
		name[0] == '.' && name[1] == '.') {
1434
		name[0] == '.' && name[1] == '.') {
1428
		lookupp = 1;
1435
		lookupp = 1;
1429
		NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, dvp);
1436
		NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, dvp, cred);
1430
	} else {
1437
	} else {
1431
		NFSCL_REQSTART(nd, NFSPROC_LOOKUP, dvp);
1438
		NFSCL_REQSTART(nd, NFSPROC_LOOKUP, dvp, cred);
1432
		(void) nfsm_strtom(nd, name, len);
1439
		(void) nfsm_strtom(nd, name, len);
1433
	}
1440
	}
1434
	if (nd->nd_flag & ND_NFSV4) {
1441
	if (nd->nd_flag & ND_NFSV4) {
Lines 1504-1510 nfsrpc_readlink(vnode_t vp, struct uio *uiop, struct u Link Here
1504
	int error, len, cangetattr = 1;
1511
	int error, len, cangetattr = 1;
1505
1512
1506
	*attrflagp = 0;
1513
	*attrflagp = 0;
1507
	NFSCL_REQSTART(nd, NFSPROC_READLINK, vp);
1514
	NFSCL_REQSTART(nd, NFSPROC_READLINK, vp, cred);
1508
	if (nd->nd_flag & ND_NFSV4) {
1515
	if (nd->nd_flag & ND_NFSV4) {
1509
		/*
1516
		/*
1510
		 * And do a Getattr op.
1517
		 * And do a Getattr op.
Lines 1640-1646 nfsrpc_readrpc(vnode_t vp, struct uio *uiop, struct uc Link Here
1640
	while (tsiz > 0) {
1647
	while (tsiz > 0) {
1641
		*attrflagp = 0;
1648
		*attrflagp = 0;
1642
		len = (tsiz > rsize) ? rsize : tsiz;
1649
		len = (tsiz > rsize) ? rsize : tsiz;
1643
		NFSCL_REQSTART(nd, NFSPROC_READ, vp);
1650
		NFSCL_REQSTART(nd, NFSPROC_READ, vp, cred);
1644
		if (nd->nd_flag & ND_NFSV4)
1651
		if (nd->nd_flag & ND_NFSV4)
1645
			nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
1652
			nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
1646
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED * 3);
1653
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED * 3);
Lines 1818-1824 nfsrpc_writerpc(vnode_t vp, struct uio *uiop, int *iom Link Here
1818
	while (tsiz > 0) {
1825
	while (tsiz > 0) {
1819
		*attrflagp = 0;
1826
		*attrflagp = 0;
1820
		len = (tsiz > wsize) ? wsize : tsiz;
1827
		len = (tsiz > wsize) ? wsize : tsiz;
1821
		NFSCL_REQSTART(nd, NFSPROC_WRITE, vp);
1828
		NFSCL_REQSTART(nd, NFSPROC_WRITE, vp, cred);
1822
		if (nd->nd_flag & ND_NFSV4) {
1829
		if (nd->nd_flag & ND_NFSV4) {
1823
			nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
1830
			nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
1824
			NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER+2*NFSX_UNSIGNED);
1831
			NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER+2*NFSX_UNSIGNED);
Lines 1988-1994 nfsrpc_mknod(vnode_t dvp, char *name, int namelen, str Link Here
1988
	*dattrflagp = 0;
1995
	*dattrflagp = 0;
1989
	if (namelen > NFS_MAXNAMLEN)
1996
	if (namelen > NFS_MAXNAMLEN)
1990
		return (ENAMETOOLONG);
1997
		return (ENAMETOOLONG);
1991
	NFSCL_REQSTART(nd, NFSPROC_MKNOD, dvp);
1998
	NFSCL_REQSTART(nd, NFSPROC_MKNOD, dvp, cred);
1992
	if (nd->nd_flag & ND_NFSV4) {
1999
	if (nd->nd_flag & ND_NFSV4) {
1993
		if (vtyp == VBLK || vtyp == VCHR) {
2000
		if (vtyp == VBLK || vtyp == VCHR) {
1994
			NFSM_BUILD(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
2001
			NFSM_BUILD(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
Lines 2138-2144 nfsrpc_createv23(vnode_t dvp, char *name, int namelen, Link Here
2138
	*dattrflagp = 0;
2145
	*dattrflagp = 0;
2139
	if (namelen > NFS_MAXNAMLEN)
2146
	if (namelen > NFS_MAXNAMLEN)
2140
		return (ENAMETOOLONG);
2147
		return (ENAMETOOLONG);
2141
	NFSCL_REQSTART(nd, NFSPROC_CREATE, dvp);
2148
	NFSCL_REQSTART(nd, NFSPROC_CREATE, dvp, cred);
2142
	(void) nfsm_strtom(nd, name, namelen);
2149
	(void) nfsm_strtom(nd, name, namelen);
2143
	if (nd->nd_flag & ND_NFSV3) {
2150
	if (nd->nd_flag & ND_NFSV3) {
2144
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2151
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
Lines 2200-2206 nfsrpc_createv4(vnode_t dvp, char *name, int namelen, Link Here
2200
	*dattrflagp = 0;
2207
	*dattrflagp = 0;
2201
	if (namelen > NFS_MAXNAMLEN)
2208
	if (namelen > NFS_MAXNAMLEN)
2202
		return (ENAMETOOLONG);
2209
		return (ENAMETOOLONG);
2203
	NFSCL_REQSTART(nd, NFSPROC_CREATE, dvp);
2210
	NFSCL_REQSTART(nd, NFSPROC_CREATE, dvp, cred);
2204
	/*
2211
	/*
2205
	 * For V4, this is actually an Open op.
2212
	 * For V4, this is actually an Open op.
2206
	 */
2213
	 */
Lines 2441-2447 tryagain: Link Here
2441
	if (NFSHASNFSV4(nmp) && ret == 0) {
2448
	if (NFSHASNFSV4(nmp) && ret == 0) {
2442
		ret = nfscl_removedeleg(vp, p, &dstateid);
2449
		ret = nfscl_removedeleg(vp, p, &dstateid);
2443
		if (ret == 1) {
2450
		if (ret == 1) {
2444
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGREMOVE, vp);
2451
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGREMOVE, vp, cred);
2445
			NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID +
2452
			NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID +
2446
			    NFSX_UNSIGNED);
2453
			    NFSX_UNSIGNED);
2447
			if (NFSHASNFSV4N(nmp))
2454
			if (NFSHASNFSV4N(nmp))
Lines 2462-2468 tryagain: Link Here
2462
		ret = 0;
2469
		ret = 0;
2463
	}
2470
	}
2464
	if (ret == 0)
2471
	if (ret == 0)
2465
		NFSCL_REQSTART(nd, NFSPROC_REMOVE, dvp);
2472
		NFSCL_REQSTART(nd, NFSPROC_REMOVE, dvp, cred);
2466
	(void) nfsm_strtom(nd, name, namelen);
2473
	(void) nfsm_strtom(nd, name, namelen);
2467
	error = nfscl_request(nd, dvp, p, cred, dstuff);
2474
	error = nfscl_request(nd, dvp, p, cred, dstuff);
2468
	if (error)
2475
	if (error)
Lines 2522-2532 tryagain: Link Here
2522
		ret = nfscl_renamedeleg(fvp, &fdstateid, &gotfd, tvp,
2529
		ret = nfscl_renamedeleg(fvp, &fdstateid, &gotfd, tvp,
2523
		    &tdstateid, &gottd, p);
2530
		    &tdstateid, &gottd, p);
2524
		if (gotfd && gottd) {
2531
		if (gotfd && gottd) {
2525
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGRENAME2, fvp);
2532
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGRENAME2, fvp, cred);
2526
		} else if (gotfd) {
2533
		} else if (gotfd) {
2527
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGRENAME1, fvp);
2534
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGRENAME1, fvp, cred);
2528
		} else if (gottd) {
2535
		} else if (gottd) {
2529
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGRENAME1, tvp);
2536
			NFSCL_REQSTART(nd, NFSPROC_RETDELEGRENAME1, tvp, cred);
2530
		}
2537
		}
2531
		if (gotfd) {
2538
		if (gotfd) {
2532
			NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID);
2539
			NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID);
Lines 2570-2576 tryagain: Link Here
2570
		ret = 0;
2577
		ret = 0;
2571
	}
2578
	}
2572
	if (ret == 0)
2579
	if (ret == 0)
2573
		NFSCL_REQSTART(nd, NFSPROC_RENAME, fdvp);
2580
		NFSCL_REQSTART(nd, NFSPROC_RENAME, fdvp, cred);
2574
	if (nd->nd_flag & ND_NFSV4) {
2581
	if (nd->nd_flag & ND_NFSV4) {
2575
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2582
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2576
		*tl = txdr_unsigned(NFSV4OP_GETATTR);
2583
		*tl = txdr_unsigned(NFSV4OP_GETATTR);
Lines 2670-2676 nfsrpc_link(vnode_t dvp, vnode_t vp, char *name, int n Link Here
2670
	*dattrflagp = 0;
2677
	*dattrflagp = 0;
2671
	if (namelen > NFS_MAXNAMLEN)
2678
	if (namelen > NFS_MAXNAMLEN)
2672
		return (ENAMETOOLONG);
2679
		return (ENAMETOOLONG);
2673
	NFSCL_REQSTART(nd, NFSPROC_LINK, vp);
2680
	NFSCL_REQSTART(nd, NFSPROC_LINK, vp, cred);
2674
	if (nd->nd_flag & ND_NFSV4) {
2681
	if (nd->nd_flag & ND_NFSV4) {
2675
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2682
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2676
		*tl = txdr_unsigned(NFSV4OP_PUTFH);
2683
		*tl = txdr_unsigned(NFSV4OP_PUTFH);
Lines 2737-2743 nfsrpc_symlink(vnode_t dvp, char *name, int namelen, c Link Here
2737
	slen = strlen(target);
2744
	slen = strlen(target);
2738
	if (slen > NFS_MAXPATHLEN || namelen > NFS_MAXNAMLEN)
2745
	if (slen > NFS_MAXPATHLEN || namelen > NFS_MAXNAMLEN)
2739
		return (ENAMETOOLONG);
2746
		return (ENAMETOOLONG);
2740
	NFSCL_REQSTART(nd, NFSPROC_SYMLINK, dvp);
2747
	NFSCL_REQSTART(nd, NFSPROC_SYMLINK, dvp, cred);
2741
	if (nd->nd_flag & ND_NFSV4) {
2748
	if (nd->nd_flag & ND_NFSV4) {
2742
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2749
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2743
		*tl = txdr_unsigned(NFLNK);
2750
		*tl = txdr_unsigned(NFLNK);
Lines 2800-2806 nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, str Link Here
2800
	fhp = VTONFS(dvp)->n_fhp;
2807
	fhp = VTONFS(dvp)->n_fhp;
2801
	if (namelen > NFS_MAXNAMLEN)
2808
	if (namelen > NFS_MAXNAMLEN)
2802
		return (ENAMETOOLONG);
2809
		return (ENAMETOOLONG);
2803
	NFSCL_REQSTART(nd, NFSPROC_MKDIR, dvp);
2810
	NFSCL_REQSTART(nd, NFSPROC_MKDIR, dvp, cred);
2804
	if (nd->nd_flag & ND_NFSV4) {
2811
	if (nd->nd_flag & ND_NFSV4) {
2805
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2812
		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
2806
		*tl = txdr_unsigned(NFDIR);
2813
		*tl = txdr_unsigned(NFDIR);
Lines 2872-2878 nfsrpc_rmdir(vnode_t dvp, char *name, int namelen, str Link Here
2872
	*dattrflagp = 0;
2879
	*dattrflagp = 0;
2873
	if (namelen > NFS_MAXNAMLEN)
2880
	if (namelen > NFS_MAXNAMLEN)
2874
		return (ENAMETOOLONG);
2881
		return (ENAMETOOLONG);
2875
	NFSCL_REQSTART(nd, NFSPROC_RMDIR, dvp);
2882
	NFSCL_REQSTART(nd, NFSPROC_RMDIR, dvp, cred);
2876
	(void) nfsm_strtom(nd, name, namelen);
2883
	(void) nfsm_strtom(nd, name, namelen);
2877
	error = nfscl_request(nd, dvp, p, cred, dstuff);
2884
	error = nfscl_request(nd, dvp, p, cred, dstuff);
2878
	if (error)
2885
	if (error)
Lines 2989-2995 nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 Link Here
2989
		 * Joy, oh joy. For V4 we get to hand craft '.' and '..'.
2996
		 * Joy, oh joy. For V4 we get to hand craft '.' and '..'.
2990
		 */
2997
		 */
2991
		if (uiop->uio_offset == 0) {
2998
		if (uiop->uio_offset == 0) {
2992
			NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, vp);
2999
			NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, vp, cred);
2993
			NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
3000
			NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
2994
			*tl++ = txdr_unsigned(NFSV4OP_GETFH);
3001
			*tl++ = txdr_unsigned(NFSV4OP_GETFH);
2995
			*tl = txdr_unsigned(NFSV4OP_GETATTR);
3002
			*tl = txdr_unsigned(NFSV4OP_GETATTR);
Lines 3106-3112 nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 Link Here
3106
	 */
3113
	 */
3107
	while (more_dirs && bigenough) {
3114
	while (more_dirs && bigenough) {
3108
		*attrflagp = 0;
3115
		*attrflagp = 0;
3109
		NFSCL_REQSTART(nd, NFSPROC_READDIR, vp);
3116
		NFSCL_REQSTART(nd, NFSPROC_READDIR, vp, cred);
3110
		if (nd->nd_flag & ND_NFSV2) {
3117
		if (nd->nd_flag & ND_NFSV2) {
3111
			NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
3118
			NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
3112
			*tl++ = cookie.lval[1];
3119
			*tl++ = cookie.lval[1];
Lines 3433-3439 nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsui Link Here
3433
		 * Joy, oh joy. For V4 we get to hand craft '.' and '..'.
3440
		 * Joy, oh joy. For V4 we get to hand craft '.' and '..'.
3434
		 */
3441
		 */
3435
		if (uiop->uio_offset == 0) {
3442
		if (uiop->uio_offset == 0) {
3436
			NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, vp);
3443
			NFSCL_REQSTART(nd, NFSPROC_LOOKUPP, vp, cred);
3437
			NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
3444
			NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
3438
			*tl++ = txdr_unsigned(NFSV4OP_GETFH);
3445
			*tl++ = txdr_unsigned(NFSV4OP_GETFH);
3439
			*tl = txdr_unsigned(NFSV4OP_GETATTR);
3446
			*tl = txdr_unsigned(NFSV4OP_GETATTR);
Lines 3555-3561 nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsui Link Here
3555
	 */
3562
	 */
3556
	while (more_dirs && bigenough) {
3563
	while (more_dirs && bigenough) {
3557
		*attrflagp = 0;
3564
		*attrflagp = 0;
3558
		NFSCL_REQSTART(nd, NFSPROC_READDIRPLUS, vp);
3565
		NFSCL_REQSTART(nd, NFSPROC_READDIRPLUS, vp, cred);
3559
 		NFSM_BUILD(tl, u_int32_t *, 6 * NFSX_UNSIGNED);
3566
 		NFSM_BUILD(tl, u_int32_t *, 6 * NFSX_UNSIGNED);
3560
		*tl++ = cookie.lval[0];
3567
		*tl++ = cookie.lval[0];
3561
		*tl++ = cookie.lval[1];
3568
		*tl++ = cookie.lval[1];
Lines 3911-3917 nfsrpc_commit(vnode_t vp, u_quad_t offset, int cnt, st Link Here
3911
	struct nfsmount *nmp = VFSTONFS(vp->v_mount);
3918
	struct nfsmount *nmp = VFSTONFS(vp->v_mount);
3912
3919
3913
	*attrflagp = 0;
3920
	*attrflagp = 0;
3914
	NFSCL_REQSTART(nd, NFSPROC_COMMIT, vp);
3921
	NFSCL_REQSTART(nd, NFSPROC_COMMIT, vp, cred);
3915
	NFSM_BUILD(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
3922
	NFSM_BUILD(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
3916
	txdr_hyper(offset, tl);
3923
	txdr_hyper(offset, tl);
3917
	tl += 2;
3924
	tl += 2;
Lines 4131-4137 nfsrpc_lockt(struct nfsrv_descript *nd, vnode_t vp, Link Here
4131
	struct nfsclsession *tsep;
4138
	struct nfsclsession *tsep;
4132
4139
4133
	nmp = VFSTONFS(vp->v_mount);
4140
	nmp = VFSTONFS(vp->v_mount);
4134
	NFSCL_REQSTART(nd, NFSPROC_LOCKT, vp);
4141
	NFSCL_REQSTART(nd, NFSPROC_LOCKT, vp, cred);
4135
	NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
4142
	NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
4136
	if (fl->l_type == F_RDLCK)
4143
	if (fl->l_type == F_RDLCK)
4137
		*tl++ = txdr_unsigned(NFSV4LOCKT_READ);
4144
		*tl++ = txdr_unsigned(NFSV4LOCKT_READ);
Lines 4202-4208 nfsrpc_locku(struct nfsrv_descript *nd, struct nfsmoun Link Here
4202
	int error;
4209
	int error;
4203
4210
4204
	nfscl_reqstart(nd, NFSPROC_LOCKU, nmp, lp->nfsl_open->nfso_fh,
4211
	nfscl_reqstart(nd, NFSPROC_LOCKU, nmp, lp->nfsl_open->nfso_fh,
4205
	    lp->nfsl_open->nfso_fhlen, NULL, NULL, 0, 0);
4212
	    lp->nfsl_open->nfso_fhlen, NULL, NULL, 0, 0, cred);
4206
	NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID + 6 * NFSX_UNSIGNED);
4213
	NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID + 6 * NFSX_UNSIGNED);
4207
	*tl++ = txdr_unsigned(type);
4214
	*tl++ = txdr_unsigned(type);
4208
	*tl = txdr_unsigned(lp->nfsl_seqid);
4215
	*tl = txdr_unsigned(lp->nfsl_seqid);
Lines 4254-4260 nfsrpc_lock(struct nfsrv_descript *nd, struct nfsmount Link Here
4254
	uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX];
4261
	uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX];
4255
	struct nfsclsession *tsep;
4262
	struct nfsclsession *tsep;
4256
4263
4257
	nfscl_reqstart(nd, NFSPROC_LOCK, nmp, nfhp, fhlen, NULL, NULL, 0, 0);
4264
	nfscl_reqstart(nd, NFSPROC_LOCK, nmp, nfhp, fhlen, NULL, NULL, 0, 0,
4265
	    cred);
4258
	NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
4266
	NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
4259
	if (type == F_RDLCK)
4267
	if (type == F_RDLCK)
4260
		*tl++ = txdr_unsigned(NFSV4LOCKT_READ);
4268
		*tl++ = txdr_unsigned(NFSV4LOCKT_READ);
Lines 4349-4355 nfsrpc_statfs(vnode_t vp, struct nfsstatfs *sbp, struc Link Here
4349
		/*
4357
		/*
4350
		 * For V4, you actually do a getattr.
4358
		 * For V4, you actually do a getattr.
4351
		 */
4359
		 */
4352
		NFSCL_REQSTART(nd, NFSPROC_GETATTR, vp);
4360
		NFSCL_REQSTART(nd, NFSPROC_GETATTR, vp, cred);
4353
		NFSSTATFS_GETATTRBIT(&attrbits);
4361
		NFSSTATFS_GETATTRBIT(&attrbits);
4354
		(void) nfsrv_putattrbit(nd, &attrbits);
4362
		(void) nfsrv_putattrbit(nd, &attrbits);
4355
		nd->nd_flag |= ND_USEGSSNAME;
4363
		nd->nd_flag |= ND_USEGSSNAME;
Lines 4372-4378 nfsrpc_statfs(vnode_t vp, struct nfsstatfs *sbp, struc Link Here
4372
		if (error)
4380
		if (error)
4373
			goto nfsmout;
4381
			goto nfsmout;
4374
	} else {
4382
	} else {
4375
		NFSCL_REQSTART(nd, NFSPROC_FSSTAT, vp);
4383
		NFSCL_REQSTART(nd, NFSPROC_FSSTAT, vp, NULL);
4376
		error = nfscl_request(nd, vp, p, cred, stuff);
4384
		error = nfscl_request(nd, vp, p, cred, stuff);
4377
		if (error)
4385
		if (error)
4378
			return (error);
4386
			return (error);
Lines 4428-4434 nfsrpc_pathconf(vnode_t vp, struct nfsv3_pathconf *pc, Link Here
4428
		/*
4436
		/*
4429
		 * For V4, you actually do a getattr.
4437
		 * For V4, you actually do a getattr.
4430
		 */
4438
		 */
4431
		NFSCL_REQSTART(nd, NFSPROC_GETATTR, vp);
4439
		NFSCL_REQSTART(nd, NFSPROC_GETATTR, vp, cred);
4432
		NFSPATHCONF_GETATTRBIT(&attrbits);
4440
		NFSPATHCONF_GETATTRBIT(&attrbits);
4433
		(void) nfsrv_putattrbit(nd, &attrbits);
4441
		(void) nfsrv_putattrbit(nd, &attrbits);
4434
		nd->nd_flag |= ND_USEGSSNAME;
4442
		nd->nd_flag |= ND_USEGSSNAME;
Lines 4445-4451 nfsrpc_pathconf(vnode_t vp, struct nfsv3_pathconf *pc, Link Here
4445
			error = nd->nd_repstat;
4453
			error = nd->nd_repstat;
4446
		}
4454
		}
4447
	} else {
4455
	} else {
4448
		NFSCL_REQSTART(nd, NFSPROC_PATHCONF, vp);
4456
		NFSCL_REQSTART(nd, NFSPROC_PATHCONF, vp, NULL);
4449
		error = nfscl_request(nd, vp, p, cred, stuff);
4457
		error = nfscl_request(nd, vp, p, cred, stuff);
4450
		if (error)
4458
		if (error)
4451
			return (error);
4459
			return (error);
Lines 4481-4487 nfsrpc_fsinfo(vnode_t vp, struct nfsfsinfo *fsp, struc Link Here
4481
	int error;
4489
	int error;
4482
4490
4483
	*attrflagp = 0;
4491
	*attrflagp = 0;
4484
	NFSCL_REQSTART(nd, NFSPROC_FSINFO, vp);
4492
	NFSCL_REQSTART(nd, NFSPROC_FSINFO, vp, NULL);
4485
	error = nfscl_request(nd, vp, p, cred, stuff);
4493
	error = nfscl_request(nd, vp, p, cred, stuff);
4486
	if (error)
4494
	if (error)
4487
		return (error);
4495
		return (error);
Lines 4528-4537 nfsrpc_renew(struct nfsclclient *clp, struct nfsclds * Link Here
4528
		return (0);
4536
		return (0);
4529
	if (dsp == NULL)
4537
	if (dsp == NULL)
4530
		nfscl_reqstart(nd, NFSPROC_RENEW, nmp, NULL, 0, NULL, NULL, 0,
4538
		nfscl_reqstart(nd, NFSPROC_RENEW, nmp, NULL, 0, NULL, NULL, 0,
4531
		    0);
4539
		    0, cred);
4532
	else
4540
	else
4533
		nfscl_reqstart(nd, NFSPROC_RENEW, nmp, NULL, 0, NULL,
4541
		nfscl_reqstart(nd, NFSPROC_RENEW, nmp, NULL, 0, NULL,
4534
		    &dsp->nfsclds_sess, 0, 0);
4542
		    &dsp->nfsclds_sess, 0, 0, NULL);
4535
	if (!NFSHASNFSV4N(nmp)) {
4543
	if (!NFSHASNFSV4N(nmp)) {
4536
		/* NFSv4.1 just uses a Sequence Op and not a Renew. */
4544
		/* NFSv4.1 just uses a Sequence Op and not a Renew. */
4537
		NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
4545
		NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
Lines 4578-4588 nfsrpc_rellockown(struct nfsmount *nmp, struct nfscllo Link Here
4578
	if (NFSHASNFSV4N(nmp)) {
4586
	if (NFSHASNFSV4N(nmp)) {
4579
		/* For NFSv4.1, do a FreeStateID. */
4587
		/* For NFSv4.1, do a FreeStateID. */
4580
		nfscl_reqstart(nd, NFSPROC_FREESTATEID, nmp, NULL, 0, NULL,
4588
		nfscl_reqstart(nd, NFSPROC_FREESTATEID, nmp, NULL, 0, NULL,
4581
		    NULL, 0, 0);
4589
		    NULL, 0, 0, cred);
4582
		nfsm_stateidtom(nd, &lp->nfsl_stateid, NFSSTATEID_PUTSTATEID);
4590
		nfsm_stateidtom(nd, &lp->nfsl_stateid, NFSSTATEID_PUTSTATEID);
4583
	} else {
4591
	} else {
4584
		nfscl_reqstart(nd, NFSPROC_RELEASELCKOWN, nmp, NULL, 0, NULL,
4592
		nfscl_reqstart(nd, NFSPROC_RELEASELCKOWN, nmp, NULL, 0, NULL,
4585
		    NULL, 0, 0);
4593
		    NULL, 0, 0, NULL);
4586
		NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
4594
		NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
4587
		tsep = nfsmnt_mdssession(nmp);
4595
		tsep = nfsmnt_mdssession(nmp);
4588
		*tl++ = tsep->nfsess_clientid.lval[0];
4596
		*tl++ = tsep->nfsess_clientid.lval[0];
Lines 4616-4622 nfsrpc_getdirpath(struct nfsmount *nmp, u_char *dirpat Link Here
4616
	u_int32_t *opcntp;
4624
	u_int32_t *opcntp;
4617
4625
4618
	nfscl_reqstart(nd, NFSPROC_PUTROOTFH, nmp, NULL, 0, &opcntp, NULL, 0,
4626
	nfscl_reqstart(nd, NFSPROC_PUTROOTFH, nmp, NULL, 0, &opcntp, NULL, 0,
4619
	    0);
4627
	    0, NULL);
4620
	cp = dirpath;
4628
	cp = dirpath;
4621
	cnt = 0;
4629
	cnt = 0;
4622
	do {
4630
	do {
Lines 4683-4689 nfsrpc_delegreturn(struct nfscldeleg *dp, struct ucred Link Here
4683
	int error;
4691
	int error;
4684
4692
4685
	nfscl_reqstart(nd, NFSPROC_DELEGRETURN, nmp, dp->nfsdl_fh,
4693
	nfscl_reqstart(nd, NFSPROC_DELEGRETURN, nmp, dp->nfsdl_fh,
4686
	    dp->nfsdl_fhlen, NULL, NULL, 0, 0);
4694
	    dp->nfsdl_fhlen, NULL, NULL, 0, 0, cred);
4687
	NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID);
4695
	NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID);
4688
	if (NFSHASNFSV4N(nmp))
4696
	if (NFSHASNFSV4N(nmp))
4689
		*tl++ = 0;
4697
		*tl++ = 0;
Lines 4717-4723 nfsrpc_getacl(vnode_t vp, struct ucred *cred, NFSPROC_ Link Here
4717
4725
4718
	if (nfsrv_useacl == 0 || !NFSHASNFSV4(nmp))
4726
	if (nfsrv_useacl == 0 || !NFSHASNFSV4(nmp))
4719
		return (EOPNOTSUPP);
4727
		return (EOPNOTSUPP);
4720
	NFSCL_REQSTART(nd, NFSPROC_GETACL, vp);
4728
	NFSCL_REQSTART(nd, NFSPROC_GETACL, vp, cred);
4721
	NFSZERO_ATTRBIT(&attrbits);
4729
	NFSZERO_ATTRBIT(&attrbits);
4722
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
4730
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
4723
	(void) nfsrv_putattrbit(nd, &attrbits);
4731
	(void) nfsrv_putattrbit(nd, &attrbits);
Lines 4763-4769 nfsrpc_setaclrpc(vnode_t vp, struct ucred *cred, NFSPR Link Here
4763
4771
4764
	if (!NFSHASNFSV4(nmp))
4772
	if (!NFSHASNFSV4(nmp))
4765
		return (EOPNOTSUPP);
4773
		return (EOPNOTSUPP);
4766
	NFSCL_REQSTART(nd, NFSPROC_SETACL, vp);
4774
	NFSCL_REQSTART(nd, NFSPROC_SETACL, vp, cred);
4767
	nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
4775
	nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
4768
	NFSZERO_ATTRBIT(&attrbits);
4776
	NFSZERO_ATTRBIT(&attrbits);
4769
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
4777
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
Lines 4796-4802 nfsrpc_exchangeid(struct nfsmount *nmp, struct nfsclcl Link Here
4796
	if (minorvers == 0)
4804
	if (minorvers == 0)
4797
		minorvers = nmp->nm_minorvers;
4805
		minorvers = nmp->nm_minorvers;
4798
	nfscl_reqstart(nd, NFSPROC_EXCHANGEID, nmp, NULL, 0, NULL, NULL,
4806
	nfscl_reqstart(nd, NFSPROC_EXCHANGEID, nmp, NULL, 0, NULL, NULL,
4799
	    NFS_VER4, minorvers);
4807
	    NFS_VER4, minorvers, NULL);
4800
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED);
4808
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED);
4801
	*tl++ = txdr_unsigned(nfsboottime.tv_sec);	/* Client owner */
4809
	*tl++ = txdr_unsigned(nfsboottime.tv_sec);	/* Client owner */
4802
	*tl = txdr_unsigned(clp->nfsc_rev);
4810
	*tl = txdr_unsigned(clp->nfsc_rev);
Lines 4892-4898 nfsrpc_createsession(struct nfsmount *nmp, struct nfsc Link Here
4892
	else
4900
	else
4893
		minorvers = NFSV41_MINORVERSION;
4901
		minorvers = NFSV41_MINORVERSION;
4894
	nfscl_reqstart(nd, NFSPROC_CREATESESSION, nmp, NULL, 0, NULL, NULL,
4902
	nfscl_reqstart(nd, NFSPROC_CREATESESSION, nmp, NULL, 0, NULL, NULL,
4895
	    NFS_VER4, minorvers);
4903
	    NFS_VER4, minorvers, NULL);
4896
	NFSM_BUILD(tl, uint32_t *, 4 * NFSX_UNSIGNED);
4904
	NFSM_BUILD(tl, uint32_t *, 4 * NFSX_UNSIGNED);
4897
	*tl++ = sep->nfsess_clientid.lval[0];
4905
	*tl++ = sep->nfsess_clientid.lval[0];
4898
	*tl++ = sep->nfsess_clientid.lval[1];
4906
	*tl++ = sep->nfsess_clientid.lval[1];
Lines 5010-5043 nfsmout: Link Here
5010
}
5018
}
5011
5019
5012
/*
5020
/*
5013
 * Do the NFSv4.1 Destroy Session.
5014
 */
5015
int
5016
nfsrpc_destroysession(struct nfsmount *nmp, struct nfsclclient *clp,
5017
    struct ucred *cred, NFSPROC_T *p)
5018
{
5019
	uint32_t *tl;
5020
	struct nfsrv_descript nfsd;
5021
	struct nfsrv_descript *nd = &nfsd;
5022
	int error;
5023
	struct nfsclsession *tsep;
5024
5025
	nfscl_reqstart(nd, NFSPROC_DESTROYSESSION, nmp, NULL, 0, NULL, NULL, 0,
5026
	    0);
5027
	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID);
5028
	tsep = nfsmnt_mdssession(nmp);
5029
	bcopy(tsep->nfsess_sessionid, tl, NFSX_V4SESSIONID);
5030
	nd->nd_flag |= ND_USEGSSNAME;
5031
	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
5032
	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
5033
	if (error != 0)
5034
		return (error);
5035
	error = nd->nd_repstat;
5036
	m_freem(nd->nd_mrep);
5037
	return (error);
5038
}
5039
5040
/*
5041
 * Do the NFSv4.1 Destroy Client.
5021
 * Do the NFSv4.1 Destroy Client.
5042
 */
5022
 */
5043
int
5023
int
Lines 5051-5057 nfsrpc_destroyclient(struct nfsmount *nmp, struct nfsc Link Here
5051
	struct nfsclsession *tsep;
5031
	struct nfsclsession *tsep;
5052
5032
5053
	nfscl_reqstart(nd, NFSPROC_DESTROYCLIENT, nmp, NULL, 0, NULL, NULL, 0,
5033
	nfscl_reqstart(nd, NFSPROC_DESTROYCLIENT, nmp, NULL, 0, NULL, NULL, 0,
5054
	    0);
5034
	    0, NULL);
5055
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED);
5035
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED);
5056
	tsep = nfsmnt_mdssession(nmp);
5036
	tsep = nfsmnt_mdssession(nmp);
5057
	*tl++ = tsep->nfsess_clientid.lval[0];
5037
	*tl++ = tsep->nfsess_clientid.lval[0];
Lines 5080-5086 nfsrpc_layoutget(struct nfsmount *nmp, uint8_t *fhp, i Link Here
5080
	int error;
5060
	int error;
5081
5061
5082
	nfscl_reqstart(nd, NFSPROC_LAYOUTGET, nmp, fhp, fhlen, NULL, NULL, 0,
5062
	nfscl_reqstart(nd, NFSPROC_LAYOUTGET, nmp, fhp, fhlen, NULL, NULL, 0,
5083
	    0);
5063
	    0, cred);
5084
	nfsrv_setuplayoutget(nd, iomode, offset, len, minlen, stateidp,
5064
	nfsrv_setuplayoutget(nd, iomode, offset, len, minlen, stateidp,
5085
	    layouttype, layoutlen, 0);
5065
	    layouttype, layoutlen, 0);
5086
	nd->nd_flag |= ND_USEGSSNAME;
5066
	nd->nd_flag |= ND_USEGSSNAME;
Lines 5124-5130 nfsrpc_getdeviceinfo(struct nfsmount *nmp, uint8_t *de Link Here
5124
	ndi = NULL;
5104
	ndi = NULL;
5125
	gotdspp = NULL;
5105
	gotdspp = NULL;
5126
	nfscl_reqstart(nd, NFSPROC_GETDEVICEINFO, nmp, NULL, 0, NULL, NULL, 0,
5106
	nfscl_reqstart(nd, NFSPROC_GETDEVICEINFO, nmp, NULL, 0, NULL, NULL, 0,
5127
	    0);
5107
	    0, cred);
5128
	NFSM_BUILD(tl, uint32_t *, NFSX_V4DEVICEID + 3 * NFSX_UNSIGNED);
5108
	NFSM_BUILD(tl, uint32_t *, NFSX_V4DEVICEID + 3 * NFSX_UNSIGNED);
5129
	NFSBCOPY(deviceid, tl, NFSX_V4DEVICEID);
5109
	NFSBCOPY(deviceid, tl, NFSX_V4DEVICEID);
5130
	tl += (NFSX_V4DEVICEID / NFSX_UNSIGNED);
5110
	tl += (NFSX_V4DEVICEID / NFSX_UNSIGNED);
Lines 5345-5351 nfsrpc_layoutcommit(struct nfsmount *nmp, uint8_t *fh, Link Here
5345
	int error;
5325
	int error;
5346
5326
5347
	nfscl_reqstart(nd, NFSPROC_LAYOUTCOMMIT, nmp, fh, fhlen, NULL, NULL,
5327
	nfscl_reqstart(nd, NFSPROC_LAYOUTCOMMIT, nmp, fh, fhlen, NULL, NULL,
5348
	    0, 0);
5328
	    0, 0, cred);
5349
	NFSM_BUILD(tl, uint32_t *, 5 * NFSX_UNSIGNED + 3 * NFSX_HYPER +
5329
	NFSM_BUILD(tl, uint32_t *, 5 * NFSX_UNSIGNED + 3 * NFSX_HYPER +
5350
	    NFSX_STATEID);
5330
	    NFSX_STATEID);
5351
	txdr_hyper(off, tl);
5331
	txdr_hyper(off, tl);
Lines 5396-5402 nfsrpc_layoutreturn(struct nfsmount *nmp, uint8_t *fh, Link Here
5396
	int error;
5376
	int error;
5397
5377
5398
	nfscl_reqstart(nd, NFSPROC_LAYOUTRETURN, nmp, fh, fhlen, NULL, NULL,
5378
	nfscl_reqstart(nd, NFSPROC_LAYOUTRETURN, nmp, fh, fhlen, NULL, NULL,
5399
	    0, 0);
5379
	    0, 0, cred);
5400
	NFSM_BUILD(tl, uint32_t *, 4 * NFSX_UNSIGNED);
5380
	NFSM_BUILD(tl, uint32_t *, 4 * NFSX_UNSIGNED);
5401
	if (reclaim != 0)
5381
	if (reclaim != 0)
5402
		*tl++ = newnfs_true;
5382
		*tl++ = newnfs_true;
Lines 5482-5488 nfsrpc_layouterror(struct nfsmount *nmp, uint8_t *fh, Link Here
5482
	int error;
5462
	int error;
5483
5463
5484
	nfscl_reqstart(nd, NFSPROC_LAYOUTERROR, nmp, fh, fhlen, NULL, NULL,
5464
	nfscl_reqstart(nd, NFSPROC_LAYOUTERROR, nmp, fh, fhlen, NULL, NULL,
5485
	    0, 0);
5465
	    0, 0, cred);
5486
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + NFSX_STATEID +
5466
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + NFSX_STATEID +
5487
	    NFSX_V4DEVICEID + 3 * NFSX_UNSIGNED);
5467
	    NFSX_V4DEVICEID + 3 * NFSX_UNSIGNED);
5488
	txdr_hyper(offset, tl); tl += 2;
5468
	txdr_hyper(offset, tl); tl += 2;
Lines 5791-5797 nfsrpc_reclaimcomplete(struct nfsmount *nmp, struct uc Link Here
5791
	int error;
5771
	int error;
5792
5772
5793
	nfscl_reqstart(nd, NFSPROC_RECLAIMCOMPL, nmp, NULL, 0, NULL, NULL, 0,
5773
	nfscl_reqstart(nd, NFSPROC_RECLAIMCOMPL, nmp, NULL, 0, NULL, NULL, 0,
5794
	    0);
5774
	    0, cred);
5795
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
5775
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
5796
	*tl = newnfs_false;
5776
	*tl = newnfs_false;
5797
	nd->nd_flag |= ND_USEGSSNAME;
5777
	nd->nd_flag |= ND_USEGSSNAME;
Lines 5820-5825 nfscl_initsessionslots(struct nfsclsession *sep) Link Here
5820
	for (i = 0; i < 64; i++)
5800
	for (i = 0; i < 64; i++)
5821
		sep->nfsess_slotseq[i] = 0;
5801
		sep->nfsess_slotseq[i] = 0;
5822
	sep->nfsess_slots = 0;
5802
	sep->nfsess_slots = 0;
5803
	sep->nfsess_badslots = 0;
5823
}
5804
}
5824
5805
5825
/*
5806
/*
Lines 6414-6420 nfsrpc_readds(vnode_t vp, struct uio *uiop, nfsv4state Link Here
6414
	nd->nd_mrep = NULL;
6395
	nd->nd_mrep = NULL;
6415
	if (vers == 0 || vers == NFS_VER4) {
6396
	if (vers == 0 || vers == NFS_VER4) {
6416
		nfscl_reqstart(nd, NFSPROC_READDS, nmp, fhp->nfh_fh,
6397
		nfscl_reqstart(nd, NFSPROC_READDS, nmp, fhp->nfh_fh,
6417
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6398
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6399
		    NULL);
6418
		vers = NFS_VER4;
6400
		vers = NFS_VER4;
6419
		NFSCL_DEBUG(4, "nfsrpc_readds: vers4 minvers=%d\n", minorvers);
6401
		NFSCL_DEBUG(4, "nfsrpc_readds: vers4 minvers=%d\n", minorvers);
6420
		if (flex != 0)
6402
		if (flex != 0)
Lines 6423-6429 nfsrpc_readds(vnode_t vp, struct uio *uiop, nfsv4state Link Here
6423
			nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSEQIDZERO);
6405
			nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSEQIDZERO);
6424
	} else {
6406
	} else {
6425
		nfscl_reqstart(nd, NFSPROC_READ, nmp, fhp->nfh_fh,
6407
		nfscl_reqstart(nd, NFSPROC_READ, nmp, fhp->nfh_fh,
6426
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6408
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6409
		    NULL);
6427
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_READ]);
6410
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_READ]);
6428
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_READDS]);
6411
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_READDS]);
6429
		NFSCL_DEBUG(4, "nfsrpc_readds: vers3\n");
6412
		NFSCL_DEBUG(4, "nfsrpc_readds: vers3\n");
Lines 6490-6496 nfsrpc_writeds(vnode_t vp, struct uio *uiop, int *iomo Link Here
6490
	nd->nd_mrep = NULL;
6473
	nd->nd_mrep = NULL;
6491
	if (vers == 0 || vers == NFS_VER4) {
6474
	if (vers == 0 || vers == NFS_VER4) {
6492
		nfscl_reqstart(nd, NFSPROC_WRITEDS, nmp, fhp->nfh_fh,
6475
		nfscl_reqstart(nd, NFSPROC_WRITEDS, nmp, fhp->nfh_fh,
6493
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6476
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6477
		    NULL);
6494
		NFSCL_DEBUG(4, "nfsrpc_writeds: vers4 minvers=%d\n", minorvers);
6478
		NFSCL_DEBUG(4, "nfsrpc_writeds: vers4 minvers=%d\n", minorvers);
6495
		vers = NFS_VER4;
6479
		vers = NFS_VER4;
6496
		if (flex != 0)
6480
		if (flex != 0)
Lines 6500-6506 nfsrpc_writeds(vnode_t vp, struct uio *uiop, int *iomo Link Here
6500
		NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
6484
		NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
6501
	} else {
6485
	} else {
6502
		nfscl_reqstart(nd, NFSPROC_WRITE, nmp, fhp->nfh_fh,
6486
		nfscl_reqstart(nd, NFSPROC_WRITE, nmp, fhp->nfh_fh,
6503
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6487
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6488
		    NULL);
6504
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITE]);
6489
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITE]);
6505
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITEDS]);
6490
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITEDS]);
6506
		NFSCL_DEBUG(4, "nfsrpc_writeds: vers3\n");
6491
		NFSCL_DEBUG(4, "nfsrpc_writeds: vers3\n");
Lines 6623-6629 nfsrpc_writedsmir(vnode_t vp, int *iomode, int *must_c Link Here
6623
	nd->nd_mrep = NULL;
6608
	nd->nd_mrep = NULL;
6624
	if (vers == 0 || vers == NFS_VER4) {
6609
	if (vers == 0 || vers == NFS_VER4) {
6625
		nfscl_reqstart(nd, NFSPROC_WRITEDS, nmp, fhp->nfh_fh,
6610
		nfscl_reqstart(nd, NFSPROC_WRITEDS, nmp, fhp->nfh_fh,
6626
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6611
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6612
		    NULL);
6627
		vers = NFS_VER4;
6613
		vers = NFS_VER4;
6628
		NFSCL_DEBUG(4, "nfsrpc_writedsmir: vers4 minvers=%d\n",
6614
		NFSCL_DEBUG(4, "nfsrpc_writedsmir: vers4 minvers=%d\n",
6629
		    minorvers);
6615
		    minorvers);
Lines 6631-6637 nfsrpc_writedsmir(vnode_t vp, int *iomode, int *must_c Link Here
6631
		NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
6617
		NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
6632
	} else {
6618
	} else {
6633
		nfscl_reqstart(nd, NFSPROC_WRITE, nmp, fhp->nfh_fh,
6619
		nfscl_reqstart(nd, NFSPROC_WRITE, nmp, fhp->nfh_fh,
6634
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6620
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6621
		    NULL);
6635
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITE]);
6622
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITE]);
6636
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITEDS]);
6623
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_WRITEDS]);
6637
		NFSCL_DEBUG(4, "nfsrpc_writedsmir: vers3\n");
6624
		NFSCL_DEBUG(4, "nfsrpc_writedsmir: vers3\n");
Lines 6851-6861 nfsrpc_commitds(vnode_t vp, uint64_t offset, int cnt, Link Here
6851
	nd->nd_mrep = NULL;
6838
	nd->nd_mrep = NULL;
6852
	if (vers == 0 || vers == NFS_VER4) {
6839
	if (vers == 0 || vers == NFS_VER4) {
6853
		nfscl_reqstart(nd, NFSPROC_COMMITDS, nmp, fhp->nfh_fh,
6840
		nfscl_reqstart(nd, NFSPROC_COMMITDS, nmp, fhp->nfh_fh,
6854
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6841
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6842
		    NULL);
6855
		vers = NFS_VER4;
6843
		vers = NFS_VER4;
6856
	} else {
6844
	} else {
6857
		nfscl_reqstart(nd, NFSPROC_COMMIT, nmp, fhp->nfh_fh,
6845
		nfscl_reqstart(nd, NFSPROC_COMMIT, nmp, fhp->nfh_fh,
6858
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
6846
		    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers,
6847
		    NULL);
6859
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_COMMIT]);
6848
		NFSDECRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_COMMIT]);
6860
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_COMMITDS]);
6849
		NFSINCRGLOBAL(nfsstatsv1.rpccnt[NFSPROC_COMMITDS]);
6861
	}
6850
	}
Lines 6970-6976 nfsrpc_advise(vnode_t vp, off_t offset, uint64_t cnt, Link Here
6970
		NFSSETBIT_ATTRBIT(&hints, NFSV4IOHINT_DONTNEED);
6959
		NFSSETBIT_ATTRBIT(&hints, NFSV4IOHINT_DONTNEED);
6971
	else
6960
	else
6972
		return (0);
6961
		return (0);
6973
	NFSCL_REQSTART(nd, NFSPROC_IOADVISE, vp);
6962
	NFSCL_REQSTART(nd, NFSPROC_IOADVISE, vp, cred);
6974
	nfsm_stateidtom(nd, NULL, NFSSTATEID_PUTALLZERO);
6963
	nfsm_stateidtom(nd, NULL, NFSSTATEID_PUTALLZERO);
6975
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER);
6964
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER);
6976
	txdr_hyper(offset, tl);
6965
	txdr_hyper(offset, tl);
Lines 7014-7020 nfsrpc_adviseds(vnode_t vp, uint64_t offset, int cnt, Link Here
7014
		return (0);
7003
		return (0);
7015
	nd->nd_mrep = NULL;
7004
	nd->nd_mrep = NULL;
7016
	nfscl_reqstart(nd, NFSPROC_IOADVISEDS, nmp, fhp->nfh_fh,
7005
	nfscl_reqstart(nd, NFSPROC_IOADVISEDS, nmp, fhp->nfh_fh,
7017
	    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers);
7006
	    fhp->nfh_len, NULL, &dsp->nfsclds_sess, vers, minorvers, NULL);
7018
	vers = NFS_VER4;
7007
	vers = NFS_VER4;
7019
	NFSCL_DEBUG(4, "nfsrpc_adviseds: vers=%d minvers=%d\n", vers,
7008
	NFSCL_DEBUG(4, "nfsrpc_adviseds: vers=%d minvers=%d\n", vers,
7020
	    minorvers);
7009
	    minorvers);
Lines 7184-7190 nfsrpc_allocaterpc(vnode_t vp, off_t off, off_t len, n Link Here
7184
	nfsattrbit_t attrbits;
7173
	nfsattrbit_t attrbits;
7185
7174
7186
	*attrflagp = 0;
7175
	*attrflagp = 0;
7187
	NFSCL_REQSTART(nd, NFSPROC_ALLOCATE, vp);
7176
	NFSCL_REQSTART(nd, NFSPROC_ALLOCATE, vp, cred);
7188
	nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
7177
	nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
7189
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + NFSX_UNSIGNED);
7178
	NFSM_BUILD(tl, uint32_t *, 2 * NFSX_HYPER + NFSX_UNSIGNED);
7190
	txdr_hyper(off, tl); tl += 2;
7179
	txdr_hyper(off, tl); tl += 2;
Lines 7672-7678 nfsrpc_openlayoutrpc(struct nfsmount *nmp, vnode_t vp, Link Here
7672
	*dpp = NULL;
7661
	*dpp = NULL;
7673
	*laystatp = ENXIO;
7662
	*laystatp = ENXIO;
7674
	nfscl_reqstart(nd, NFSPROC_OPENLAYGET, nmp, nfhp, fhlen, NULL, NULL,
7663
	nfscl_reqstart(nd, NFSPROC_OPENLAYGET, nmp, nfhp, fhlen, NULL, NULL,
7675
	    0, 0);
7664
	    0, 0, cred);
7676
	NFSM_BUILD(tl, uint32_t *, 5 * NFSX_UNSIGNED);
7665
	NFSM_BUILD(tl, uint32_t *, 5 * NFSX_UNSIGNED);
7677
	*tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid);
7666
	*tl++ = txdr_unsigned(op->nfso_own->nfsow_seqid);
7678
	*tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH);
7667
	*tl++ = txdr_unsigned(mode & NFSV4OPEN_ACCESSBOTH);
Lines 7857-7863 nfsrpc_createlayout(vnode_t dvp, char *name, int namel Link Here
7857
	*dattrflagp = 0;
7846
	*dattrflagp = 0;
7858
	if (namelen > NFS_MAXNAMLEN)
7847
	if (namelen > NFS_MAXNAMLEN)
7859
		return (ENAMETOOLONG);
7848
		return (ENAMETOOLONG);
7860
	NFSCL_REQSTART(nd, NFSPROC_CREATELAYGET, dvp);
7849
	NFSCL_REQSTART(nd, NFSPROC_CREATELAYGET, dvp, cred);
7861
	/*
7850
	/*
7862
	 * For V4, this is actually an Open op.
7851
	 * For V4, this is actually an Open op.
7863
	 */
7852
	 */
Lines 8069-8075 nfsrpc_createlayout(vnode_t dvp, char *name, int namel Link Here
8069
	}
8058
	}
8070
	if (nd->nd_repstat != 0 && error == 0)
8059
	if (nd->nd_repstat != 0 && error == 0)
8071
		error = nd->nd_repstat;
8060
		error = nd->nd_repstat;
8072
	if (error == NFSERR_STALECLIENTID || error == NFSERR_BADSESSION)
8061
	if (error == NFSERR_STALECLIENTID)
8073
		nfscl_initiate_recovery(owp->nfsow_clp);
8062
		nfscl_initiate_recovery(owp->nfsow_clp);
8074
nfsmout:
8063
nfsmout:
8075
	NFSCL_DEBUG(4, "eo nfsrpc_createlayout err=%d\n", error);
8064
	NFSCL_DEBUG(4, "eo nfsrpc_createlayout err=%d\n", error);
Lines 8298-8304 nfsrpc_copyrpc(vnode_t invp, off_t inoff, vnode_t outv Link Here
8298
	*lenp = 0;
8287
	*lenp = 0;
8299
	if (len > nfs_maxcopyrange)
8288
	if (len > nfs_maxcopyrange)
8300
		len = nfs_maxcopyrange;
8289
		len = nfs_maxcopyrange;
8301
	NFSCL_REQSTART(nd, NFSPROC_COPY, invp);
8290
	NFSCL_REQSTART(nd, NFSPROC_COPY, invp, cred);
8302
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
8291
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
8303
	*tl = txdr_unsigned(NFSV4OP_GETATTR);
8292
	*tl = txdr_unsigned(NFSV4OP_GETATTR);
8304
	NFSGETATTR_ATTRBIT(&attrbits);
8293
	NFSGETATTR_ATTRBIT(&attrbits);
Lines 8463-8469 nfsrpc_seekrpc(vnode_t vp, off_t *offp, nfsv4stateid_t Link Here
8463
	nfsattrbit_t attrbits;
8452
	nfsattrbit_t attrbits;
8464
8453
8465
	*attrflagp = 0;
8454
	*attrflagp = 0;
8466
	NFSCL_REQSTART(nd, NFSPROC_SEEK, vp);
8455
	NFSCL_REQSTART(nd, NFSPROC_SEEK, vp, cred);
8467
	nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
8456
	nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
8468
	NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
8457
	NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
8469
	txdr_hyper(*offp, tl); tl += 2;
8458
	txdr_hyper(*offp, tl); tl += 2;
Lines 8507-8513 nfsrpc_getextattr(vnode_t vp, const char *name, struct Link Here
8507
	uint32_t len, len2;
8496
	uint32_t len, len2;
8508
8497
8509
	*attrflagp = 0;
8498
	*attrflagp = 0;
8510
	NFSCL_REQSTART(nd, NFSPROC_GETEXTATTR, vp);
8499
	NFSCL_REQSTART(nd, NFSPROC_GETEXTATTR, vp, cred);
8511
	nfsm_strtom(nd, name, strlen(name));
8500
	nfsm_strtom(nd, name, strlen(name));
8512
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
8501
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
8513
	*tl = txdr_unsigned(NFSV4OP_GETATTR);
8502
	*tl = txdr_unsigned(NFSV4OP_GETATTR);
Lines 8577-8583 nfsrpc_setextattr(vnode_t vp, const char *name, struct Link Here
8577
	nfsattrbit_t attrbits;
8566
	nfsattrbit_t attrbits;
8578
8567
8579
	*attrflagp = 0;
8568
	*attrflagp = 0;
8580
	NFSCL_REQSTART(nd, NFSPROC_SETEXTATTR, vp);
8569
	NFSCL_REQSTART(nd, NFSPROC_SETEXTATTR, vp, cred);
8581
	if (uiop->uio_resid > nd->nd_maxreq) {
8570
	if (uiop->uio_resid > nd->nd_maxreq) {
8582
		/* nd_maxreq is set by NFSCL_REQSTART(). */
8571
		/* nd_maxreq is set by NFSCL_REQSTART(). */
8583
		m_freem(nd->nd_mreq);
8572
		m_freem(nd->nd_mreq);
Lines 8625-8631 nfsrpc_rmextattr(vnode_t vp, const char *name, struct Link Here
8625
	nfsattrbit_t attrbits;
8614
	nfsattrbit_t attrbits;
8626
8615
8627
	*attrflagp = 0;
8616
	*attrflagp = 0;
8628
	NFSCL_REQSTART(nd, NFSPROC_RMEXTATTR, vp);
8617
	NFSCL_REQSTART(nd, NFSPROC_RMEXTATTR, vp, cred);
8629
	nfsm_strtom(nd, name, strlen(name));
8618
	nfsm_strtom(nd, name, strlen(name));
8630
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
8619
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
8631
	*tl = txdr_unsigned(NFSV4OP_GETATTR);
8620
	*tl = txdr_unsigned(NFSV4OP_GETATTR);
Lines 8665-8671 nfsrpc_listextattr(vnode_t vp, uint64_t *cookiep, stru Link Here
8665
	u_char c;
8654
	u_char c;
8666
8655
8667
	*attrflagp = 0;
8656
	*attrflagp = 0;
8668
	NFSCL_REQSTART(nd, NFSPROC_LISTEXTATTR, vp);
8657
	NFSCL_REQSTART(nd, NFSPROC_LISTEXTATTR, vp, cred);
8669
	NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
8658
	NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + 2 * NFSX_UNSIGNED);
8670
	txdr_hyper(*cookiep, tl); tl += 2;
8659
	txdr_hyper(*cookiep, tl); tl += 2;
8671
	*tl++ = txdr_unsigned(*lenp);
8660
	*tl++ = txdr_unsigned(*lenp);
Lines 8839-8845 nfsrpc_bindconnsess(CLIENT *cl, void *arg, struct ucre Link Here
8839
	int error;
8828
	int error;
8840
8829
8841
	nfscl_reqstart(nd, NFSPROC_BINDCONNTOSESS, NULL, NULL, 0, NULL, NULL,
8830
	nfscl_reqstart(nd, NFSPROC_BINDCONNTOSESS, NULL, NULL, 0, NULL, NULL,
8842
	    NFS_VER4, rcp->minorvers);
8831
	    NFS_VER4, rcp->minorvers, NULL);
8843
	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 2 * NFSX_UNSIGNED);
8832
	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 2 * NFSX_UNSIGNED);
8844
	memcpy(tl, rcp->sessionid, NFSX_V4SESSIONID);
8833
	memcpy(tl, rcp->sessionid, NFSX_V4SESSIONID);
8845
	tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
8834
	tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
(-)sys/fs/nfsclient/nfs_clstate.c (-3 / +2 lines)
Lines 2089-2095 nfscl_umount(struct nfsmount *nmp, NFSPROC_T *p, struc Link Here
2089
		nfscl_delegreturnall(clp, p, dhp);
2089
		nfscl_delegreturnall(clp, p, dhp);
2090
		cred = newnfs_getcred();
2090
		cred = newnfs_getcred();
2091
		if (NFSHASNFSV4N(nmp)) {
2091
		if (NFSHASNFSV4N(nmp)) {
2092
			(void)nfsrpc_destroysession(nmp, clp, cred, p);
2092
			(void)nfsrpc_destroysession(nmp, NULL, cred, p);
2093
			(void)nfsrpc_destroyclient(nmp, clp, cred, p);
2093
			(void)nfsrpc_destroyclient(nmp, clp, cred, p);
2094
		} else
2094
		} else
2095
			(void)nfsrpc_setclient(nmp, clp, 0, NULL, cred, p);
2095
			(void)nfsrpc_setclient(nmp, clp, 0, NULL, cred, p);
Lines 2767-2774 nfscl_renewthread(struct nfsclclient *clp, NFSPROC_T * Link Here
2767
			error = nfsrpc_renew(clp, NULL, cred, p);
2767
			error = nfsrpc_renew(clp, NULL, cred, p);
2768
			if (error == NFSERR_CBPATHDOWN)
2768
			if (error == NFSERR_CBPATHDOWN)
2769
			    cbpathdown = 1;
2769
			    cbpathdown = 1;
2770
			else if (error == NFSERR_STALECLIENTID ||
2770
			else if (error == NFSERR_STALECLIENTID) {
2771
			    error == NFSERR_BADSESSION) {
2772
			    NFSLOCKCLSTATE();
2771
			    NFSLOCKCLSTATE();
2773
			    clp->nfsc_flags |= NFSCLFLAGS_RECOVER;
2772
			    clp->nfsc_flags |= NFSCLFLAGS_RECOVER;
2774
			    NFSUNLOCKCLSTATE();
2773
			    NFSUNLOCKCLSTATE();
(-)sys/fs/nfs/nfscl.h (-2 / +2 lines)
Lines 49-58 struct nfsv4node { Link Here
49
/*
49
/*
50
 * Just a macro to convert the nfscl_reqstart arguments.
50
 * Just a macro to convert the nfscl_reqstart arguments.
51
 */
51
 */
52
#define	NFSCL_REQSTART(n, p, v) 					\
52
#define	NFSCL_REQSTART(n, p, v, c) 					\
53
	nfscl_reqstart((n), (p), VFSTONFS((v)->v_mount), 		\
53
	nfscl_reqstart((n), (p), VFSTONFS((v)->v_mount), 		\
54
	    VTONFS(v)->n_fhp->nfh_fh, VTONFS(v)->n_fhp->nfh_len, NULL,	\
54
	    VTONFS(v)->n_fhp->nfh_fh, VTONFS(v)->n_fhp->nfh_len, NULL,	\
55
	    NULL, 0, 0)
55
	    NULL, 0, 0, (c))
56
56
57
/*
57
/*
58
 * These two macros convert between a lease duration and renew interval.
58
 * These two macros convert between a lease duration and renew interval.
(-)sys/fs/nfs/nfs_commonkrpc.c (-5 / +38 lines)
Lines 951-956 tryagain: Link Here
951
			 */
951
			 */
952
			mtx_lock(&sep->nfsess_mtx);
952
			mtx_lock(&sep->nfsess_mtx);
953
			sep->nfsess_slotseq[nd->nd_slotid] += 10;
953
			sep->nfsess_slotseq[nd->nd_slotid] += 10;
954
			sep->nfsess_badslots |= (0x1ULL << nd->nd_slotid);
954
			mtx_unlock(&sep->nfsess_mtx);
955
			mtx_unlock(&sep->nfsess_mtx);
955
			/* And free the slot. */
956
			/* And free the slot. */
956
			nfsv4_freeslot(sep, nd->nd_slotid, false);
957
			nfsv4_freeslot(sep, nd->nd_slotid, false);
Lines 1019-1026 tryagain: Link Here
1019
			 * If the first op is Sequence, free up the slot.
1020
			 * If the first op is Sequence, free up the slot.
1020
			 */
1021
			 */
1021
			if ((nmp != NULL && i == NFSV4OP_SEQUENCE && j != 0) ||
1022
			if ((nmp != NULL && i == NFSV4OP_SEQUENCE && j != 0) ||
1022
			    (clp != NULL && i == NFSV4OP_CBSEQUENCE && j != 0))
1023
			   (clp != NULL && i == NFSV4OP_CBSEQUENCE && j != 0)) {
1023
				NFSCL_DEBUG(1, "failed seq=%d\n", j);
1024
				NFSCL_DEBUG(1, "failed seq=%d\n", j);
1025
				if (sep != NULL && i == NFSV4OP_SEQUENCE &&
1026
				    j == NFSERR_SEQMISORDERED) {
1027
					mtx_lock(&sep->nfsess_mtx);
1028
					sep->nfsess_badslots |=
1029
					    (0x1ULL << nd->nd_slotid);
1030
					mtx_unlock(&sep->nfsess_mtx);
1031
				}
1032
			}
1024
			if (((nmp != NULL && i == NFSV4OP_SEQUENCE && j == 0) ||
1033
			if (((nmp != NULL && i == NFSV4OP_SEQUENCE && j == 0) ||
1025
			    (clp != NULL && i == NFSV4OP_CBSEQUENCE &&
1034
			    (clp != NULL && i == NFSV4OP_CBSEQUENCE &&
1026
			    j == 0)) && sep != NULL) {
1035
			    j == 0)) && sep != NULL) {
Lines 1039-1049 tryagain: Link Here
1039
					retseq = fxdr_unsigned(uint32_t, *tl++);
1048
					retseq = fxdr_unsigned(uint32_t, *tl++);
1040
					slot = fxdr_unsigned(int, *tl++);
1049
					slot = fxdr_unsigned(int, *tl++);
1041
					if ((nd->nd_flag & ND_HASSLOTID) != 0) {
1050
					if ((nd->nd_flag & ND_HASSLOTID) != 0) {
1042
						if (slot != nd->nd_slotid) {
1051
						if (slot >= NFSV4_SLOTS ||
1052
						    (i == NFSV4OP_CBSEQUENCE &&
1053
						     slot >= NFSV4_CBSLOTS)) {
1043
							printf("newnfs_request:"
1054
							printf("newnfs_request:"
1044
							    " Wrong session "
1055
							    " Bogus slot\n");
1045
							    "slot=%d\n", slot);
1046
							slot = nd->nd_slotid;
1056
							slot = nd->nd_slotid;
1057
						} else if (slot !=
1058
						    nd->nd_slotid) {
1059
						    printf("newnfs_request:"
1060
							" Wrong session "
1061
							"srvslot=%d "
1062
							"slot=%d\n", slot,
1063
							nd->nd_slotid);
1064
						    if (i == NFSV4OP_SEQUENCE) {
1065
							/*
1066
							 * Mark both slots as
1067
							 * bad, because we do
1068
							 * not know if the
1069
							 * server has advanced
1070
							 * the sequence# for
1071
							 * either of them.
1072
							 */
1073
							sep->nfsess_badslots |=
1074
							    (0x1ULL << slot);
1075
							sep->nfsess_badslots |=
1076
							    (0x1ULL <<
1077
							     nd->nd_slotid);
1078
						    }
1079
						    slot = nd->nd_slotid;
1047
						}
1080
						}
1048
					} else if (slot != 0) {
1081
					} else if (slot != 0) {
1049
						printf("newnfs_request: Bad "
1082
						printf("newnfs_request: Bad "
Lines 1121-1127 tryagain: Link Here
1121
				if ((nd->nd_flag & ND_LOOPBADSESS) != 0) {
1154
				if ((nd->nd_flag & ND_LOOPBADSESS) != 0) {
1122
					reterr = nfsv4_sequencelookup(nmp, sep,
1155
					reterr = nfsv4_sequencelookup(nmp, sep,
1123
					    &slotpos, &maxslot, &slotseq,
1156
					    &slotpos, &maxslot, &slotseq,
1124
					    sessionid);
1157
					    sessionid, true);
1125
					if (reterr == 0) {
1158
					if (reterr == 0) {
1126
						/* Fill in new session info. */
1159
						/* Fill in new session info. */
1127
						NFSCL_DEBUG(1,
1160
						NFSCL_DEBUG(1,
(-)sys/fs/nfs/nfsclstate.h (+1 lines)
Lines 67-72 struct nfsclsession { Link Here
67
	SVCXPRT		*nfsess_xprt;		/* For backchannel callback */
67
	SVCXPRT		*nfsess_xprt;		/* For backchannel callback */
68
	uint32_t	nfsess_slotseq[64];	/* Max for 64bit nm_slots */
68
	uint32_t	nfsess_slotseq[64];	/* Max for 64bit nm_slots */
69
	uint64_t	nfsess_slots;
69
	uint64_t	nfsess_slots;
70
	uint64_t	nfsess_badslots;	/* Slots possibly broken */
70
	uint32_t	nfsess_sequenceid;
71
	uint32_t	nfsess_sequenceid;
71
	uint32_t	nfsess_maxcache;	/* Max size for cached reply. */
72
	uint32_t	nfsess_maxcache;	/* Max size for cached reply. */
72
	uint32_t	nfsess_maxreq;		/* Max request size. */
73
	uint32_t	nfsess_maxreq;		/* Max request size. */
(-)sys/fs/nfs/nfs_commonsubs.c (-16 / +84 lines)
Lines 322-328 static int nfs_bigrequest[NFSV42_NPROCS] = { Link Here
322
void
322
void
323
nfscl_reqstart(struct nfsrv_descript *nd, int procnum, struct nfsmount *nmp,
323
nfscl_reqstart(struct nfsrv_descript *nd, int procnum, struct nfsmount *nmp,
324
    u_int8_t *nfhp, int fhlen, u_int32_t **opcntpp, struct nfsclsession *sep,
324
    u_int8_t *nfhp, int fhlen, u_int32_t **opcntpp, struct nfsclsession *sep,
325
    int vers, int minorvers)
325
    int vers, int minorvers, struct ucred *cred)
326
{
326
{
327
	struct mbuf *mb;
327
	struct mbuf *mb;
328
	u_int32_t *tl;
328
	u_int32_t *tl;
Lines 415-425 nfscl_reqstart(struct nfsrv_descript *nd, int procnum, Link Here
415
			*tl = txdr_unsigned(NFSV4OP_SEQUENCE);
415
			*tl = txdr_unsigned(NFSV4OP_SEQUENCE);
416
			if (sep == NULL) {
416
			if (sep == NULL) {
417
				sep = nfsmnt_mdssession(nmp);
417
				sep = nfsmnt_mdssession(nmp);
418
				/*
419
				 * For MDS mount sessions, check for bad
420
				 * slots.  If the caller does not want this
421
				 * check to be done, the "cred" argument can
422
				 * be passed in as NULL.
423
				 */
418
				nfsv4_setsequence(nmp, nd, sep,
424
				nfsv4_setsequence(nmp, nd, sep,
419
				    nfs_bigreply[procnum]);
425
				    nfs_bigreply[procnum], cred);
420
			} else
426
			} else
421
				nfsv4_setsequence(nmp, nd, sep,
427
				nfsv4_setsequence(nmp, nd, sep,
422
				    nfs_bigreply[procnum]);
428
				    nfs_bigreply[procnum], NULL);
423
		}
429
		}
424
		if (nfsv4_opflag[nfsv4_opmap[procnum].op].needscfh > 0) {
430
		if (nfsv4_opflag[nfsv4_opmap[procnum].op].needscfh > 0) {
425
			NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
431
			NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
Lines 4768-4781 nfsv4_seqsess_cacherep(uint32_t slotid, struct nfsslot Link Here
4768
 */
4774
 */
4769
void
4775
void
4770
nfsv4_setsequence(struct nfsmount *nmp, struct nfsrv_descript *nd,
4776
nfsv4_setsequence(struct nfsmount *nmp, struct nfsrv_descript *nd,
4771
    struct nfsclsession *sep, int dont_replycache)
4777
    struct nfsclsession *sep, int dont_replycache, struct ucred *cred)
4772
{
4778
{
4773
	uint32_t *tl, slotseq = 0;
4779
	uint32_t *tl, slotseq = 0;
4774
	int error, maxslot, slotpos;
4780
	int error, maxslot, slotpos;
4775
	uint8_t sessionid[NFSX_V4SESSIONID];
4781
	uint8_t sessionid[NFSX_V4SESSIONID];
4776
4782
4777
	error = nfsv4_sequencelookup(nmp, sep, &slotpos, &maxslot, &slotseq,
4783
	if (cred != NULL) {
4778
	    sessionid);
4784
		error = nfsv4_sequencelookup(nmp, sep, &slotpos, &maxslot,
4785
		    &slotseq, sessionid, false);
4786
		if (error == NFSERR_SEQMISORDERED) {
4787
			/* If all slots are bad, Destroy the session. */
4788
			nfsrpc_destroysession(nmp, sep, cred, curthread);
4789
			error = 0;
4790
		}
4791
	} else
4792
		error = nfsv4_sequencelookup(nmp, sep, &slotpos, &maxslot,
4793
		    &slotseq, sessionid, true);
4779
	nd->nd_maxreq = sep->nfsess_maxreq;
4794
	nd->nd_maxreq = sep->nfsess_maxreq;
4780
	nd->nd_maxresp = sep->nfsess_maxresp;
4795
	nd->nd_maxresp = sep->nfsess_maxresp;
4781
4796
Lines 4812-4828 nfsv4_setsequence(struct nfsmount *nmp, struct nfsrv_d Link Here
4812
	nd->nd_flag |= ND_HASSEQUENCE;
4827
	nd->nd_flag |= ND_HASSEQUENCE;
4813
}
4828
}
4814
4829
4830
/*
4831
 * If fnd_init is true, ignore the badslots.
4832
 * If fnd_init is false, return NFSERR_SEQMISORDERED of all slots are bad.
4833
 */
4815
int
4834
int
4816
nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsclsession *sep,
4835
nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsclsession *sep,
4817
    int *slotposp, int *maxslotp, uint32_t *slotseqp, uint8_t *sessionid)
4836
    int *slotposp, int *maxslotp, uint32_t *slotseqp, uint8_t *sessionid,
4837
    bool fnd_init)
4818
{
4838
{
4819
	int i, maxslot, slotpos;
4839
	int i, maxslot, slotpos;
4820
	uint64_t bitval;
4840
	uint64_t bitval;
4841
	bool fnd_ok;
4821
4842
4822
	/* Find an unused slot. */
4843
	/* Find an unused slot. */
4823
	slotpos = -1;
4844
	slotpos = -1;
4824
	maxslot = -1;
4845
	maxslot = -1;
4825
	mtx_lock(&sep->nfsess_mtx);
4846
	mtx_lock(&sep->nfsess_mtx);
4847
if (sep->nfsess_badslots != 0) printf("bad slots=0x%lx\n", sep->nfsess_badslots);
4826
	do {
4848
	do {
4827
		if (nmp != NULL && sep->nfsess_defunct != 0) {
4849
		if (nmp != NULL && sep->nfsess_defunct != 0) {
4828
			/* Just return the bad session. */
4850
			/* Just return the bad session. */
Lines 4831-4844 nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsc Link Here
4831
			mtx_unlock(&sep->nfsess_mtx);
4853
			mtx_unlock(&sep->nfsess_mtx);
4832
			return (NFSERR_BADSESSION);
4854
			return (NFSERR_BADSESSION);
4833
		}
4855
		}
4856
		fnd_ok = fnd_init;
4834
		bitval = 1;
4857
		bitval = 1;
4835
		for (i = 0; i < sep->nfsess_foreslots; i++) {
4858
		for (i = 0; i < sep->nfsess_foreslots; i++) {
4836
			if ((bitval & sep->nfsess_slots) == 0) {
4859
			if ((bitval & sep->nfsess_badslots) == 0 || fnd_init) {
4837
				slotpos = i;
4860
				fnd_ok = true;
4838
				sep->nfsess_slots |= bitval;
4861
				if ((bitval & sep->nfsess_slots) == 0) {
4839
				sep->nfsess_slotseq[i]++;
4862
					slotpos = i;
4840
				*slotseqp = sep->nfsess_slotseq[i];
4863
					sep->nfsess_slots |= bitval;
4841
				break;
4864
					sep->nfsess_slotseq[i]++;
4865
					*slotseqp = sep->nfsess_slotseq[i];
4866
					break;
4867
				}
4842
			}
4868
			}
4843
			bitval <<= 1;
4869
			bitval <<= 1;
4844
		}
4870
		}
Lines 4853-4862 nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsc Link Here
4853
				return (ESTALE);
4879
				return (ESTALE);
4854
			}
4880
			}
4855
			/* Wake up once/sec, to check for a forced dismount. */
4881
			/* Wake up once/sec, to check for a forced dismount. */
4856
			(void)mtx_sleep(&sep->nfsess_slots, &sep->nfsess_mtx,
4882
			if (fnd_ok)
4857
			    PZERO, "nfsclseq", hz);
4883
				mtx_sleep(&sep->nfsess_slots, &sep->nfsess_mtx,
4884
				    PZERO, "nfsclseq", hz);
4858
		}
4885
		}
4859
	} while (slotpos == -1);
4886
	} while (slotpos == -1 && fnd_ok);
4887
	/*
4888
	 * If all slots are bad, just return slot 0 and NFSERR_SEQMISORDERED.
4889
	 * The caller will do a DestroySession, so that the session's use
4890
	 * will get a NFSERR_BADSESSION reply from the server.
4891
	 */
4892
	if (!fnd_ok)
4893
		slotpos = 0;
4894
4860
	/* Now, find the highest slot in use. (nfsc_slots is 64bits) */
4895
	/* Now, find the highest slot in use. (nfsc_slots is 64bits) */
4861
	bitval = 1;
4896
	bitval = 1;
4862
	for (i = 0; i < 64; i++) {
4897
	for (i = 0; i < 64; i++) {
Lines 4868-4873 nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsc Link Here
4868
	mtx_unlock(&sep->nfsess_mtx);
4903
	mtx_unlock(&sep->nfsess_mtx);
4869
	*slotposp = slotpos;
4904
	*slotposp = slotpos;
4870
	*maxslotp = maxslot;
4905
	*maxslotp = maxslot;
4906
4907
	if (!fnd_ok)
4908
{ printf("ret seqmis\n");
4909
		return (NFSERR_SEQMISORDERED);
4910
}
4871
	return (0);
4911
	return (0);
4872
}
4912
}
4873
4913
Lines 4983-4986 nfsm_add_ext_pgs(struct mbuf *m, int maxextsiz, int *b Link Here
4983
		mp = m;
5023
		mp = m;
4984
	}
5024
	}
4985
	return (mp);
5025
	return (mp);
5026
}
5027
5028
/*
5029
 * Do the NFSv4.1 Destroy Session.
5030
 */
5031
int
5032
nfsrpc_destroysession(struct nfsmount *nmp, struct nfsclsession *tsep,
5033
    struct ucred *cred, NFSPROC_T *p)
5034
{
5035
	uint32_t *tl;
5036
	struct nfsrv_descript nfsd;
5037
	struct nfsrv_descript *nd = &nfsd;
5038
	int error;
5039
5040
	nfscl_reqstart(nd, NFSPROC_DESTROYSESSION, nmp, NULL, 0, NULL, NULL, 0,
5041
	    0, NULL);
5042
	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID);
5043
	if (tsep == NULL)
5044
		tsep = nfsmnt_mdssession(nmp);
5045
	bcopy(tsep->nfsess_sessionid, tl, NFSX_V4SESSIONID);
5046
	nd->nd_flag |= ND_USEGSSNAME;
5047
	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
5048
	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
5049
	if (error != 0)
5050
		return (error);
5051
	error = nd->nd_repstat;
5052
	m_freem(nd->nd_mrep);
5053
	return (error);
4986
}
5054
}
(-)sys/fs/nfs/nfs_var.h (-4 / +5 lines)
Lines 315-321 void nfsrc_trimcache(uint64_t, uint32_t, int); Link Here
315
315
316
/* nfs_commonsubs.c */
316
/* nfs_commonsubs.c */
317
void nfscl_reqstart(struct nfsrv_descript *, int, struct nfsmount *,
317
void nfscl_reqstart(struct nfsrv_descript *, int, struct nfsmount *,
318
    u_int8_t *, int, u_int32_t **, struct nfsclsession *, int, int);
318
    u_int8_t *, int, u_int32_t **, struct nfsclsession *, int, int,
319
    struct ucred *);
319
void nfsm_stateidtom(struct nfsrv_descript *, nfsv4stateid_t *, int);
320
void nfsm_stateidtom(struct nfsrv_descript *, nfsv4stateid_t *, int);
320
void nfscl_fillsattr(struct nfsrv_descript *, struct vattr *,
321
void nfscl_fillsattr(struct nfsrv_descript *, struct vattr *,
321
      vnode_t, int, u_int32_t);
322
      vnode_t, int, u_int32_t);
Lines 355-363 int nfsv4_seqsession(uint32_t, uint32_t, uint32_t, str Link Here
355
    struct mbuf **, uint16_t);
356
    struct mbuf **, uint16_t);
356
void nfsv4_seqsess_cacherep(uint32_t, struct nfsslot *, int, struct mbuf **);
357
void nfsv4_seqsess_cacherep(uint32_t, struct nfsslot *, int, struct mbuf **);
357
void nfsv4_setsequence(struct nfsmount *, struct nfsrv_descript *,
358
void nfsv4_setsequence(struct nfsmount *, struct nfsrv_descript *,
358
    struct nfsclsession *, int);
359
    struct nfsclsession *, int, struct ucred *);
359
int nfsv4_sequencelookup(struct nfsmount *, struct nfsclsession *, int *,
360
int nfsv4_sequencelookup(struct nfsmount *, struct nfsclsession *, int *,
360
    int *, uint32_t *, uint8_t *);
361
    int *, uint32_t *, uint8_t *, bool);
361
void nfsv4_freeslot(struct nfsclsession *, int, bool);
362
void nfsv4_freeslot(struct nfsclsession *, int, bool);
362
struct ucred *nfsrv_getgrpscred(struct ucred *);
363
struct ucred *nfsrv_getgrpscred(struct ucred *);
363
struct nfsdevice *nfsv4_findmirror(struct nfsmount *);
364
struct nfsdevice *nfsv4_findmirror(struct nfsmount *);
Lines 529-535 int nfsrpc_exchangeid(struct nfsmount *, struct nfsclc Link Here
529
int nfsrpc_createsession(struct nfsmount *, struct nfsclsession *,
530
int nfsrpc_createsession(struct nfsmount *, struct nfsclsession *,
530
    struct nfssockreq *, struct nfsclds *, uint32_t, int, struct ucred *,
531
    struct nfssockreq *, struct nfsclds *, uint32_t, int, struct ucred *,
531
    NFSPROC_T *);
532
    NFSPROC_T *);
532
int nfsrpc_destroysession(struct nfsmount *, struct nfsclclient *,
533
int nfsrpc_destroysession(struct nfsmount *, struct nfsclsession *,
533
    struct ucred *, NFSPROC_T *);
534
    struct ucred *, NFSPROC_T *);
534
int nfsrpc_destroyclient(struct nfsmount *, struct nfsclclient *,
535
int nfsrpc_destroyclient(struct nfsmount *, struct nfsclclient *,
535
    struct ucred *, NFSPROC_T *);
536
    struct ucred *, NFSPROC_T *);
(-)sys/fs/nfsserver/nfs_nfsdstate.c (-1 / +1 lines)
Lines 6638-6644 nfsv4_setcbsequence(struct nfsrv_descript *nd, struct Link Here
6638
		return (error);
6638
		return (error);
6639
	sep = *sepp;
6639
	sep = *sepp;
6640
	(void)nfsv4_sequencelookup(NULL, &sep->sess_cbsess, slotposp, &maxslot,
6640
	(void)nfsv4_sequencelookup(NULL, &sep->sess_cbsess, slotposp, &maxslot,
6641
	    &slotseq, sessionid);
6641
	    &slotseq, sessionid, true);
6642
	KASSERT(maxslot >= 0, ("nfsv4_setcbsequence neg maxslot"));
6642
	KASSERT(maxslot >= 0, ("nfsv4_setcbsequence neg maxslot"));
6643
6643
6644
	/* Build the Sequence arguments. */
6644
	/* Build the Sequence arguments. */
(-)sys/fs/nfsserver/nfs_nfsdport.c (-7 / +7 lines)
Lines 5235-5241 nfsrv_readdsrpc(fhandle_t *fhp, off_t off, int len, st Link Here
5235
	st.other[2] = 0x55555555;
5235
	st.other[2] = 0x55555555;
5236
	st.seqid = 0xffffffff;
5236
	st.seqid = 0xffffffff;
5237
	nfscl_reqstart(nd, NFSPROC_READDS, nmp, (u_int8_t *)fhp, sizeof(*fhp),
5237
	nfscl_reqstart(nd, NFSPROC_READDS, nmp, (u_int8_t *)fhp, sizeof(*fhp),
5238
	    NULL, NULL, 0, 0);
5238
	    NULL, NULL, 0, 0, NULL);
5239
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
5239
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
5240
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED * 3);
5240
	NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED * 3);
5241
	txdr_hyper(off, tl);
5241
	txdr_hyper(off, tl);
Lines 5343-5349 nfsrv_writedsdorpc(struct nfsmount *nmp, fhandle_t *fh Link Here
5343
5343
5344
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
5344
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
5345
	nfscl_reqstart(nd, NFSPROC_WRITE, nmp, (u_int8_t *)fhp,
5345
	nfscl_reqstart(nd, NFSPROC_WRITE, nmp, (u_int8_t *)fhp,
5346
	    sizeof(fhandle_t), NULL, NULL, 0, 0);
5346
	    sizeof(fhandle_t), NULL, NULL, 0, 0, NULL);
5347
5347
5348
	/*
5348
	/*
5349
	 * Use a stateid where other is an alternating 01010 pattern and
5349
	 * Use a stateid where other is an alternating 01010 pattern and
Lines 5565-5571 nfsrv_allocatedsdorpc(struct nfsmount *nmp, fhandle_t Link Here
5565
5565
5566
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
5566
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
5567
	nfscl_reqstart(nd, NFSPROC_ALLOCATE, nmp, (u_int8_t *)fhp,
5567
	nfscl_reqstart(nd, NFSPROC_ALLOCATE, nmp, (u_int8_t *)fhp,
5568
	    sizeof(fhandle_t), NULL, NULL, 0, 0);
5568
	    sizeof(fhandle_t), NULL, NULL, 0, 0, NULL);
5569
5569
5570
	/*
5570
	/*
5571
	 * Use a stateid where other is an alternating 01010 pattern and
5571
	 * Use a stateid where other is an alternating 01010 pattern and
Lines 5719-5725 nfsrv_setattrdsdorpc(fhandle_t *fhp, struct ucred *cre Link Here
5719
	st.other[2] = 0x55555555;
5719
	st.other[2] = 0x55555555;
5720
	st.seqid = 0xffffffff;
5720
	st.seqid = 0xffffffff;
5721
	nfscl_reqstart(nd, NFSPROC_SETATTR, nmp, (u_int8_t *)fhp, sizeof(*fhp),
5721
	nfscl_reqstart(nd, NFSPROC_SETATTR, nmp, (u_int8_t *)fhp, sizeof(*fhp),
5722
	    NULL, NULL, 0, 0);
5722
	    NULL, NULL, 0, 0, NULL);
5723
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
5723
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
5724
	nfscl_fillsattr(nd, &nap->na_vattr, vp, NFSSATTR_FULL, 0);
5724
	nfscl_fillsattr(nd, &nap->na_vattr, vp, NFSSATTR_FULL, 0);
5725
5725
Lines 5904-5910 nfsrv_setacldsdorpc(fhandle_t *fhp, struct ucred *cred Link Here
5904
	st.other[2] = 0x55555555;
5904
	st.other[2] = 0x55555555;
5905
	st.seqid = 0xffffffff;
5905
	st.seqid = 0xffffffff;
5906
	nfscl_reqstart(nd, NFSPROC_SETACL, nmp, (u_int8_t *)fhp, sizeof(*fhp),
5906
	nfscl_reqstart(nd, NFSPROC_SETACL, nmp, (u_int8_t *)fhp, sizeof(*fhp),
5907
	    NULL, NULL, 0, 0);
5907
	    NULL, NULL, 0, 0, NULL);
5908
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
5908
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
5909
	NFSZERO_ATTRBIT(&attrbits);
5909
	NFSZERO_ATTRBIT(&attrbits);
5910
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
5910
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
Lines 6039-6045 nfsrv_getattrdsrpc(fhandle_t *fhp, struct ucred *cred, Link Here
6039
	NFSD_DEBUG(4, "in nfsrv_getattrdsrpc\n");
6039
	NFSD_DEBUG(4, "in nfsrv_getattrdsrpc\n");
6040
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
6040
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
6041
	nfscl_reqstart(nd, NFSPROC_GETATTR, nmp, (u_int8_t *)fhp,
6041
	nfscl_reqstart(nd, NFSPROC_GETATTR, nmp, (u_int8_t *)fhp,
6042
	    sizeof(fhandle_t), NULL, NULL, 0, 0);
6042
	    sizeof(fhandle_t), NULL, NULL, 0, 0, NULL);
6043
	NFSZERO_ATTRBIT(&attrbits);
6043
	NFSZERO_ATTRBIT(&attrbits);
6044
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_SIZE);
6044
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_SIZE);
6045
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_CHANGE);
6045
	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_CHANGE);
Lines 6107-6113 nfsrv_seekdsrpc(fhandle_t *fhp, off_t *offp, int conte Link Here
6107
	st.seqid = 0xffffffff;
6107
	st.seqid = 0xffffffff;
6108
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
6108
	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
6109
	nfscl_reqstart(nd, NFSPROC_SEEKDS, nmp, (u_int8_t *)fhp,
6109
	nfscl_reqstart(nd, NFSPROC_SEEKDS, nmp, (u_int8_t *)fhp,
6110
	    sizeof(fhandle_t), NULL, NULL, 0, 0);
6110
	    sizeof(fhandle_t), NULL, NULL, 0, 0, NULL);
6111
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
6111
	nfsm_stateidtom(nd, &st, NFSSTATEID_PUTSTATEID);
6112
	NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + NFSX_UNSIGNED);
6112
	NFSM_BUILD(tl, uint32_t *, NFSX_HYPER + NFSX_UNSIGNED);
6113
	txdr_hyper(*offp, tl); tl += 2;
6113
	txdr_hyper(*offp, tl); tl += 2;

Return to bug 260011