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

Collapse All | Expand All

(-)sys/fs/nfs/nfsport.h (-3 / +7 lines)
Lines 412-421 Link Here
412
#define	NFSPROC_RMEXTATTR	63
412
#define	NFSPROC_RMEXTATTR	63
413
#define	NFSPROC_LISTEXTATTR	64
413
#define	NFSPROC_LISTEXTATTR	64
414
414
415
/* BindConnectionToSession, done by the krpc for a new connection. */
416
#define	NFSPROC_BINDCONNTOSESS	65
417
415
/*
418
/*
416
 * Must be defined as one higher than the last NFSv4.2 Proc# above.
419
 * Must be defined as one higher than the last NFSv4.2 Proc# above.
417
 */
420
 */
418
#define	NFSV42_NPROCS		65
421
#define	NFSV42_NPROCS		66
419
422
420
#endif	/* NFS_V3NPROCS */
423
#endif	/* NFS_V3NPROCS */
421
424
Lines 444-450 struct nfsstatsv1 { Link Here
444
	uint64_t	readlink_bios;
447
	uint64_t	readlink_bios;
445
	uint64_t	biocache_readdirs;
448
	uint64_t	biocache_readdirs;
446
	uint64_t	readdir_bios;
449
	uint64_t	readdir_bios;
447
	uint64_t	rpccnt[NFSV42_NPROCS + 15];
450
	uint64_t	rpccnt[NFSV42_NPROCS + 14];
448
	uint64_t	rpcretries;
451
	uint64_t	rpcretries;
449
	uint64_t	srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15];
452
	uint64_t	srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15];
450
	uint64_t	reserved_0;
453
	uint64_t	reserved_0;
Lines 509-515 struct nfsstatsov1 { Link Here
509
	uint64_t	readlink_bios;
512
	uint64_t	readlink_bios;
510
	uint64_t	biocache_readdirs;
513
	uint64_t	biocache_readdirs;
511
	uint64_t	readdir_bios;
514
	uint64_t	readdir_bios;
512
	uint64_t	rpccnt[NFSV42_NPROCS + 4];
515
	uint64_t	rpccnt[NFSV42_NPROCS + 3];
513
	uint64_t	rpcretries;
516
	uint64_t	rpcretries;
514
	uint64_t	srvrpccnt[NFSV42_PURENOPS + NFSV4OP_FAKENOPS];
517
	uint64_t	srvrpccnt[NFSV42_PURENOPS + NFSV4OP_FAKENOPS];
515
	uint64_t	reserved_0;
518
	uint64_t	reserved_0;
Lines 1006-1011 bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsi Link Here
1006
 * "out by one" without disastrous consequences.
1009
 * "out by one" without disastrous consequences.
1007
 */
1010
 */
1008
#define	NFSINCRGLOBAL(a)	((a)++)
1011
#define	NFSINCRGLOBAL(a)	((a)++)
1012
#define	NFSDECRGLOBAL(a)	((a)--)
1009
1013
1010
/*
1014
/*
1011
 * Assorted funky stuff to make things work under Darwin8.
1015
 * Assorted funky stuff to make things work under Darwin8.
(-)sys/fs/nfs/nfsproto.h (-1 / +4 lines)
Lines 394-403 Link Here
394
#define	NFSPROC_RMEXTATTR	63
394
#define	NFSPROC_RMEXTATTR	63
395
#define	NFSPROC_LISTEXTATTR	64
395
#define	NFSPROC_LISTEXTATTR	64
396
396
397
/* BindConnectionToSession, done by the krpc for a new connection. */
398
#define	NFSPROC_BINDCONNTOSESS	65
399
397
/*
400
/*
398
 * Must be defined as one higher than the last NFSv4.2 Proc# above.
401
 * Must be defined as one higher than the last NFSv4.2 Proc# above.
399
 */
402
 */
400
#define	NFSV42_NPROCS		65
403
#define	NFSV42_NPROCS		66
401
404
402
#endif	/* NFS_V3NPROCS */
405
#endif	/* NFS_V3NPROCS */
403
406
(-)sys/fs/nfs/nfs_var.h (+1 lines)
Lines 561-566 int nfsrpc_listextattr(vnode_t, uint64_t *, struct uio Link Here
561
    struct nfsvattr *, int *, struct ucred *, NFSPROC_T *);
561
    struct nfsvattr *, int *, struct ucred *, NFSPROC_T *);
562
int nfsrpc_rmextattr(vnode_t, const char *, struct nfsvattr *, int *,
562
int nfsrpc_rmextattr(vnode_t, const char *, struct nfsvattr *, int *,
563
    struct ucred *, NFSPROC_T *);
563
    struct ucred *, NFSPROC_T *);
564
void nfsrpc_bindconnsess(CLIENT *, void *, struct ucred *);
564
565
565
/* nfs_clstate.c */
566
/* nfs_clstate.c */
566
int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int,
567
int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int,
(-)sys/fs/nfs/nfs_commonsubs.c (-2 / +3 lines)
Lines 218-224 static struct nfsrv_lughash *nfsgroupnamehash; Link Here
218
static int nfs_bigreply[NFSV42_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0,
218
static int nfs_bigreply[NFSV42_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0,
219
    0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
219
    0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
220
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
220
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
221
    1, 0, 0, 1 };
221
    1, 0, 0, 1, 0 };
222
222
223
/* local functions */
223
/* local functions */
224
static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep);
224
static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep);
Lines 301-306 static struct { Link Here
301
	{ NFSV4OP_SETXATTR, 2, "Setxattr", 8, },
301
	{ NFSV4OP_SETXATTR, 2, "Setxattr", 8, },
302
	{ NFSV4OP_REMOVEXATTR, 2, "Rmxattr", 7, },
302
	{ NFSV4OP_REMOVEXATTR, 2, "Rmxattr", 7, },
303
	{ NFSV4OP_LISTXATTRS, 2, "Listxattr", 9, },
303
	{ NFSV4OP_LISTXATTRS, 2, "Listxattr", 9, },
304
	{ NFSV4OP_BINDCONNTOSESS, 1, "BindConSess", 11, },
304
};
305
};
305
306
306
/*
307
/*
Lines 309-315 static struct { Link Here
309
static int nfs_bigrequest[NFSV42_NPROCS] = {
310
static int nfs_bigrequest[NFSV42_NPROCS] = {
310
	0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
311
	0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
311
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
312
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
312
	0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
313
	0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0
313
};
314
};
314
315
315
/*
316
/*
(-)sys/fs/nfs/nfscl.h (+5 lines)
Lines 81-84 struct nfsv4node { Link Here
81
			printf(__VA_ARGS__);				\
81
			printf(__VA_ARGS__);				\
82
	} while (0)
82
	} while (0)
83
83
84
struct nfscl_reconarg {
85
	int	minorvers;
86
	uint8_t	sessionid[NFSX_V4SESSIONID];
87
};
88
84
#endif	/* _NFS_NFSCL_H */
89
#endif	/* _NFS_NFSCL_H */
(-)sys/fs/nfsclient/nfs_clrpcops.c (+91 lines)
Lines 946-951 nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli Link Here
946
	struct nfsclds *dsp, *odsp;
946
	struct nfsclds *dsp, *odsp;
947
	struct in6_addr a6;
947
	struct in6_addr a6;
948
	struct nfsclsession *tsep;
948
	struct nfsclsession *tsep;
949
	struct rpc_reconupcall recon;
950
	struct nfscl_reconarg *rcp;
949
951
950
	if (nfsboottime.tv_sec == 0)
952
	if (nfsboottime.tv_sec == 0)
951
		NFSSETBOOTTIME(nfsboottime);
953
		NFSSETBOOTTIME(nfsboottime);
Lines 1019-1024 nfsrpc_setclient(struct nfsmount *nmp, struct nfsclcli Link Here
1019
			NFSCL_DEBUG(1, "aft createsess=%d\n", error);
1021
			NFSCL_DEBUG(1, "aft createsess=%d\n", error);
1020
		}
1022
		}
1021
		if (error == 0) {
1023
		if (error == 0) {
1024
			/*
1025
			 * If the session supports a backchannel, set up
1026
			 * the BindConnectionToSession call in the krpc
1027
			 * so that it is done on a reconnection.
1028
			 */
1029
			if (nfscl_enablecallb != 0 && nfs_numnfscbd > 0) {
1030
				rcp = mem_alloc(sizeof(*rcp));
1031
				rcp->minorvers = nmp->nm_minorvers;
1032
				memcpy(rcp->sessionid,
1033
				    dsp->nfsclds_sess.nfsess_sessionid,
1034
				    NFSX_V4SESSIONID);
1035
				recon.call = nfsrpc_bindconnsess;
1036
				recon.arg = rcp;
1037
				CLNT_CONTROL(nmp->nm_client, CLSET_RECONUPCALL,
1038
				    &recon);
1039
			}
1040
1022
			NFSLOCKMNT(nmp);
1041
			NFSLOCKMNT(nmp);
1023
			/*
1042
			/*
1024
			 * The old sessions cannot be safely free'd
1043
			 * The old sessions cannot be safely free'd
Lines 8709-8711 nfsm_split(struct mbuf *mp, uint64_t xfer) Link Here
8709
	m->m_next = NULL;
8728
	m->m_next = NULL;
8710
	return (m2);
8729
	return (m2);
8711
}
8730
}
8731
8732
/*
8733
 * Do the NFSv4.1 Bind Connection to Session.
8734
 * Called from the reconnect layer of the krpc (sys/rpc/clnt_rc.c).
8735
 */
8736
void
8737
nfsrpc_bindconnsess(CLIENT *cl, void *arg, struct ucred *cr)
8738
{
8739
	struct nfscl_reconarg *rcp = (struct nfscl_reconarg *)arg;
8740
	uint32_t res, *tl;
8741
	struct nfsrv_descript nfsd;
8742
	struct nfsrv_descript *nd = &nfsd;
8743
	struct rpc_callextra ext;
8744
	struct timeval utimeout;
8745
	enum clnt_stat stat;
8746
	int error;
8747
8748
	nfscl_reqstart(nd, NFSPROC_BINDCONNTOSESS, NULL, NULL, 0, NULL, NULL,
8749
	    NFS_VER4, rcp->minorvers);
8750
	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 2 * NFSX_UNSIGNED);
8751
	memcpy(tl, rcp->sessionid, NFSX_V4SESSIONID);
8752
	tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
8753
	*tl++ = txdr_unsigned(NFSCDFC4_FORE_OR_BOTH);
8754
	*tl = newnfs_false;
8755
8756
	memset(&ext, 0, sizeof(ext));
8757
	utimeout.tv_sec = 30;
8758
	utimeout.tv_usec = 0;
8759
	ext.rc_auth = authunix_create(cr);
8760
	nd->nd_mrep = NULL;
8761
	stat = CLNT_CALL_MBUF(cl, &ext, NFSV4PROC_COMPOUND, nd->nd_mreq,
8762
	    &nd->nd_mrep, utimeout);
8763
	AUTH_DESTROY(ext.rc_auth);
8764
	if (stat != RPC_SUCCESS) {
8765
		printf("nfsrpc_bindconnsess: call failed stat=%d\n", stat);
8766
		return;
8767
	}
8768
	if (nd->nd_mrep == NULL) {
8769
		printf("nfsrpc_bindconnsess: no reply args\n");
8770
		return;
8771
	}
8772
	error = 0;
8773
	newnfs_realign(&nd->nd_mrep, M_WAITOK);
8774
	nd->nd_md = nd->nd_mrep;
8775
	nd->nd_dpos = mtod(nd->nd_md, char *);
8776
	NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED);
8777
	nd->nd_repstat = fxdr_unsigned(uint32_t, *tl++);
8778
	if (nd->nd_repstat == NFSERR_OK) {
8779
		res = fxdr_unsigned(uint32_t, *tl);
8780
		if (res > 0 && (error = nfsm_advance(nd, NFSM_RNDUP(res),
8781
		    -1)) != 0)
8782
			goto nfsmout;
8783
		NFSM_DISSECT(tl, uint32_t *, NFSX_V4SESSIONID +
8784
		    4 * NFSX_UNSIGNED);
8785
		tl += 3;
8786
		if (!NFSBCMP(tl, rcp->sessionid, NFSX_V4SESSIONID)) {
8787
			tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
8788
			res = fxdr_unsigned(uint32_t, *tl);
8789
			if (res != NFSCDFS4_BOTH)
8790
				printf("nfsrpc_bindconnsess: did not "
8791
				    "return FS4_BOTH\n");
8792
		} else
8793
			printf("nfsrpc_bindconnsess: not same "
8794
			    "sessionid\n");
8795
	} else
8796
		printf("nfsrpc_bindconnsess: returned %d\n", nd->nd_repstat);
8797
nfsmout:
8798
	if (error != 0)
8799
		printf("nfsrpc_bindconnsess: reply bad xdr\n");
8800
	m_freem(nd->nd_mrep);
8801
}
8802
(-)sys/rpc/krpc.h (+3 lines)
Lines 81-86 struct rc_data { Link Here
81
	void			*rc_backchannel;
81
	void			*rc_backchannel;
82
	bool			rc_tls; /* Enable TLS on connection */
82
	bool			rc_tls; /* Enable TLS on connection */
83
	char			*rc_tlscertname;
83
	char			*rc_tlscertname;
84
	void			(*rc_reconcall)(CLIENT *, void *,
85
				    struct ucred *); /* reconection upcall */
86
	void			*rc_reconarg;	/* upcall arg */
84
};
87
};
85
88
86
/* Bits for ct_rcvstate. */
89
/* Bits for ct_rcvstate. */
(-)sys/rpc/clnt.h (+6 lines)
Lines 360-365 enum clnt_stat clnt_call_private(CLIENT *, struct rpc_ Link Here
360
#define	CLSET_TLS		30	/* set TLS for socket */
360
#define	CLSET_TLS		30	/* set TLS for socket */
361
#define	CLSET_BLOCKRCV		31	/* Temporarily block reception */
361
#define	CLSET_BLOCKRCV		31	/* Temporarily block reception */
362
#define	CLSET_TLSCERTNAME	32	/* TLS certificate file name */
362
#define	CLSET_TLSCERTNAME	32	/* TLS certificate file name */
363
/* Structure used as the argument for CLSET_RECONUPCALL. */
364
struct rpc_reconupcall {
365
	void	(*call)(CLIENT *, void *, struct ucred *);
366
	void	*arg;
367
};
368
#define	CLSET_RECONUPCALL	33	/* Reconnect upcall */
363
#endif
369
#endif
364
370
365
371
(-)sys/rpc/clnt_rc.c (+15 lines)
Lines 111-116 clnt_reconnect_create( Link Here
111
	rc->rc_client = NULL;
111
	rc->rc_client = NULL;
112
	rc->rc_tls = false;
112
	rc->rc_tls = false;
113
	rc->rc_tlscertname = NULL;
113
	rc->rc_tlscertname = NULL;
114
	rc->rc_reconcall = NULL;
115
	rc->rc_reconarg = NULL;
114
116
115
	cl->cl_refs = 1;
117
	cl->cl_refs = 1;
116
	cl->cl_ops = &clnt_reconnect_ops;
118
	cl->cl_ops = &clnt_reconnect_ops;
Lines 213-218 clnt_reconnect_connect(CLIENT *cl) Link Here
213
				goto out;
215
				goto out;
214
			}
216
			}
215
		}
217
		}
218
		if (newclient != NULL && rc->rc_reconcall != NULL)
219
			(*rc->rc_reconcall)(newclient, rc->rc_reconarg,
220
			    rc->rc_ucred);
216
	}
221
	}
217
	td->td_ucred = oldcred;
222
	td->td_ucred = oldcred;
218
223
Lines 408-413 clnt_reconnect_control(CLIENT *cl, u_int request, void Link Here
408
	struct rc_data *rc = (struct rc_data *)cl->cl_private;
413
	struct rc_data *rc = (struct rc_data *)cl->cl_private;
409
	SVCXPRT *xprt;
414
	SVCXPRT *xprt;
410
	size_t slen;
415
	size_t slen;
416
	struct rpc_reconupcall *upcp;
411
417
412
	if (info == NULL) {
418
	if (info == NULL) {
413
		return (FALSE);
419
		return (FALSE);
Lines 513-518 clnt_reconnect_control(CLIENT *cl, u_int request, void Link Here
513
		strlcpy(rc->rc_tlscertname, info, slen);
519
		strlcpy(rc->rc_tlscertname, info, slen);
514
		break;
520
		break;
515
521
522
	case CLSET_RECONUPCALL:
523
		upcp = (struct rpc_reconupcall *)info;
524
		rc->rc_reconcall = upcp->call;
525
		rc->rc_reconarg = upcp->arg;
526
		break;
527
516
	default:
528
	default:
517
		return (FALSE);
529
		return (FALSE);
518
	}
530
	}
Lines 555-566 clnt_reconnect_destroy(CLIENT *cl) Link Here
555
		CLNT_DESTROY(rc->rc_client);
567
		CLNT_DESTROY(rc->rc_client);
556
	if (rc->rc_backchannel) {
568
	if (rc->rc_backchannel) {
557
		xprt = (SVCXPRT *)rc->rc_backchannel;
569
		xprt = (SVCXPRT *)rc->rc_backchannel;
570
		KASSERT(xprt->xp_socket == NULL,
571
		    ("clnt_reconnect_destroy: xp_socket not NULL"));
558
		xprt_unregister(xprt);
572
		xprt_unregister(xprt);
559
		SVC_RELEASE(xprt);
573
		SVC_RELEASE(xprt);
560
	}
574
	}
561
	crfree(rc->rc_ucred);
575
	crfree(rc->rc_ucred);
562
	mtx_destroy(&rc->rc_lock);
576
	mtx_destroy(&rc->rc_lock);
563
	mem_free(rc->rc_tlscertname, 0);	/* 0 ok, since arg. ignored. */
577
	mem_free(rc->rc_tlscertname, 0);	/* 0 ok, since arg. ignored. */
578
	mem_free(rc->rc_reconarg, 0);
564
	mem_free(rc, sizeof(*rc));
579
	mem_free(rc, sizeof(*rc));
565
	mem_free(cl, sizeof (CLIENT));
580
	mem_free(cl, sizeof (CLIENT));
566
}
581
}

Return to bug 254840