diff options
-rw-r--r-- | sys/netsmb/smb_conn.c | 130 | ||||
-rw-r--r-- | sys/netsmb/smb_conn.h | 21 | ||||
-rw-r--r-- | sys/netsmb/smb_dev.c | 30 | ||||
-rw-r--r-- | sys/netsmb/smb_iod.c | 42 | ||||
-rw-r--r-- | sys/netsmb/smb_rq.c | 4 | ||||
-rw-r--r-- | sys/netsmb/smb_smb.c | 2 | ||||
-rw-r--r-- | sys/netsmb/smb_subr.c | 10 | ||||
-rw-r--r-- | sys/netsmb/smb_subr.h | 4 | ||||
-rw-r--r-- | sys/netsmb/smb_tran.h | 16 | ||||
-rw-r--r-- | sys/netsmb/smb_trantcp.c | 105 |
10 files changed, 188 insertions, 176 deletions
diff --git a/sys/netsmb/smb_conn.c b/sys/netsmb/smb_conn.c index 1d56d85..b58781f 100644 --- a/sys/netsmb/smb_conn.c +++ b/sys/netsmb/smb_conn.c @@ -61,9 +61,9 @@ SYSCTL_NODE(_net, OID_AUTO, smb, CTLFLAG_RW, NULL, "SMB protocol"); MALLOC_DEFINE(M_SMBCONN, "SMB conn", "SMB connection"); static void smb_co_init(struct smb_connobj *cp, int level, char *objname, - struct proc *p); + struct thread *td); static void smb_co_done(struct smb_connobj *cp); -static int smb_co_lockstatus(struct smb_connobj *cp, struct proc *p); +static int smb_co_lockstatus(struct smb_connobj *cp, struct thread *td); static int smb_vc_disconnect(struct smb_vc *vcp); static void smb_vc_free(struct smb_connobj *cp); @@ -80,8 +80,8 @@ int smb_sm_init(void) { - smb_co_init(&smb_vclist, SMBL_SM, "smbsm", curproc); - smb_co_unlock(&smb_vclist, 0, curproc); + smb_co_init(&smb_vclist, SMBL_SM, "smbsm", curthread); + smb_co_unlock(&smb_vclist, 0, curthread); return 0; } @@ -99,24 +99,24 @@ smb_sm_done(void) } static int -smb_sm_lockvclist(int flags, struct proc *p) +smb_sm_lockvclist(int flags, struct thread *td) { - return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE, p); + return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE, td); } static void -smb_sm_unlockvclist(struct proc *p) +smb_sm_unlockvclist(struct thread *td) { - smb_co_unlock(&smb_vclist, LK_RELEASE, p); + smb_co_unlock(&smb_vclist, LK_RELEASE, td); } static int smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_vc **vcpp) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct smb_vc *vcp; int exact = 1; int error; @@ -124,7 +124,7 @@ smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, vcspec->shspec = shspec; error = ENOENT; SMBCO_FOREACH((struct smb_connobj*)vcp, &smb_vclist) { - error = smb_vc_lock(vcp, LK_EXCLUSIVE, p); + error = smb_vc_lock(vcp, LK_EXCLUSIVE, td); if (error) continue; itry { @@ -156,14 +156,14 @@ smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, error = 0; break; } icatch(error) { - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); } ifinally { } iendtry; if (error == 0) break; } if (vcp) { - smb_vc_ref(vcp, p); + smb_vc_ref(vcp); *vcpp = vcp; } return error; @@ -173,19 +173,19 @@ int smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_vc **vcpp) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct smb_vc *vcp; struct smb_share *ssp = NULL; int error; *vcpp = vcp = NULL; - error = smb_sm_lockvclist(LK_EXCLUSIVE, p); + error = smb_sm_lockvclist(LK_EXCLUSIVE, td); if (error) return error; error = smb_sm_lookupint(vcspec, shspec, scred, vcpp); if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) { - smb_sm_unlockvclist(p); + smb_sm_unlockvclist(td); return error; } error = smb_sm_lookupint(vcspec, NULL, scred, &vcp); @@ -208,7 +208,7 @@ smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, else smb_share_put(ssp, scred); out: - smb_sm_unlockvclist(p); + smb_sm_unlockvclist(td); if (error == 0) *vcpp = vcp; else if (vcp) @@ -220,14 +220,14 @@ out: * Common code for connection object */ static void -smb_co_init(struct smb_connobj *cp, int level, char *objname, struct proc *p) +smb_co_init(struct smb_connobj *cp, int level, char *objname, struct thread *td) { SLIST_INIT(&cp->co_children); smb_sl_init(&cp->co_interlock, objname); lockinit(&cp->co_lock, PZERO, objname, 0, 0); cp->co_level = level; cp->co_usecount = 1; - KASSERT(smb_co_lock(cp, LK_EXCLUSIVE, p) == 0, ("smb_co_init: lock failed")); + KASSERT(smb_co_lock(cp, LK_EXCLUSIVE, td) == 0, ("smb_co_init: lock failed")); } static void @@ -246,7 +246,7 @@ smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred) cp->co_gone(cp, scred); parent = cp->co_parent; if (parent) { - smb_co_lock(parent, LK_EXCLUSIVE, scred->scr_p); + smb_co_lock(parent, LK_EXCLUSIVE, scred->scr_td); SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next); smb_co_put(parent, scred); } @@ -255,7 +255,7 @@ smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred) } void -smb_co_ref(struct smb_connobj *cp, struct proc *p) +smb_co_ref(struct smb_connobj *cp) { SMB_CO_LOCK(cp); @@ -266,7 +266,7 @@ smb_co_ref(struct smb_connobj *cp, struct proc *p) void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; SMB_CO_LOCK(cp); if (cp->co_usecount > 1) { @@ -282,7 +282,7 @@ smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred) cp->co_usecount--; cp->co_flags |= SMBO_GONE; - lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, &cp->co_interlock, p); + lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, &cp->co_interlock, td); smb_co_gone(cp, scred); } @@ -294,7 +294,7 @@ smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred) if ((flags & LK_INTERLOCK) == 0) SMB_CO_LOCK(cp); cp->co_usecount++; - error = smb_co_lock(cp, flags | LK_INTERLOCK, scred->scr_p); + error = smb_co_lock(cp, flags | LK_INTERLOCK, scred->scr_td); if (error) { SMB_CO_LOCK(cp); cp->co_usecount--; @@ -307,7 +307,7 @@ smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred) void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; int flags; flags = LK_RELEASE; @@ -321,48 +321,48 @@ smb_co_put(struct smb_connobj *cp, struct smb_cred *scred) } else { SMBERROR("negative usecount"); } - lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, &cp->co_interlock, p); + lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, &cp->co_interlock, td); if ((cp->co_flags & SMBO_GONE) == 0) return; - lockmgr(&cp->co_lock, LK_DRAIN, NULL, p); + lockmgr(&cp->co_lock, LK_DRAIN, NULL, td); smb_co_gone(cp, scred); } int -smb_co_lockstatus(struct smb_connobj *cp, struct proc *p) +smb_co_lockstatus(struct smb_connobj *cp, struct thread *td) { - return lockstatus(&cp->co_lock, p); + return lockstatus(&cp->co_lock, td); } int -smb_co_lock(struct smb_connobj *cp, int flags, struct proc *p) +smb_co_lock(struct smb_connobj *cp, int flags, struct thread *td) { if (cp->co_flags & SMBO_GONE) return EINVAL; if ((flags & LK_TYPE_MASK) == 0) flags |= LK_EXCLUSIVE; - if (smb_co_lockstatus(cp, p) == LK_EXCLUSIVE && + if (smb_co_lockstatus(cp, td) == LK_EXCLUSIVE && (flags & LK_CANRECURSE) == 0) { SMBERROR("recursive lock for object %d\n", cp->co_level); return 0; } - return lockmgr(&cp->co_lock, flags, &cp->co_interlock, p); + return lockmgr(&cp->co_lock, flags, &cp->co_interlock, td); } void -smb_co_unlock(struct smb_connobj *cp, int flags, struct proc *p) +smb_co_unlock(struct smb_connobj *cp, int flags, struct thread *td) { - (void)lockmgr(&cp->co_lock, flags | LK_RELEASE, &cp->co_interlock, p); + (void)lockmgr(&cp->co_lock, flags | LK_RELEASE, &cp->co_interlock, td); } static void smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child) { - KASSERT(smb_co_lockstatus(parent, curproc) == LK_EXCLUSIVE, ("smb_co_addchild: parent not locked")); - KASSERT(smb_co_lockstatus(child, curproc) == LK_EXCLUSIVE, ("smb_co_addchild: child not locked")); + KASSERT(smb_co_lockstatus(parent, curthread) == LK_EXCLUSIVE, ("smb_co_addchild: parent not locked")); + KASSERT(smb_co_lockstatus(child, curthread) == LK_EXCLUSIVE, ("smb_co_addchild: child not locked")); - smb_co_ref(parent, curproc); + smb_co_ref(parent); SLIST_INSERT_HEAD(&parent->co_children, child, co_next); child->co_parent = parent; } @@ -376,7 +376,7 @@ smb_vc_create(struct smb_vcspec *vcspec, struct smb_cred *scred, struct smb_vc **vcpp) { struct smb_vc *vcp; - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct ucred *cred = scred->scr_cred; uid_t uid = vcspec->owner; gid_t gid = vcspec->group; @@ -394,7 +394,7 @@ smb_vc_create(struct smb_vcspec *vcspec, return EPERM; vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK); - smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc", p); + smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc", td); vcp->obj.co_free = smb_vc_free; vcp->obj.co_gone = smb_vc_gone; vcp->vc_number = smb_vcnext++; @@ -488,9 +488,9 @@ smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred) } void -smb_vc_ref(struct smb_vc *vcp, struct proc *p) +smb_vc_ref(struct smb_vc *vcp) { - smb_co_ref(VCTOCP(vcp), p); + smb_co_ref(VCTOCP(vcp)); } void @@ -512,15 +512,15 @@ smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred) } int -smb_vc_lock(struct smb_vc *vcp, int flags, struct proc *p) +smb_vc_lock(struct smb_vc *vcp, int flags, struct thread *td) { - return smb_co_lock(VCTOCP(vcp), flags, p); + return smb_co_lock(VCTOCP(vcp), flags, td); } void -smb_vc_unlock(struct smb_vc *vcp, int flags, struct proc *p) +smb_vc_unlock(struct smb_vc *vcp, int flags, struct thread *td) { - smb_co_unlock(VCTOCP(vcp), flags, p); + smb_co_unlock(VCTOCP(vcp), flags, td); } int @@ -572,22 +572,22 @@ int smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp, struct smb_cred *scred, struct smb_share **sspp) { - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct smb_share *ssp = NULL; int error; *sspp = NULL; dp->scred = scred; SMBCO_FOREACH((struct smb_connobj*)ssp, VCTOCP(vcp)) { - error = smb_share_lock(ssp, LK_EXCLUSIVE, p); + error = smb_share_lock(ssp, LK_EXCLUSIVE, td); if (error) continue; if (smb_vc_cmpshare(ssp, dp) == 0) break; - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); } if (ssp) { - smb_share_ref(ssp, p); + smb_share_ref(ssp); *sspp = ssp; error = 0; } else @@ -666,7 +666,7 @@ smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_share **sspp) { struct smb_share *ssp; - struct proc *p = scred->scr_p; + struct thread *td = scred->scr_td; struct ucred *cred = scred->scr_cred; uid_t realuid = cred->cr_uid; uid_t uid = shspec->owner; @@ -691,7 +691,7 @@ smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, if (gid == SMBM_ANY_GROUP) gid = cred->cr_groups[0]; ssp = smb_zmalloc(sizeof(*ssp), M_SMBCONN, M_WAITOK); - smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss", p); + smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss", td); ssp->obj.co_free = smb_share_free; ssp->obj.co_gone = smb_share_gone; smb_sl_init(&ssp->ss_stlock, "ssstlock"); @@ -729,9 +729,9 @@ smb_share_gone(struct smb_connobj *cp, struct smb_cred *scred) } void -smb_share_ref(struct smb_share *ssp, struct proc *p) +smb_share_ref(struct smb_share *ssp) { - smb_co_ref(SSTOCP(ssp), p); + smb_co_ref(SSTOCP(ssp)); } void @@ -753,15 +753,15 @@ smb_share_put(struct smb_share *ssp, struct smb_cred *scred) } int -smb_share_lock(struct smb_share *ssp, int flags, struct proc *p) +smb_share_lock(struct smb_share *ssp, int flags, struct thread *td) { - return smb_co_lock(SSTOCP(ssp), flags, p); + return smb_co_lock(SSTOCP(ssp), flags, td); } void -smb_share_unlock(struct smb_share *ssp, int flags, struct proc *p) +smb_share_unlock(struct smb_share *ssp, int flags, struct thread *td) { - smb_co_unlock(SSTOCP(ssp), flags, p); + smb_co_unlock(SSTOCP(ssp), flags, td); } int @@ -825,7 +825,7 @@ smb_share_getinfo(struct smb_share *ssp, struct smb_share_info *sip) static int smb_sysctl_treedump(SYSCTL_HANDLER_ARGS) { - struct proc *p = req->p; + struct thread *td = req->td; struct smb_cred scred; struct smb_vc *vcp; struct smb_share *ssp; @@ -833,33 +833,33 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS) struct smb_share_info ssi; int error, itype; - smb_makescred(&scred, p, p->p_ucred); - error = smb_sm_lockvclist(LK_SHARED, p); + smb_makescred(&scred, td, td->td_proc->p_ucred); + error = smb_sm_lockvclist(LK_SHARED, td); if (error) return error; SMBCO_FOREACH((struct smb_connobj*)vcp, &smb_vclist) { - error = smb_vc_lock(vcp, LK_SHARED, p); + error = smb_vc_lock(vcp, LK_SHARED, td); if (error) continue; smb_vc_getinfo(vcp, &vci); error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info)); if (error) { - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); break; } SMBCO_FOREACH((struct smb_connobj*)ssp, VCTOCP(vcp)) { - error = smb_share_lock(ssp, LK_SHARED, p); + error = smb_share_lock(ssp, LK_SHARED, td); if (error) { error = 0; continue; } smb_share_getinfo(ssp, &ssi); - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info)); if (error) break; } - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); if (error) break; } @@ -867,6 +867,6 @@ smb_sysctl_treedump(SYSCTL_HANDLER_ARGS) itype = SMB_INFO_NONE; error = SYSCTL_OUT(req, &itype, sizeof(itype)); } - smb_sm_unlockvclist(p); + smb_sm_unlockvclist(td); return error; } diff --git a/sys/netsmb/smb_conn.h b/sys/netsmb/smb_conn.h index 33cb4d7..80d5abb 100644 --- a/sys/netsmb/smb_conn.h +++ b/sys/netsmb/smb_conn.h @@ -262,7 +262,6 @@ struct smb_vc { u_char vc_ch[SMB_MAXCHALLENGELEN]; u_short vc_mid; /* multiplex id */ struct smb_sopt vc_sopt; /* server options */ - struct smb_cred*vc_scred; /* used in reconnect procedure */ int vc_txmax; /* max tx/rx packet size */ struct smbiod * vc_iod; struct smb_slock vc_stlock; @@ -295,7 +294,6 @@ struct smb_share { int ss_vcgenid; char * ss_pass; /* password to a share, can be null */ struct smb_slock ss_stlock; - struct smb_cred *ss_cred; /* used in reconnect procedure */ }; #define ss_flags obj.co_flags @@ -354,12 +352,12 @@ int smb_sm_lookup(struct smb_vcspec *vcspec, /* * Connection object */ -void smb_co_ref(struct smb_connobj *cp, struct proc *p); +void smb_co_ref(struct smb_connobj *cp); void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred); int smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred); void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred); -int smb_co_lock(struct smb_connobj *cp, int flags, struct proc *p); -void smb_co_unlock(struct smb_connobj *cp, int flags, struct proc *p); +int smb_co_lock(struct smb_connobj *cp, int flags, struct thread *td); +void smb_co_unlock(struct smb_connobj *cp, int flags, struct thread *td); /* * session level functions @@ -370,10 +368,10 @@ int smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred); int smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode); int smb_vc_get(struct smb_vc *vcp, int flags, struct smb_cred *scred); void smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred); -void smb_vc_ref(struct smb_vc *vcp, struct proc *p); +void smb_vc_ref(struct smb_vc *vcp); void smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred); -int smb_vc_lock(struct smb_vc *vcp, int flags, struct proc *p); -void smb_vc_unlock(struct smb_vc *vcp, int flags, struct proc *p); +int smb_vc_lock(struct smb_vc *vcp, int flags, struct thread *td); +void smb_vc_unlock(struct smb_vc *vcp, int flags, struct thread *td); int smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_share **sspp); const char * smb_vc_getpass(struct smb_vc *vcp); @@ -385,12 +383,12 @@ u_short smb_vc_nextmid(struct smb_vc *vcp); int smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_share **sspp); int smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode); -void smb_share_ref(struct smb_share *ssp, struct proc *p); +void smb_share_ref(struct smb_share *ssp); void smb_share_rele(struct smb_share *ssp, struct smb_cred *scred); int smb_share_get(struct smb_share *ssp, int flags, struct smb_cred *scred); void smb_share_put(struct smb_share *ssp, struct smb_cred *scred); -int smb_share_lock(struct smb_share *ssp, int flags, struct proc *p); -void smb_share_unlock(struct smb_share *ssp, int flags, struct proc *p); +int smb_share_lock(struct smb_share *ssp, int flags, struct thread *td); +void smb_share_unlock(struct smb_share *ssp, int flags, struct thread *td); void smb_share_invalidate(struct smb_share *ssp); int smb_share_valid(struct smb_share *ssp); const char * smb_share_getpass(struct smb_share *ssp); @@ -442,6 +440,7 @@ struct smbiod { struct smb_rqhead iod_rqlist; /* list of outstanding requests */ int iod_muxwant; struct proc * iod_p; + struct thread * iod_td; struct smb_cred iod_scred; struct smb_slock iod_evlock; /* iod_evlist */ STAILQ_HEAD(,smbiod_event) iod_evlist; diff --git a/sys/netsmb/smb_dev.c b/sys/netsmb/smb_dev.c index f369a68..2a0f671 100644 --- a/sys/netsmb/smb_dev.c +++ b/sys/netsmb/smb_dev.c @@ -120,9 +120,10 @@ nsmb_dev_clone(void *arg, char *name, int namelen, dev_t *dev) } static int -nsmb_dev_open(dev_t dev, int oflags, int devtype, struct proc *p) +nsmb_dev_open(dev_t dev, int oflags, int devtype, struct thread *td) { struct smb_dev *sdp; + struct proc *p = td->td_proc; struct ucred *cred = p->p_ucred; int s; @@ -154,7 +155,7 @@ nsmb_dev_open(dev_t dev, int oflags, int devtype, struct proc *p) } static int -nsmb_dev_close(dev_t dev, int flag, int fmt, struct proc *p) +nsmb_dev_close(dev_t dev, int flag, int fmt, struct thread *td) { struct smb_dev *sdp; struct smb_vc *vcp; @@ -168,7 +169,7 @@ nsmb_dev_close(dev_t dev, int flag, int fmt, struct proc *p) splx(s); return EBADF; } - smb_makescred(&scred, p, NULL); + smb_makescred(&scred, td, NULL); ssp = sdp->sd_share; if (ssp != NULL) smb_share_rele(ssp, &scred); @@ -188,7 +189,7 @@ nsmb_dev_close(dev_t dev, int flag, int fmt, struct proc *p) static int -nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct smb_dev *sdp; struct smb_vc *vcp; @@ -200,7 +201,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if ((sdp->sd_flags & NSMBFL_OPEN) == 0) return EBADF; - smb_makescred(&scred, p, NULL); + smb_makescred(&scred, td, NULL); switch (cmd) { case SMBIOC_OPENSESSION: if (sdp->sd_vc) @@ -210,7 +211,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (error) break; sdp->sd_vc = vcp; - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); sdp->sd_level = SMBL_VC; break; case SMBIOC_OPENSHARE: @@ -223,7 +224,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (error) break; sdp->sd_share = ssp; - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); sdp->sd_level = SMBL_SHARE; break; case SMBIOC_REQUEST: @@ -252,7 +253,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) break; if (on && (vcp->obj.co_flags & SMBV_PERMANENT) == 0) { vcp->obj.co_flags |= SMBV_PERMANENT; - smb_vc_ref(vcp, p); + smb_vc_ref(vcp); } else if (!on && (vcp->obj.co_flags & SMBV_PERMANENT)) { vcp->obj.co_flags &= ~SMBV_PERMANENT; smb_vc_rele(vcp, &scred); @@ -270,7 +271,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) break; if (on && (ssp->obj.co_flags & SMBS_PERMANENT) == 0) { ssp->obj.co_flags |= SMBS_PERMANENT; - smb_share_ref(ssp, p); + smb_share_ref(ssp); } else if (!on && (ssp->obj.co_flags & SMBS_PERMANENT)) { ssp->obj.co_flags &= ~SMBS_PERMANENT; smb_share_rele(ssp, &scred); @@ -293,12 +294,12 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) break; if (vcp) { sdp->sd_vc = vcp; - smb_vc_unlock(vcp, 0, p); + smb_vc_unlock(vcp, 0, td); sdp->sd_level = SMBL_VC; } if (ssp) { sdp->sd_share = ssp; - smb_share_unlock(ssp, 0, p); + smb_share_unlock(ssp, 0, td); sdp->sd_level = SMBL_SHARE; } break; @@ -317,7 +318,7 @@ nsmb_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) auio.uio_resid = rwrq->ioc_cnt; auio.uio_segflg = UIO_USERSPACE; auio.uio_rw = (cmd == SMBIOC_READ) ? UIO_READ : UIO_WRITE; - auio.uio_procp = p; + auio.uio_td = td; if (cmd == SMBIOC_READ) error = smb_read(ssp, rwrq->ioc_fh, &auio, &scred); else @@ -344,7 +345,7 @@ nsmb_dev_write(dev_t dev, struct uio *uio, int flag) } static int -nsmb_dev_poll(dev_t dev, int events, struct proc *p) +nsmb_dev_poll(dev_t dev, int events, struct thread *td) { return ENODEV; } @@ -411,7 +412,8 @@ smb_dev2share(int fd, int mode, struct smb_cred *scred, dev_t dev; int error; - if ((fp = nsmb_getfp(scred->scr_p->p_fd, fd, FREAD | FWRITE)) == NULL) + fp = nsmb_getfp(scred->scr_td->td_proc->p_fd, fd, FREAD | FWRITE); + if (fp == NULL) return EBADF; vp = (struct vnode*)fp->f_data; if (vp == NULL) diff --git a/sys/netsmb/smb_iod.c b/sys/netsmb/smb_iod.c index f87d6e5..ff1919d 100644 --- a/sys/netsmb/smb_iod.c +++ b/sys/netsmb/smb_iod.c @@ -103,12 +103,12 @@ static void smb_iod_closetran(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; if (vcp->vc_tdata == NULL) return; - SMB_TRAN_DISCONNECT(vcp, p); - SMB_TRAN_DONE(vcp, p); + SMB_TRAN_DISCONNECT(vcp, td); + SMB_TRAN_DONE(vcp, td); vcp->vc_tdata = NULL; } @@ -124,7 +124,7 @@ static int smb_iod_connect(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; int error; SMBIODEBUG("%d\n", iod->iod_state); @@ -140,13 +140,13 @@ smb_iod_connect(struct smbiod *iod) vcp->vc_genid++; error = 0; itry { - ithrow(SMB_TRAN_CREATE(vcp, p)); + ithrow(SMB_TRAN_CREATE(vcp, td)); SMBIODEBUG("tcreate\n"); if (vcp->vc_laddr) { - ithrow(SMB_TRAN_BIND(vcp, vcp->vc_laddr, p)); + ithrow(SMB_TRAN_BIND(vcp, vcp->vc_laddr, td)); } SMBIODEBUG("tbind\n"); - ithrow(SMB_TRAN_CONNECT(vcp, vcp->vc_paddr, p)); + ithrow(SMB_TRAN_CONNECT(vcp, vcp->vc_paddr, td)); SMB_TRAN_SETPARAM(vcp, SMBTP_SELECTID, &iod->iod_flags); iod->iod_state = SMBIOD_ST_TRANACTIVE; SMBIODEBUG("tconnect\n"); @@ -208,7 +208,7 @@ smb_iod_treeconnect(struct smbiod *iod, struct smb_share *ssp) static int smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp) { - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; struct smb_vc *vcp = iod->iod_vc; struct smb_share *ssp = rqp->sr_share; struct mbuf *m; @@ -248,7 +248,7 @@ smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp) SMBSDEBUG("M:%04x, P:%04x, U:%04x, T:%04x\n", rqp->sr_mid, 0, 0, 0); m_dumpm(rqp->sr_rq.mb_top); m = m_copym(rqp->sr_rq.mb_top, 0, M_COPYALL, M_WAIT); - error = rqp->sr_lerror = m ? SMB_TRAN_SEND(vcp, m, p) : ENOBUFS; + error = rqp->sr_lerror = m ? SMB_TRAN_SEND(vcp, m, td) : ENOBUFS; if (error == 0) { getnanotime(&rqp->sr_timesent); iod->iod_lastrqsent = rqp->sr_timesent; @@ -277,7 +277,7 @@ static int smb_iod_recvall(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; - struct proc *p = iod->iod_p; + struct thread *td = iod->iod_td; struct smb_rq *rqp; struct mbuf *m; u_char *hp; @@ -294,7 +294,7 @@ smb_iod_recvall(struct smbiod *iod) } for (;;) { m = NULL; - error = SMB_TRAN_RECV(vcp, &m, p); + error = SMB_TRAN_RECV(vcp, &m, td); if (error == EWOULDBLOCK) break; if (SMB_TRAN_FATAL(vcp, error)) { @@ -355,7 +355,7 @@ smb_iod_recvall(struct smbiod *iod) */ SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { - if (smb_proc_intr(rqp->sr_cred->scr_p)) { + if (smb_proc_intr(rqp->sr_cred->scr_td->td_proc)) { smb_iod_rqprocessed(rqp, EINTR); } } @@ -399,7 +399,7 @@ smb_iod_addrq(struct smb_rq *rqp) int error; SMBIODEBUG("\n"); - if (rqp->sr_cred->scr_p == iod->iod_p) { + if (rqp->sr_cred->scr_td->td_proc == iod->iod_p) { rqp->sr_flags |= SMBR_INTERNAL; SMB_IOD_RQLOCK(iod); TAILQ_INSERT_HEAD(&iod->iod_rqlist, rqp, sr_link); @@ -631,20 +631,18 @@ smb_iod_main(struct smbiod *iod) return; } -#ifndef FB_CURRENT -#define kthread_create_compat kthread_create2 -#else -#define kthread_create_compat kthread_create -#endif - - void smb_iod_thread(void *arg) { struct smbiod *iod = arg; mtx_lock(&Giant); - smb_makescred(&iod->iod_scred, iod->iod_p, NULL); + /* + * Here we assume that the thread structure will be the same + * for an entire kthread (kproc, to be more precise) life. + */ + iod->iod_td = curthread; + smb_makescred(&iod->iod_scred, iod->iod_td, NULL); while ((iod->iod_flags & SMBIOD_SHUTDOWN) == 0) { smb_iod_main(iod); SMBIODEBUG("going to sleep for %d ticks\n", iod->iod_sleeptimo); @@ -675,7 +673,7 @@ smb_iod_create(struct smb_vc *vcp) TAILQ_INIT(&iod->iod_rqlist); smb_sl_init(&iod->iod_evlock, "90evl"); STAILQ_INIT(&iod->iod_evlist); - error = kthread_create_compat(smb_iod_thread, iod, &iod->iod_p, + error = kthread_create(smb_iod_thread, iod, &iod->iod_p, RFNOWAIT, "smbiod%d", iod->iod_id); if (error) { SMBERROR("can't start smbiod: %d", error); diff --git a/sys/netsmb/smb_rq.c b/sys/netsmb/smb_rq.c index 1a56943..36e2db9 100644 --- a/sys/netsmb/smb_rq.c +++ b/sys/netsmb/smb_rq.c @@ -180,7 +180,7 @@ smb_rq_enqueue(struct smb_rq *rqp) if (ssp->ss_flags & SMBS_RECONNECTING) { msleep(&ssp->ss_vcgenid, SMBS_ST_LOCKPTR(ssp), PWAIT | PDROP, "90trcn", hz); - if (smb_proc_intr(rqp->sr_cred->scr_p)) + if (smb_proc_intr(rqp->sr_cred->scr_td->td_proc)) return EINTR; continue; } @@ -244,7 +244,7 @@ smb_rq_bend(struct smb_rq *rqp) int smb_rq_intr(struct smb_rq *rqp) { - struct proc *p = rqp->sr_cred->scr_p; + struct proc *p = rqp->sr_cred->scr_td->td_proc; if (rqp->sr_flags & SMBR_INTR) return EINTR; diff --git a/sys/netsmb/smb_smb.c b/sys/netsmb/smb_smb.c index 0f3179d..242b941 100644 --- a/sys/netsmb/smb_smb.c +++ b/sys/netsmb/smb_smb.c @@ -74,7 +74,7 @@ static struct smb_dialect smb_dialects[] = { static int smb_smb_nomux(struct smb_vc *vcp, struct smb_cred *scred, const char *name) { - if (scred->scr_p == vcp->vc_iod->iod_p) + if (scred->scr_td->td_proc == vcp->vc_iod->iod_p) return 0; SMBERROR("wrong function called(%s)\n", name); return EINVAL; diff --git a/sys/netsmb/smb_subr.c b/sys/netsmb/smb_subr.c index a8f60fe..63b0d82 100644 --- a/sys/netsmb/smb_subr.c +++ b/sys/netsmb/smb_subr.c @@ -56,13 +56,13 @@ MALLOC_DEFINE(M_SMBTEMP, "SMBTEMP", "Temp netsmb data"); smb_unichar smb_unieol = 0; void -smb_makescred(struct smb_cred *scred, struct proc *p, struct ucred *cred) +smb_makescred(struct smb_cred *scred, struct thread *td, struct ucred *cred) { - if (p) { - scred->scr_p = p; - scred->scr_cred = cred ? cred : p->p_ucred; + if (td) { + scred->scr_td = td; + scred->scr_cred = cred ? cred : td->td_proc->p_ucred; } else { - scred->scr_p = NULL; + scred->scr_td = NULL; scred->scr_cred = cred ? cred : NULL; } } diff --git a/sys/netsmb/smb_subr.h b/sys/netsmb/smb_subr.h index f76b62f..8591893 100644 --- a/sys/netsmb/smb_subr.h +++ b/sys/netsmb/smb_subr.h @@ -130,7 +130,7 @@ typedef smb_unichar *smb_uniptr; * Crediantials of user/process being processing in the connection procedures */ struct smb_cred { - struct proc * scr_p; + struct thread * scr_td; struct ucred * scr_cred; }; @@ -140,7 +140,7 @@ struct mbchain; struct smb_vc; struct smb_rq; -void smb_makescred(struct smb_cred *scred, struct proc *p, struct ucred *cred); +void smb_makescred(struct smb_cred *scred, struct thread *td, struct ucred *cred); int smb_proc_intr(struct proc *); char *smb_strdup(const char *s); void *smb_memdup(const void *umem, int len); diff --git a/sys/netsmb/smb_tran.h b/sys/netsmb/smb_tran.h index 7403d21..0e7fc50 100644 --- a/sys/netsmb/smb_tran.h +++ b/sys/netsmb/smb_tran.h @@ -54,20 +54,20 @@ struct smb_tran_ops; struct smb_tran_desc { sa_family_t tr_type; - int (*tr_create)(struct smb_vc *vcp, struct proc *p); - int (*tr_done)(struct smb_vc *vcp, struct proc *p); - int (*tr_bind)(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p); - int (*tr_connect)(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p); - int (*tr_disconnect)(struct smb_vc *vcp, struct proc *p); - int (*tr_send)(struct smb_vc *vcp, struct mbuf *m0, struct proc *p); - int (*tr_recv)(struct smb_vc *vcp, struct mbuf **mpp, struct proc *p); + int (*tr_create)(struct smb_vc *vcp, struct thread *td); + int (*tr_done)(struct smb_vc *vcp, struct thread *td); + int (*tr_bind)(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td); + int (*tr_connect)(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td); + int (*tr_disconnect)(struct smb_vc *vcp, struct thread *td); + int (*tr_send)(struct smb_vc *vcp, struct mbuf *m0, struct thread *td); + int (*tr_recv)(struct smb_vc *vcp, struct mbuf **mpp, struct thread *td); void (*tr_timo)(struct smb_vc *vcp); void (*tr_intr)(struct smb_vc *vcp); int (*tr_getparam)(struct smb_vc *vcp, int param, void *data); int (*tr_setparam)(struct smb_vc *vcp, int param, void *data); int (*tr_fatal)(struct smb_vc *vcp, int error); #ifdef notyet - int (*tr_poll)(struct smb_vc *vcp, struct proc *p); + int (*tr_poll)(struct smb_vc *vcp, struct thread *td); int (*tr_cmpaddr)(void *addr1, void *addr2); #endif LIST_ENTRY(smb_tran_desc) tr_link; diff --git a/sys/netsmb/smb_trantcp.c b/sys/netsmb/smb_trantcp.c index 3d6b082..7c4d74b 100644 --- a/sys/netsmb/smb_trantcp.c +++ b/sys/netsmb/smb_trantcp.c @@ -70,12 +70,12 @@ SYSCTL_DECL(_net_smb); SYSCTL_INT(_net_smb, OID_AUTO, tcpsndbuf, CTLFLAG_RW, &smb_tcpsndbuf, 0, ""); SYSCTL_INT(_net_smb, OID_AUTO, tcprcvbuf, CTLFLAG_RW, &smb_tcprcvbuf, 0, ""); -#define nb_sosend(so,m,flags,p) (so)->so_proto->pr_usrreqs->pru_sosend( \ - so, NULL, 0, m, 0, flags, p) +#define nb_sosend(so,m,flags,td) (so)->so_proto->pr_usrreqs->pru_sosend( \ + so, NULL, 0, m, 0, flags, td) static int nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, - u_int8_t *rpcodep, struct proc *p); -static int smb_nbst_disconnect(struct smb_vc *vcp, struct proc *p); + u_int8_t *rpcodep, struct thread *td); +static int smb_nbst_disconnect(struct smb_vc *vcp, struct thread *td); static int nb_setsockopt_int(struct socket *so, int level, int name, int val) @@ -91,16 +91,18 @@ nb_setsockopt_int(struct socket *so, int level, int name, int val) } static __inline int -nb_poll(struct nbpcb *nbp, int events, struct proc *p) +nb_poll(struct nbpcb *nbp, int events, struct thread *td) { return nbp->nbp_tso->so_proto->pr_usrreqs->pru_sopoll(nbp->nbp_tso, - events, NULL, p); + events, NULL, td); } static int -nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, struct proc *p) +nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, + struct thread *td) { struct timeval atv, rtv, ttv; + struct proc *p; int timo, error; if (tv) { @@ -113,10 +115,13 @@ nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, struct proc *p) timevaladd(&atv, &rtv); } timo = 0; + p = td->td_proc; PROC_LOCK(p); - p->p_flag |= P_SELECT; + mtx_lock_spin(&sched_lock); + td->td_flags |= TDF_SELECT; + mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); - error = nb_poll(nbp, events, p); + error = nb_poll(nbp, events, td); PROC_LOCK(p); if (error) { error = 0; @@ -131,19 +136,24 @@ nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, struct proc *p) * the process, test P_SELECT and rescan file descriptors if * necessary. */ - if ((p->p_flag & P_SELECT) == 0) { - p->p_flag |= P_SELECT; + mtx_lock_spin(&sched_lock); + if ((td->td_flags & TDF_SELECT) == 0) { + td->td_flags |= TDF_SELECT; + mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); - error = nb_poll(nbp, events, p); + error = nb_poll(nbp, events, td); PROC_LOCK(p); - } + } else + mtx_unlock_spin(&sched_lock); goto done; } ttv = atv; timevalsub(&ttv, &rtv); timo = tvtohz(&ttv); } - p->p_flag &= ~P_SELECT; + mtx_lock_spin(&sched_lock); + td->td_flags &= ~TDF_SELECT; + mtx_unlock_spin(&sched_lock); if (timo > 0) error = cv_timedwait(&selwait, &p->p_mtx, timo); else { @@ -152,8 +162,11 @@ nbssn_rselect(struct nbpcb *nbp, struct timeval *tv, int events, struct proc *p) } done: + mtx_lock_spin(&sched_lock); + td->td_flags &= ~TDF_SELECT; + mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); - p->p_flag &= ~P_SELECT; + done_noproclock: if (error == ERESTART) return 0; @@ -208,12 +221,12 @@ nb_put_name(struct mbchain *mbp, struct sockaddr_nb *snb) } static int -nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct proc *p) +nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct thread *td) { struct socket *so; int error, s; - error = socreate(AF_INET, &so, SOCK_STREAM, IPPROTO_TCP, p); + error = socreate(AF_INET, &so, SOCK_STREAM, IPPROTO_TCP, td); if (error) return error; nbp->nbp_tso = so; @@ -229,14 +242,14 @@ nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct proc *p) nb_setsockopt_int(so, IPPROTO_TCP, TCP_NODELAY, 1); so->so_rcv.sb_flags &= ~SB_NOINTR; so->so_snd.sb_flags &= ~SB_NOINTR; - error = soconnect(so, (struct sockaddr*)to, p); + error = soconnect(so, (struct sockaddr*)to, td); if (error) goto bad; s = splnet(); while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { tsleep(&so->so_timeo, PSOCK, "nbcon", 2 * hz); if ((so->so_state & SS_ISCONNECTING) && so->so_error == 0 && - (error = nb_intr(nbp, p)) != 0) { + (error = nb_intr(nbp, td->td_proc)) != 0) { so->so_state &= ~SS_ISCONNECTING; splx(s); goto bad; @@ -251,12 +264,12 @@ nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct proc *p) splx(s); return 0; bad: - smb_nbst_disconnect(nbp->nbp_vc, p); + smb_nbst_disconnect(nbp->nbp_vc, td); return error; } static int -nbssn_rq_request(struct nbpcb *nbp, struct proc *p) +nbssn_rq_request(struct nbpcb *nbp, struct thread *td) { struct mbchain mb, *mbp = &mb; struct mdchain md, *mdp = &md; @@ -274,7 +287,7 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) nb_put_name(mbp, nbp->nbp_paddr); nb_put_name(mbp, nbp->nbp_laddr); nb_sethdr(mbp->mb_top, NB_SSN_REQUEST, mb_fixhdr(mbp) - 4); - error = nb_sosend(nbp->nbp_tso, mbp->mb_top, 0, p); + error = nb_sosend(nbp->nbp_tso, mbp->mb_top, 0, td); if (!error) { nbp->nbp_state = NBST_RQSENT; } @@ -283,14 +296,14 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) if (error) return error; TIMESPEC_TO_TIMEVAL(&tv, &nbp->nbp_timo); - error = nbssn_rselect(nbp, &tv, POLLIN, p); + error = nbssn_rselect(nbp, &tv, POLLIN, td); if (error == EWOULDBLOCK) { /* Timeout */ NBDEBUG("initial request timeout\n"); return ETIMEDOUT; } if (error) /* restart or interrupt */ return error; - error = nbssn_recv(nbp, &m0, &rplen, &rpcode, p); + error = nbssn_recv(nbp, &m0, &rplen, &rpcode, td); if (error) { NBDEBUG("recv() error %d\n", error); return error; @@ -319,12 +332,12 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) md_get_uint16(mdp, &port); sin.sin_port = port; nbp->nbp_state = NBST_RETARGET; - smb_nbst_disconnect(nbp->nbp_vc, p); - error = nb_connect_in(nbp, &sin, p); + smb_nbst_disconnect(nbp->nbp_vc, td); + error = nb_connect_in(nbp, &sin, td); if (!error) - error = nbssn_rq_request(nbp, p); + error = nbssn_rq_request(nbp, td); if (error) { - smb_nbst_disconnect(nbp->nbp_vc, p); + smb_nbst_disconnect(nbp->nbp_vc, td); break; } } while(0); @@ -335,7 +348,7 @@ nbssn_rq_request(struct nbpcb *nbp, struct proc *p) static int nbssn_recvhdr(struct nbpcb *nbp, int *lenp, - u_int8_t *rpcodep, int flags, struct proc *p) + u_int8_t *rpcodep, int flags, struct thread *td) { struct socket *so = nbp->nbp_tso; struct uio auio; @@ -351,7 +364,7 @@ nbssn_recvhdr(struct nbpcb *nbp, int *lenp, auio.uio_rw = UIO_READ; auio.uio_offset = 0; auio.uio_resid = sizeof(len); - auio.uio_procp = p; + auio.uio_td = td; error = so->so_proto->pr_usrreqs->pru_soreceive (so, (struct sockaddr **)NULL, &auio, (struct mbuf **)NULL, (struct mbuf **)NULL, &flags); @@ -374,7 +387,7 @@ nbssn_recvhdr(struct nbpcb *nbp, int *lenp, static int nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, - u_int8_t *rpcodep, struct proc *p) + u_int8_t *rpcodep, struct thread *td) { struct socket *so = nbp->nbp_tso; struct uio auio; @@ -390,7 +403,7 @@ nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, *mpp = NULL; for(;;) { m = NULL; - error = nbssn_recvhdr(nbp, &len, &rpcode, MSG_DONTWAIT, p); + error = nbssn_recvhdr(nbp, &len, &rpcode, MSG_DONTWAIT, td); if (so->so_state & (SS_ISDISCONNECTING | SS_ISDISCONNECTED | SS_CANTRCVMORE)) { nbp->nbp_state = NBST_CLOSED; @@ -405,7 +418,7 @@ nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, continue; bzero(&auio, sizeof(auio)); auio.uio_resid = len; - auio.uio_procp = p; + auio.uio_td = td; do { rcvflg = MSG_WAITALL; error = so->so_proto->pr_usrreqs->pru_soreceive @@ -445,7 +458,7 @@ nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp, * SMB transport interface */ static int -smb_nbst_create(struct smb_vc *vcp, struct proc *p) +smb_nbst_create(struct smb_vc *vcp, struct thread *td) { struct nbpcb *nbp; @@ -461,13 +474,13 @@ smb_nbst_create(struct smb_vc *vcp, struct proc *p) } static int -smb_nbst_done(struct smb_vc *vcp, struct proc *p) +smb_nbst_done(struct smb_vc *vcp, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; if (nbp == NULL) return ENOTCONN; - smb_nbst_disconnect(vcp, p); + smb_nbst_disconnect(vcp, td); if (nbp->nbp_laddr) free(nbp->nbp_laddr, M_SONAME); if (nbp->nbp_paddr) @@ -477,7 +490,7 @@ smb_nbst_done(struct smb_vc *vcp, struct proc *p) } static int -smb_nbst_bind(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) +smb_nbst_bind(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; struct sockaddr_nb *snb; @@ -510,7 +523,7 @@ smb_nbst_bind(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) } static int -smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) +smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; struct sockaddr_in sin; @@ -536,7 +549,7 @@ smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) nbp->nbp_paddr = snb; sin = snb->snb_addrin; getnanotime(&ts1); - error = nb_connect_in(nbp, &sin, p); + error = nb_connect_in(nbp, &sin, td); if (error) return error; getnanotime(&ts2); @@ -547,14 +560,14 @@ smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct proc *p) timespecadd(&nbp->nbp_timo, &ts2); timespecadd(&nbp->nbp_timo, &ts2); timespecadd(&nbp->nbp_timo, &ts2); /* * 4 */ - error = nbssn_rq_request(nbp, p); + error = nbssn_rq_request(nbp, td); if (error) - smb_nbst_disconnect(vcp, p); + smb_nbst_disconnect(vcp, td); return error; } static int -smb_nbst_disconnect(struct smb_vc *vcp, struct proc *p) +smb_nbst_disconnect(struct smb_vc *vcp, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; struct socket *so; @@ -574,7 +587,7 @@ smb_nbst_disconnect(struct smb_vc *vcp, struct proc *p) } static int -smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct proc *p) +smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; int error; @@ -587,7 +600,7 @@ smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct proc *p) if (m0 == NULL) return ENOBUFS; nb_sethdr(m0, NB_SSN_MESSAGE, m_fixhdr(m0) - 4); - error = nb_sosend(nbp->nbp_tso, m0, 0, p); + error = nb_sosend(nbp->nbp_tso, m0, 0, td); return error; abort: if (m0) @@ -597,14 +610,14 @@ abort: static int -smb_nbst_recv(struct smb_vc *vcp, struct mbuf **mpp, struct proc *p) +smb_nbst_recv(struct smb_vc *vcp, struct mbuf **mpp, struct thread *td) { struct nbpcb *nbp = vcp->vc_tdata; u_int8_t rpcode; int error, rplen; nbp->nbp_flags |= NBF_RECVLOCK; - error = nbssn_recv(nbp, mpp, &rplen, &rpcode, p); + error = nbssn_recv(nbp, mpp, &rplen, &rpcode, td); nbp->nbp_flags &= ~NBF_RECVLOCK; return error; } |