Lines 582-587
nfsrv_getclient(nfsquad_t clientid, int
Link Here
|
582 |
error = NFSERR_STALECLIENTID; |
582 |
error = NFSERR_STALECLIENTID; |
583 |
else if (nfsrv_notsamecredname(nd, clp)) |
583 |
else if (nfsrv_notsamecredname(nd, clp)) |
584 |
error = NFSERR_CLIDINUSE; |
584 |
error = NFSERR_CLIDINUSE; |
|
|
585 |
else if ((nd->nd_flag & ND_NFSV41) != 0 && nsep != NULL && |
586 |
clp->lc_sesscnt > NFSRV_MAXCLIENTSESS) |
587 |
{ printf("Too many sessions\n"); |
588 |
error = NFSERR_RESOURCE; |
589 |
} |
585 |
|
590 |
|
586 |
if (!error) { |
591 |
if (!error) { |
587 |
if ((clp->lc_flags & (LCL_NEEDSCONFIRM | LCL_DONTCLEAN)) == |
592 |
if ((clp->lc_flags & (LCL_NEEDSCONFIRM | LCL_DONTCLEAN)) == |
Lines 614-623
nfsrv_getclient(nfsquad_t clientid, int
Link Here
|
614 |
if (nsep != NULL) { |
619 |
if (nsep != NULL) { |
615 |
/* Hold a reference on the xprt for a backchannel. */ |
620 |
/* Hold a reference on the xprt for a backchannel. */ |
616 |
if ((nsep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) |
621 |
if ((nsep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) |
617 |
!= 0 && clp->lc_req.nr_client == NULL) { |
622 |
!= 0) { |
618 |
clp->lc_req.nr_client = (struct __rpc_client *) |
623 |
if (clp->lc_req.nr_client == NULL) |
619 |
clnt_bck_create(nd->nd_xprt->xp_socket, |
624 |
clp->lc_req.nr_client = (struct __rpc_client *) |
620 |
cbprogram, NFSV4_CBVERS); |
625 |
clnt_bck_create(nd->nd_xprt->xp_socket, |
|
|
626 |
cbprogram, NFSV4_CBVERS); |
621 |
if (clp->lc_req.nr_client != NULL) { |
627 |
if (clp->lc_req.nr_client != NULL) { |
622 |
SVC_ACQUIRE(nd->nd_xprt); |
628 |
SVC_ACQUIRE(nd->nd_xprt); |
623 |
nd->nd_xprt->xp_p2 = |
629 |
nd->nd_xprt->xp_p2 = |
Lines 638-643
nfsrv_getclient(nfsquad_t clientid, int
Link Here
|
638 |
LIST_INSERT_HEAD(&shp->list, nsep, sess_hash); |
644 |
LIST_INSERT_HEAD(&shp->list, nsep, sess_hash); |
639 |
LIST_INSERT_HEAD(&clp->lc_session, nsep, sess_list); |
645 |
LIST_INSERT_HEAD(&clp->lc_session, nsep, sess_list); |
640 |
nsep->sess_clp = clp; |
646 |
nsep->sess_clp = clp; |
|
|
647 |
clp->lc_sesscnt++; |
641 |
NFSUNLOCKSESSION(shp); |
648 |
NFSUNLOCKSESSION(shp); |
642 |
NFSUNLOCKSTATE(); |
649 |
NFSUNLOCKSTATE(); |
643 |
} |
650 |
} |
Lines 4248-4254
nfsrv_docallback(struct nfsclient *clp,
Link Here
|
4248 |
error = newnfs_request(nd, NULL, clp, &clp->lc_req, |
4255 |
error = newnfs_request(nd, NULL, clp, &clp->lc_req, |
4249 |
NULL, NULL, cred, clp->lc_program, |
4256 |
NULL, NULL, cred, clp->lc_program, |
4250 |
clp->lc_req.nr_vers, NULL, 1, NULL, NULL); |
4257 |
clp->lc_req.nr_vers, NULL, 1, NULL, NULL); |
4251 |
} |
4258 |
} else if ((nd->nd_flag & ND_NFSV41) != 0 && sep != NULL) |
|
|
4259 |
nfsrv_freesession(sep, NULL); |
4252 |
errout: |
4260 |
errout: |
4253 |
NFSFREECRED(cred); |
4261 |
NFSFREECRED(cred); |
4254 |
|
4262 |
|
Lines 5833-5839
nfsrv_checksequence(struct nfsrv_descrip
Link Here
|
5833 |
* RPC, since this is the one being used. |
5841 |
* RPC, since this is the one being used. |
5834 |
*/ |
5842 |
*/ |
5835 |
if (sep->sess_clp->lc_req.nr_client != NULL && |
5843 |
if (sep->sess_clp->lc_req.nr_client != NULL && |
5836 |
(sep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) != 0) { |
5844 |
sep->sess_cbsess.nfsess_xprt != nd->nd_xprt && |
|
|
5845 |
(sep->sess_crflags & (NFSV4CRSESS_CONNBACKCHAN | |
5846 |
NFSV4CRSESS_DONEBINDCONN)) == NFSV4CRSESS_CONNBACKCHAN) { |
5847 |
printf("implicit bind backchan\n"); |
5837 |
savxprt = sep->sess_cbsess.nfsess_xprt; |
5848 |
savxprt = sep->sess_cbsess.nfsess_xprt; |
5838 |
SVC_ACQUIRE(nd->nd_xprt); |
5849 |
SVC_ACQUIRE(nd->nd_xprt); |
5839 |
nd->nd_xprt->xp_p2 = |
5850 |
nd->nd_xprt->xp_p2 = |
Lines 5950-5955
nfsrv_destroysession(struct nfsrv_descri
Link Here
|
5950 |
} |
5961 |
} |
5951 |
|
5962 |
|
5952 |
/* |
5963 |
/* |
|
|
5964 |
* Bind a connection to a session. |
5965 |
* For now, only certain variants are supported, since the current session |
5966 |
* structure can only handle a single backchannel entry, which will be |
5967 |
* applied to all connections if it is set. |
5968 |
*/ |
5969 |
int |
5970 |
nfsrv_bindconnsess(struct nfsrv_descript *nd, uint8_t *sessionid, int *foreaftp) |
5971 |
{ |
5972 |
struct nfssessionhash *shp; |
5973 |
struct nfsdsession *sep; |
5974 |
struct nfsclient *clp; |
5975 |
SVCXPRT *savxprt; |
5976 |
int error; |
5977 |
|
5978 |
error = 0; |
5979 |
shp = NFSSESSIONHASH(sessionid); |
5980 |
NFSLOCKSESSION(shp); |
5981 |
sep = nfsrv_findsession(sessionid); |
5982 |
if (sep != NULL) { |
5983 |
clp = sep->sess_clp; |
5984 |
if (*foreaftp == NFSCDFC4_BACK || |
5985 |
*foreaftp == NFSCDFC4_BACK_OR_BOTH || |
5986 |
*foreaftp == NFSCDFC4_FORE_OR_BOTH) { |
5987 |
/* Try to set up a backchannel. */ |
5988 |
if (clp->lc_req.nr_client == NULL) |
5989 |
{ printf("nfsrv_bindconnsess: clnt_bck_create\n"); |
5990 |
clp->lc_req.nr_client = (struct __rpc_client *) |
5991 |
clnt_bck_create(nd->nd_xprt->xp_socket, |
5992 |
sep->sess_cbprogram, NFSV4_CBVERS); |
5993 |
} |
5994 |
if (clp->lc_req.nr_client != NULL) { |
5995 |
savxprt = sep->sess_cbsess.nfsess_xprt; |
5996 |
SVC_ACQUIRE(nd->nd_xprt); |
5997 |
nd->nd_xprt->xp_p2 = |
5998 |
clp->lc_req.nr_client->cl_private; |
5999 |
/* Disable idle timeout. */ |
6000 |
nd->nd_xprt->xp_idletimeout = 0; |
6001 |
sep->sess_cbsess.nfsess_xprt = nd->nd_xprt; |
6002 |
if (savxprt != NULL) |
6003 |
SVC_RELEASE(savxprt); |
6004 |
sep->sess_crflags |= (NFSV4CRSESS_CONNBACKCHAN | |
6005 |
NFSV4CRSESS_DONEBINDCONN); |
6006 |
if (*foreaftp == NFSCDFS4_BACK) |
6007 |
*foreaftp = NFSCDFS4_BACK; |
6008 |
else |
6009 |
*foreaftp = NFSCDFS4_BOTH; |
6010 |
printf("nfsrv_bindconnsess: Added backchannel\n"); |
6011 |
} else if (*foreaftp != NFSCDFC4_BACK) { |
6012 |
printf("nfsrv_bindconnsess: No backchannel\n"); |
6013 |
sep->sess_crflags &= ~NFSV4CRSESS_CONNBACKCHAN; |
6014 |
sep->sess_crflags |= NFSV4CRSESS_DONEBINDCONN; |
6015 |
*foreaftp = NFSCDFS4_FORE; |
6016 |
} else { |
6017 |
error = NFSERR_NOTSUPP; |
6018 |
printf("nfsrv_bindconnsess: Can't add " |
6019 |
"backchannel\n"); |
6020 |
} |
6021 |
} else { |
6022 |
printf("nfsrv_bindconnsess: Set forechannel\n"); |
6023 |
sep->sess_crflags |= NFSV4CRSESS_DONEBINDCONN; |
6024 |
*foreaftp = NFSCDFS4_FORE; |
6025 |
} |
6026 |
} else |
6027 |
error = NFSERR_BADSESSION; |
6028 |
NFSUNLOCKSESSION(shp); |
6029 |
return (error); |
6030 |
} |
6031 |
|
6032 |
/* |
5953 |
* Free up a session structure. |
6033 |
* Free up a session structure. |
5954 |
*/ |
6034 |
*/ |
5955 |
static int |
6035 |
static int |
Lines 5976-5981
nfsrv_freesession(struct nfsdsession *se
Link Here
|
5976 |
} |
6056 |
} |
5977 |
LIST_REMOVE(sep, sess_hash); |
6057 |
LIST_REMOVE(sep, sess_hash); |
5978 |
LIST_REMOVE(sep, sess_list); |
6058 |
LIST_REMOVE(sep, sess_list); |
|
|
6059 |
sep->sess_clp->lc_sesscnt--; |
5979 |
} |
6060 |
} |
5980 |
NFSUNLOCKSESSION(shp); |
6061 |
NFSUNLOCKSESSION(shp); |
5981 |
NFSUNLOCKSTATE(); |
6062 |
NFSUNLOCKSTATE(); |