Index: head/sys/netsmb/smb_conn.c =================================================================== --- head/sys/netsmb/smb_conn.c (revision 291034) +++ head/sys/netsmb/smb_conn.c (revision 291035) @@ -1,966 +1,968 @@ /*- * Copyright (c) 2000-2001 Boris Popov * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Connection engine. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static struct smb_connobj smb_vclist; static int smb_vcnext = 1; /* next unique id for VC */ SYSCTL_NODE(_net, OID_AUTO, smb, CTLFLAG_RW, NULL, "SMB protocol"); static MALLOC_DEFINE(M_SMBCONN, "smb_conn", "SMB connection"); static void smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname); static void smb_co_done(struct smb_connobj *cp); static int smb_vc_disconnect(struct smb_vc *vcp); static void smb_vc_free(struct smb_connobj *cp); static void smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred); static smb_co_free_t smb_share_free; static smb_co_gone_t smb_share_gone; static int smb_sysctl_treedump(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_net_smb, OID_AUTO, treedump, CTLFLAG_RD | CTLTYPE_OPAQUE, NULL, 0, smb_sysctl_treedump, "S,treedump", "Requester tree"); int smb_sm_init(void) { smb_co_init(&smb_vclist, SMBL_SM, "smbsm ilock", "smbsm"); sx_xlock(&smb_vclist.co_interlock); smb_co_unlock(&smb_vclist); sx_unlock(&smb_vclist.co_interlock); return 0; } int smb_sm_done(void) { /* XXX: hold the mutex */ if (smb_vclist.co_usecount > 1) { SMBERROR("%d connections still active\n", smb_vclist.co_usecount - 1); return EBUSY; } smb_co_done(&smb_vclist); return 0; } static int smb_sm_lockvclist(void) { int error; sx_xlock(&smb_vclist.co_interlock); error = smb_co_lock(&smb_vclist); sx_unlock(&smb_vclist.co_interlock); return error; } static void smb_sm_unlockvclist(void) { sx_xlock(&smb_vclist.co_interlock); smb_co_unlock(&smb_vclist); sx_unlock(&smb_vclist.co_interlock); } static int smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_vc **vcpp) { struct smb_connobj *scp; struct smb_vc *vcp; int exact = 1; int error; vcspec->shspec = shspec; error = ENOENT; vcp = NULL; SMBCO_FOREACH(scp, &smb_vclist) { vcp = (struct smb_vc *)scp; error = smb_vc_lock(vcp); if (error) continue; if ((vcp->obj.co_flags & SMBV_PRIVATE) || !CONNADDREQ(vcp->vc_paddr, vcspec->sap) || strcmp(vcp->vc_username, vcspec->username) != 0) goto err1; if (vcspec->owner != SMBM_ANY_OWNER) { if (vcp->vc_uid != vcspec->owner) goto err1; } else exact = 0; if (vcspec->group != SMBM_ANY_GROUP) { if (vcp->vc_grp != vcspec->group) goto err1; } else exact = 0; if (vcspec->mode & SMBM_EXACT) { if (!exact || (vcspec->mode & SMBM_MASK) != vcp->vc_mode) goto err1; } if (smb_vc_access(vcp, scred, vcspec->mode) != 0) goto err1; vcspec->ssp = NULL; if (shspec) { error = (int)smb_vc_lookupshare(vcp, shspec, scred, &vcspec->ssp); if (error) goto fail; } error = 0; break; err1: error = 1; fail: smb_vc_unlock(vcp); } if (vcp) { smb_vc_ref(vcp); *vcpp = vcp; } return (error); } int smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_vc **vcpp) { struct smb_vc *vcp; struct smb_share *ssp = NULL; int error; *vcpp = vcp = NULL; error = smb_sm_lockvclist(); if (error) return error; error = smb_sm_lookupint(vcspec, shspec, scred, vcpp); if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) { smb_sm_unlockvclist(); return error; } error = smb_sm_lookupint(vcspec, NULL, scred, &vcp); if (error) { error = smb_vc_create(vcspec, scred, &vcp); if (error) goto out; error = smb_vc_connect(vcp, scred); if (error) goto out; } if (shspec == NULL) goto out; error = smb_share_create(vcp, shspec, scred, &ssp); if (error) goto out; error = smb_smb_treeconnect(ssp, scred); if (error == 0) vcspec->ssp = ssp; else smb_share_put(ssp, scred); out: smb_sm_unlockvclist(); if (error == 0) *vcpp = vcp; else if (vcp) { smb_vc_lock(vcp); smb_vc_put(vcp, scred); } return error; } /* * Common code for connection object */ static void smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname) { SLIST_INIT(&cp->co_children); sx_init_flags(&cp->co_interlock, ilockname, SX_RECURSE); cv_init(&cp->co_lock, "smblock"); cp->co_lockcnt = 0; cp->co_locker = NULL; cp->co_level = level; cp->co_usecount = 1; sx_xlock(&cp->co_interlock); smb_co_lock(cp); sx_unlock(&cp->co_interlock); } static void smb_co_done(struct smb_connobj *cp) { sx_destroy(&cp->co_interlock); cv_destroy(&cp->co_lock); cp->co_locker = NULL; cp->co_flags = 0; cp->co_lockcnt = 0; } static void smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred) { struct smb_connobj *parent; if (cp->co_gone) cp->co_gone(cp, scred); parent = cp->co_parent; if (parent) { sx_xlock(&parent->co_interlock); smb_co_lock(parent); sx_unlock(&parent->co_interlock); SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next); smb_co_put(parent, scred); } if (cp->co_free) cp->co_free(cp); } void smb_co_ref(struct smb_connobj *cp) { sx_xlock(&cp->co_interlock); cp->co_usecount++; sx_unlock(&cp->co_interlock); } void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred) { sx_xlock(&cp->co_interlock); smb_co_unlock(cp); if (cp->co_usecount > 1) { cp->co_usecount--; sx_unlock(&cp->co_interlock); return; } if (cp->co_usecount == 0) { SMBERROR("negative use_count for object %d", cp->co_level); sx_unlock(&cp->co_interlock); return; } cp->co_usecount--; cp->co_flags |= SMBO_GONE; sx_unlock(&cp->co_interlock); smb_co_gone(cp, scred); } int smb_co_get(struct smb_connobj *cp, struct smb_cred *scred) { int error; MPASS(sx_xholder(&cp->co_interlock) == curthread); cp->co_usecount++; error = smb_co_lock(cp); if (error) cp->co_usecount--; return error; } void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred) { sx_xlock(&cp->co_interlock); if (cp->co_usecount > 1) { cp->co_usecount--; } else if (cp->co_usecount == 1) { cp->co_usecount--; cp->co_flags |= SMBO_GONE; } else { SMBERROR("negative usecount"); } smb_co_unlock(cp); sx_unlock(&cp->co_interlock); if ((cp->co_flags & SMBO_GONE) == 0) return; smb_co_gone(cp, scred); } int smb_co_lock(struct smb_connobj *cp) { MPASS(sx_xholder(&cp->co_interlock) == curthread); for (;;) { if (cp->co_flags & SMBO_GONE) return EINVAL; if (cp->co_locker == NULL) { cp->co_locker = curthread; return 0; } if (cp->co_locker == curthread) { cp->co_lockcnt++; return 0; } cv_wait(&cp->co_lock, &cp->co_interlock); } } void smb_co_unlock(struct smb_connobj *cp) { MPASS(sx_xholder(&cp->co_interlock) == curthread); MPASS(cp->co_locker == curthread); if (cp->co_lockcnt != 0) { cp->co_lockcnt--; return; } cp->co_locker = NULL; cv_signal(&cp->co_lock); } static void smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child) { smb_co_ref(parent); SLIST_INSERT_HEAD(&parent->co_children, child, co_next); child->co_parent = parent; } /* * Session implementation */ int smb_vc_create(struct smb_vcspec *vcspec, struct smb_cred *scred, struct smb_vc **vcpp) { struct smb_vc *vcp; struct ucred *cred = scred->scr_cred; uid_t uid = vcspec->owner; gid_t gid = vcspec->group; uid_t realuid = cred->cr_uid; char *domain = vcspec->domain; int error, isroot; isroot = smb_suser(cred) == 0; /* * Only superuser can create VCs with different uid and gid */ if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot) return EPERM; if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot) return EPERM; vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK); smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc"); vcp->obj.co_free = smb_vc_free; vcp->obj.co_gone = smb_vc_gone; vcp->vc_number = smb_vcnext++; vcp->vc_timo = SMB_DEFRQTIMO; vcp->vc_smbuid = SMB_UID_UNKNOWN; vcp->vc_mode = vcspec->rights & SMBM_MASK; vcp->obj.co_flags = vcspec->flags & (SMBV_PRIVATE | SMBV_SINGLESHARE); vcp->vc_tdesc = &smb_tran_nbtcp_desc; vcp->vc_seqno = 0; vcp->vc_mackey = NULL; vcp->vc_mackeylen = 0; if (uid == SMBM_ANY_OWNER) uid = realuid; if (gid == SMBM_ANY_GROUP) gid = cred->cr_groups[0]; vcp->vc_uid = uid; vcp->vc_grp = gid; smb_sl_init(&vcp->vc_stlock, "vcstlock"); error = ENOMEM; vcp->vc_paddr = sodupsockaddr(vcspec->sap, M_WAITOK); if (vcp->vc_paddr == NULL) goto fail; vcp->vc_laddr = sodupsockaddr(vcspec->lap, M_WAITOK); if (vcp->vc_laddr == NULL) goto fail; vcp->vc_pass = smb_strdup(vcspec->pass); if (vcp->vc_pass == NULL) goto fail; vcp->vc_domain = smb_strdup((domain && domain[0]) ? domain : "NODOMAIN"); if (vcp->vc_domain == NULL) goto fail; vcp->vc_srvname = smb_strdup(vcspec->srvname); if (vcp->vc_srvname == NULL) goto fail; vcp->vc_username = smb_strdup(vcspec->username); if (vcp->vc_username == NULL) goto fail; error = (int)iconv_open("tolower", vcspec->localcs, &vcp->vc_tolower); if (error) goto fail; error = (int)iconv_open("toupper", vcspec->localcs, &vcp->vc_toupper); if (error) goto fail; if (vcspec->servercs[0]) { error = (int)iconv_open(vcspec->servercs, vcspec->localcs, &vcp->vc_cp_toserver); if (error) goto fail; error = (int)iconv_open(vcspec->localcs, vcspec->servercs, &vcp->vc_cp_tolocal); if (error) goto fail; vcp->vc_toserver = vcp->vc_cp_toserver; vcp->vc_tolocal = vcp->vc_cp_tolocal; iconv_add(ENCODING_UNICODE, ENCODING_UNICODE, SMB_UNICODE_NAME); iconv_add(ENCODING_UNICODE, SMB_UNICODE_NAME, ENCODING_UNICODE); error = (int)iconv_open(SMB_UNICODE_NAME, vcspec->localcs, &vcp->vc_ucs_toserver); if (!error) { error = (int)iconv_open(vcspec->localcs, SMB_UNICODE_NAME, &vcp->vc_ucs_tolocal); } if (error) { if (vcp->vc_ucs_toserver) iconv_close(vcp->vc_ucs_toserver); vcp->vc_ucs_toserver = NULL; vcp->vc_ucs_tolocal = NULL; } } error = (int)smb_iod_create(vcp); if (error) goto fail; *vcpp = vcp; smb_co_addchild(&smb_vclist, VCTOCP(vcp)); return (0); fail: smb_vc_put(vcp, scred); return (error); } static void smb_vc_free(struct smb_connobj *cp) { struct smb_vc *vcp = CPTOVC(cp); if (vcp->vc_iod) smb_iod_destroy(vcp->vc_iod); SMB_STRFREE(vcp->vc_username); SMB_STRFREE(vcp->vc_srvname); SMB_STRFREE(vcp->vc_pass); SMB_STRFREE(vcp->vc_domain); if (vcp->vc_mackey) free(vcp->vc_mackey, M_SMBTEMP); if (vcp->vc_paddr) free(vcp->vc_paddr, M_SONAME); if (vcp->vc_laddr) free(vcp->vc_laddr, M_SONAME); if (vcp->vc_tolower) iconv_close(vcp->vc_tolower); if (vcp->vc_toupper) iconv_close(vcp->vc_toupper); if (vcp->vc_tolocal) vcp->vc_tolocal = NULL; if (vcp->vc_toserver) vcp->vc_toserver = NULL; if (vcp->vc_cp_tolocal) iconv_close(vcp->vc_cp_tolocal); if (vcp->vc_cp_toserver) iconv_close(vcp->vc_cp_toserver); if (vcp->vc_ucs_tolocal) iconv_close(vcp->vc_ucs_tolocal); if (vcp->vc_ucs_toserver) iconv_close(vcp->vc_ucs_toserver); smb_co_done(VCTOCP(vcp)); smb_sl_destroy(&vcp->vc_stlock); free(vcp, M_SMBCONN); } /* * Called when use count of VC dropped to zero. */ static void smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred) { struct smb_vc *vcp = CPTOVC(cp); smb_vc_disconnect(vcp); } void smb_vc_ref(struct smb_vc *vcp) { smb_co_ref(VCTOCP(vcp)); } void smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred) { smb_co_rele(VCTOCP(vcp), scred); } int smb_vc_get(struct smb_vc *vcp, struct smb_cred *scred) { struct smb_connobj *cp; int error; cp = VCTOCP(vcp); sx_xlock(&cp->co_interlock); error = smb_co_get(cp, scred); sx_unlock(&cp->co_interlock); return error; } void smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred) { smb_co_put(VCTOCP(vcp), scred); } int smb_vc_lock(struct smb_vc *vcp) { struct smb_connobj *cp; int error; cp = VCTOCP(vcp); sx_xlock(&cp->co_interlock); error = smb_co_lock(cp); sx_unlock(&cp->co_interlock); return error; } void smb_vc_unlock(struct smb_vc *vcp) { struct smb_connobj *cp; cp = VCTOCP(vcp); sx_xlock(&cp->co_interlock); smb_co_unlock(cp); sx_unlock(&cp->co_interlock); } int smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode) { struct ucred *cred = scred->scr_cred; if (smb_suser(cred) == 0 || cred->cr_uid == vcp->vc_uid) return 0; mode >>= 3; if (!groupmember(vcp->vc_grp, cred)) mode >>= 3; return (vcp->vc_mode & mode) == mode ? 0 : EACCES; } static int smb_vc_cmpshare(struct smb_share *ssp, struct smb_sharespec *dp) { int exact = 1; if (strcmp(ssp->ss_name, dp->name) != 0) return 1; if (dp->owner != SMBM_ANY_OWNER) { if (ssp->ss_uid != dp->owner) return 1; } else exact = 0; if (dp->group != SMBM_ANY_GROUP) { if (ssp->ss_grp != dp->group) return 1; } else exact = 0; if (dp->mode & SMBM_EXACT) { if (!exact) return 1; return (dp->mode & SMBM_MASK) == ssp->ss_mode ? 0 : 1; } if (smb_share_access(ssp, dp->scred, dp->mode) != 0) return 1; return 0; } /* * Lookup share in the given VC. Share referenced and locked on return. * VC expected to be locked on entry and will be left locked on exit. */ int smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp, struct smb_cred *scred, struct smb_share **sspp) { struct smb_connobj *scp = NULL; struct smb_share *ssp = NULL; int error; *sspp = NULL; dp->scred = scred; SMBCO_FOREACH(scp, VCTOCP(vcp)) { ssp = (struct smb_share *)scp; error = smb_share_lock(ssp); if (error) continue; if (smb_vc_cmpshare(ssp, dp) == 0) break; smb_share_unlock(ssp); } if (ssp) { smb_share_ref(ssp); *sspp = ssp; error = 0; } else error = ENOENT; return error; } int smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred) { return smb_iod_request(vcp->vc_iod, SMBIOD_EV_CONNECT | SMBIOD_EV_SYNC, NULL); } /* * Destroy VC to server, invalidate shares linked with it. * Transport should be locked on entry. */ int smb_vc_disconnect(struct smb_vc *vcp) { - smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT | SMBIOD_EV_SYNC, NULL); + if (vcp->vc_iod != NULL) + smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT | + SMBIOD_EV_SYNC, NULL); return 0; } static char smb_emptypass[] = ""; const char * smb_vc_getpass(struct smb_vc *vcp) { if (vcp->vc_pass) return vcp->vc_pass; return smb_emptypass; } static int smb_vc_getinfo(struct smb_vc *vcp, struct smb_vc_info *vip) { bzero(vip, sizeof(struct smb_vc_info)); vip->itype = SMB_INFO_VC; vip->usecount = vcp->obj.co_usecount; vip->uid = vcp->vc_uid; vip->gid = vcp->vc_grp; vip->mode = vcp->vc_mode; vip->flags = vcp->obj.co_flags; vip->sopt = vcp->vc_sopt; vip->iodstate = vcp->vc_iod->iod_state; bzero(&vip->sopt.sv_skey, sizeof(vip->sopt.sv_skey)); snprintf(vip->srvname, sizeof(vip->srvname), "%s", vcp->vc_srvname); snprintf(vip->vcname, sizeof(vip->vcname), "%s", vcp->vc_username); return 0; } u_short smb_vc_nextmid(struct smb_vc *vcp) { u_short r; sx_xlock(&vcp->obj.co_interlock); r = vcp->vc_mid++; sx_unlock(&vcp->obj.co_interlock); return r; } /* * Share implementation */ /* * Allocate share structure and attach it to the given VC * Connection expected to be locked on entry. Share will be returned * in locked state. */ int smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, struct smb_cred *scred, struct smb_share **sspp) { struct smb_share *ssp; struct ucred *cred = scred->scr_cred; uid_t realuid = cred->cr_uid; uid_t uid = shspec->owner; gid_t gid = shspec->group; int error, isroot; isroot = smb_suser(cred) == 0; /* * Only superuser can create shares with different uid and gid */ if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot) return EPERM; if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot) return EPERM; error = smb_vc_lookupshare(vcp, shspec, scred, &ssp); if (!error) { smb_share_put(ssp, scred); return EEXIST; } if (uid == SMBM_ANY_OWNER) uid = realuid; 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 ilock", "smbss"); ssp->obj.co_free = smb_share_free; ssp->obj.co_gone = smb_share_gone; smb_sl_init(&ssp->ss_stlock, "ssstlock"); ssp->ss_name = smb_strdup(shspec->name); if (shspec->pass && shspec->pass[0]) ssp->ss_pass = smb_strdup(shspec->pass); ssp->ss_type = shspec->stype; ssp->ss_tid = SMB_TID_UNKNOWN; ssp->ss_uid = uid; ssp->ss_grp = gid; ssp->ss_mode = shspec->rights & SMBM_MASK; smb_co_addchild(VCTOCP(vcp), SSTOCP(ssp)); *sspp = ssp; return 0; } static void smb_share_free(struct smb_connobj *cp) { struct smb_share *ssp = CPTOSS(cp); SMB_STRFREE(ssp->ss_name); SMB_STRFREE(ssp->ss_pass); smb_sl_destroy(&ssp->ss_stlock); smb_co_done(SSTOCP(ssp)); free(ssp, M_SMBCONN); } static void smb_share_gone(struct smb_connobj *cp, struct smb_cred *scred) { struct smb_share *ssp = CPTOSS(cp); smb_smb_treedisconnect(ssp, scred); } void smb_share_ref(struct smb_share *ssp) { smb_co_ref(SSTOCP(ssp)); } void smb_share_rele(struct smb_share *ssp, struct smb_cred *scred) { smb_co_rele(SSTOCP(ssp), scred); } int smb_share_get(struct smb_share *ssp, struct smb_cred *scred) { struct smb_connobj *cp = SSTOCP(ssp); int error; sx_xlock(&cp->co_interlock); error = smb_co_get(cp, scred); sx_unlock(&cp->co_interlock); return error; } void smb_share_put(struct smb_share *ssp, struct smb_cred *scred) { smb_co_put(SSTOCP(ssp), scred); } int smb_share_lock(struct smb_share *ssp) { struct smb_connobj *cp; int error; cp = SSTOCP(ssp); sx_xlock(&cp->co_interlock); error = smb_co_lock(cp); sx_unlock(&cp->co_interlock); return error; } void smb_share_unlock(struct smb_share *ssp) { struct smb_connobj *cp; cp = SSTOCP(ssp); sx_xlock(&cp->co_interlock); smb_co_unlock(cp); sx_unlock(&cp->co_interlock); } int smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode) { struct ucred *cred = scred->scr_cred; if (smb_suser(cred) == 0 || cred->cr_uid == ssp->ss_uid) return 0; mode >>= 3; if (!groupmember(ssp->ss_grp, cred)) mode >>= 3; return (ssp->ss_mode & mode) == mode ? 0 : EACCES; } void smb_share_invalidate(struct smb_share *ssp) { ssp->ss_tid = SMB_TID_UNKNOWN; } int smb_share_valid(struct smb_share *ssp) { return ssp->ss_tid != SMB_TID_UNKNOWN && ssp->ss_vcgenid == SSTOVC(ssp)->vc_genid; } const char* smb_share_getpass(struct smb_share *ssp) { struct smb_vc *vcp; if (ssp->ss_pass) return ssp->ss_pass; vcp = SSTOVC(ssp); if (vcp->vc_pass) return vcp->vc_pass; return smb_emptypass; } static int smb_share_getinfo(struct smb_share *ssp, struct smb_share_info *sip) { bzero(sip, sizeof(struct smb_share_info)); sip->itype = SMB_INFO_SHARE; sip->usecount = ssp->obj.co_usecount; sip->tid = ssp->ss_tid; sip->type= ssp->ss_type; sip->uid = ssp->ss_uid; sip->gid = ssp->ss_grp; sip->mode= ssp->ss_mode; sip->flags = ssp->obj.co_flags; snprintf(sip->sname, sizeof(sip->sname), "%s", ssp->ss_name); return 0; } /* * Dump an entire tree into sysctl call */ static int smb_sysctl_treedump(SYSCTL_HANDLER_ARGS) { struct smb_connobj *scp1, *scp2; struct smb_vc *vcp; struct smb_share *ssp; struct smb_vc_info vci; struct smb_share_info ssi; int error, itype; error = sysctl_wire_old_buffer(req, 0); if (error) return (error); error = smb_sm_lockvclist(); if (error) return error; SMBCO_FOREACH(scp1, &smb_vclist) { vcp = (struct smb_vc *)scp1; error = smb_vc_lock(vcp); if (error) continue; smb_vc_getinfo(vcp, &vci); error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info)); if (error) { smb_vc_unlock(vcp); break; } SMBCO_FOREACH(scp2, VCTOCP(vcp)) { ssp = (struct smb_share *)scp2; error = smb_share_lock(ssp); if (error) { error = 0; continue; } smb_share_getinfo(ssp, &ssi); smb_share_unlock(ssp); error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info)); if (error) break; } smb_vc_unlock(vcp); if (error) break; } if (!error) { itype = SMB_INFO_NONE; error = SYSCTL_OUT(req, &itype, sizeof(itype)); } smb_sm_unlockvclist(); return error; } Index: head/sys/netsmb/smb_iod.c =================================================================== --- head/sys/netsmb/smb_iod.c (revision 291034) +++ head/sys/netsmb/smb_iod.c (revision 291035) @@ -1,717 +1,720 @@ /*- * Copyright (c) 2000-2001 Boris Popov * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SMBIOD_SLEEP_TIMO 2 #define SMBIOD_PING_TIMO 60 /* seconds */ #define SMB_IOD_EVLOCKPTR(iod) (&((iod)->iod_evlock)) #define SMB_IOD_EVLOCK(iod) smb_sl_lock(&((iod)->iod_evlock)) #define SMB_IOD_EVUNLOCK(iod) smb_sl_unlock(&((iod)->iod_evlock)) #define SMB_IOD_RQLOCKPTR(iod) (&((iod)->iod_rqlock)) #define SMB_IOD_RQLOCK(iod) smb_sl_lock(&((iod)->iod_rqlock)) #define SMB_IOD_RQUNLOCK(iod) smb_sl_unlock(&((iod)->iod_rqlock)) #define smb_iod_wakeup(iod) wakeup(&(iod)->iod_flags) static MALLOC_DEFINE(M_SMBIOD, "SMBIOD", "SMB network io daemon"); static int smb_iod_next; static int smb_iod_sendall(struct smbiod *iod); static int smb_iod_disconnect(struct smbiod *iod); static void smb_iod_thread(void *); static __inline void smb_iod_rqprocessed(struct smb_rq *rqp, int error) { SMBRQ_SLOCK(rqp); rqp->sr_lerror = error; rqp->sr_rpgen++; rqp->sr_state = SMBRQ_NOTIFIED; wakeup(&rqp->sr_state); SMBRQ_SUNLOCK(rqp); } static void smb_iod_invrq(struct smbiod *iod) { struct smb_rq *rqp; /* * Invalidate all outstanding requests for this connection */ SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { rqp->sr_flags |= SMBR_RESTART; smb_iod_rqprocessed(rqp, ENOTCONN); } SMB_IOD_RQUNLOCK(iod); } static void smb_iod_closetran(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; struct thread *td = iod->iod_td; if (vcp->vc_tdata == NULL) return; SMB_TRAN_DISCONNECT(vcp, td); SMB_TRAN_DONE(vcp, td); vcp->vc_tdata = NULL; } static void smb_iod_dead(struct smbiod *iod) { iod->iod_state = SMBIOD_ST_DEAD; smb_iod_closetran(iod); smb_iod_invrq(iod); } static int smb_iod_connect(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; struct thread *td = iod->iod_td; int error; SMBIODEBUG("%d\n", iod->iod_state); switch(iod->iod_state) { case SMBIOD_ST_VCACTIVE: SMBERROR("called for already opened connection\n"); return EISCONN; case SMBIOD_ST_DEAD: return ENOTCONN; /* XXX: last error code ? */ default: break; } vcp->vc_genid++; error = 0; error = (int)SMB_TRAN_CREATE(vcp, td); if (error) goto fail; SMBIODEBUG("tcreate\n"); if (vcp->vc_laddr) { error = (int)SMB_TRAN_BIND(vcp, vcp->vc_laddr, td); if (error) goto fail; } SMBIODEBUG("tbind\n"); error = (int)SMB_TRAN_CONNECT(vcp, vcp->vc_paddr, td); if (error) goto fail; SMB_TRAN_SETPARAM(vcp, SMBTP_SELECTID, &iod->iod_flags); iod->iod_state = SMBIOD_ST_TRANACTIVE; SMBIODEBUG("tconnect\n"); /* vcp->vc_mid = 0;*/ error = (int)smb_smb_negotiate(vcp, &iod->iod_scred); if (error) goto fail; SMBIODEBUG("snegotiate\n"); error = (int)smb_smb_ssnsetup(vcp, &iod->iod_scred); if (error) goto fail; iod->iod_state = SMBIOD_ST_VCACTIVE; SMBIODEBUG("completed\n"); smb_iod_invrq(iod); return (0); fail: smb_iod_dead(iod); return (error); } static int smb_iod_disconnect(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; SMBIODEBUG("\n"); if (iod->iod_state == SMBIOD_ST_VCACTIVE) { smb_smb_ssnclose(vcp, &iod->iod_scred); iod->iod_state = SMBIOD_ST_TRANACTIVE; } vcp->vc_smbuid = SMB_UID_UNKNOWN; smb_iod_closetran(iod); iod->iod_state = SMBIOD_ST_NOTCONN; return 0; } static int smb_iod_treeconnect(struct smbiod *iod, struct smb_share *ssp) { int error; if (iod->iod_state != SMBIOD_ST_VCACTIVE) { if (iod->iod_state != SMBIOD_ST_DEAD) return ENOTCONN; iod->iod_state = SMBIOD_ST_RECONNECT; error = smb_iod_connect(iod); if (error) return error; } SMBIODEBUG("tree reconnect\n"); SMBS_ST_LOCK(ssp); ssp->ss_flags |= SMBS_RECONNECTING; SMBS_ST_UNLOCK(ssp); error = smb_smb_treeconnect(ssp, &iod->iod_scred); SMBS_ST_LOCK(ssp); ssp->ss_flags &= ~SMBS_RECONNECTING; SMBS_ST_UNLOCK(ssp); wakeup(&ssp->ss_vcgenid); return error; } static int smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp) { struct thread *td = iod->iod_td; struct smb_vc *vcp = iod->iod_vc; struct smb_share *ssp = rqp->sr_share; struct mbuf *m; int error; SMBIODEBUG("iod_state = %d\n", iod->iod_state); switch (iod->iod_state) { case SMBIOD_ST_NOTCONN: smb_iod_rqprocessed(rqp, ENOTCONN); return 0; case SMBIOD_ST_DEAD: iod->iod_state = SMBIOD_ST_RECONNECT; return 0; case SMBIOD_ST_RECONNECT: return 0; default: break; } if (rqp->sr_sendcnt == 0) { #ifdef movedtoanotherplace if (vcp->vc_maxmux != 0 && iod->iod_muxcnt >= vcp->vc_maxmux) return 0; #endif le16enc(rqp->sr_rqtid, ssp ? ssp->ss_tid : SMB_TID_UNKNOWN); le16enc(rqp->sr_rquid, vcp ? vcp->vc_smbuid : 0); mb_fixhdr(&rqp->sr_rq); if (vcp->vc_hflags2 & SMB_FLAGS2_SECURITY_SIGNATURE) smb_rq_sign(rqp); } if (rqp->sr_sendcnt++ > 5) { rqp->sr_flags |= SMBR_RESTART; smb_iod_rqprocessed(rqp, rqp->sr_lerror); /* * If all attempts to send a request failed, then * something is seriously hosed. */ return ENOTCONN; } 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_WAITOK); error = rqp->sr_lerror = SMB_TRAN_SEND(vcp, m, td); if (error == 0) { getnanotime(&rqp->sr_timesent); iod->iod_lastrqsent = rqp->sr_timesent; rqp->sr_flags |= SMBR_SENT; rqp->sr_state = SMBRQ_SENT; return 0; } /* * Check for fatal errors */ if (SMB_TRAN_FATAL(vcp, error)) { /* * No further attempts should be made */ return ENOTCONN; } if (smb_rq_intr(rqp)) smb_iod_rqprocessed(rqp, EINTR); return 0; } /* * Process incoming packets */ static int smb_iod_recvall(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; struct thread *td = iod->iod_td; struct smb_rq *rqp; struct mbuf *m; u_char *hp; u_short mid; int error; switch (iod->iod_state) { case SMBIOD_ST_NOTCONN: case SMBIOD_ST_DEAD: case SMBIOD_ST_RECONNECT: return 0; default: break; } for (;;) { m = NULL; error = SMB_TRAN_RECV(vcp, &m, td); if (error == EWOULDBLOCK) break; if (SMB_TRAN_FATAL(vcp, error)) { smb_iod_dead(iod); break; } if (error) break; if (m == NULL) { SMBERROR("tran return NULL without error\n"); error = EPIPE; continue; } m = m_pullup(m, SMB_HDRLEN); if (m == NULL) continue; /* wait for a good packet */ /* * Now we got an entire and possibly invalid SMB packet. * Be careful while parsing it. */ m_dumpm(m); hp = mtod(m, u_char*); if (bcmp(hp, SMB_SIGNATURE, SMB_SIGLEN) != 0) { m_freem(m); continue; } mid = SMB_HDRMID(hp); SMBSDEBUG("mid %04x\n", (u_int)mid); SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { if (rqp->sr_mid != mid) continue; SMBRQ_SLOCK(rqp); if (rqp->sr_rp.md_top == NULL) { md_initm(&rqp->sr_rp, m); } else { if (rqp->sr_flags & SMBR_MULTIPACKET) { md_append_record(&rqp->sr_rp, m); } else { SMBRQ_SUNLOCK(rqp); SMBERROR("duplicate response %d (ignored)\n", mid); break; } } SMBRQ_SUNLOCK(rqp); smb_iod_rqprocessed(rqp, 0); break; } SMB_IOD_RQUNLOCK(iod); if (rqp == NULL) { SMBERROR("drop resp with mid %d\n", (u_int)mid); /* smb_printrqlist(vcp);*/ m_freem(m); } } /* * check for interrupts */ SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { if (smb_td_intr(rqp->sr_cred->scr_td)) { smb_iod_rqprocessed(rqp, EINTR); } } SMB_IOD_RQUNLOCK(iod); return 0; } int smb_iod_request(struct smbiod *iod, int event, void *ident) { struct smbiod_event *evp; int error; SMBIODEBUG("\n"); evp = smb_zmalloc(sizeof(*evp), M_SMBIOD, M_WAITOK); evp->ev_type = event; evp->ev_ident = ident; SMB_IOD_EVLOCK(iod); STAILQ_INSERT_TAIL(&iod->iod_evlist, evp, ev_link); if ((event & SMBIOD_EV_SYNC) == 0) { SMB_IOD_EVUNLOCK(iod); smb_iod_wakeup(iod); return 0; } smb_iod_wakeup(iod); msleep(evp, SMB_IOD_EVLOCKPTR(iod), PWAIT | PDROP, "90evw", 0); error = evp->ev_error; free(evp, M_SMBIOD); return error; } /* * Place request in the queue. * Request from smbiod have a high priority. */ int smb_iod_addrq(struct smb_rq *rqp) { struct smb_vc *vcp = rqp->sr_vc; struct smbiod *iod = vcp->vc_iod; int error; SMBIODEBUG("\n"); if (rqp->sr_cred->scr_td != NULL && 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); SMB_IOD_RQUNLOCK(iod); for (;;) { if (smb_iod_sendrq(iod, rqp) != 0) { smb_iod_dead(iod); break; } /* * we don't need to lock state field here */ if (rqp->sr_state != SMBRQ_NOTSENT) break; tsleep(&iod->iod_flags, PWAIT, "90sndw", hz); } if (rqp->sr_lerror) smb_iod_removerq(rqp); return rqp->sr_lerror; } switch (iod->iod_state) { case SMBIOD_ST_NOTCONN: return ENOTCONN; case SMBIOD_ST_DEAD: error = smb_iod_request(vcp->vc_iod, SMBIOD_EV_CONNECT | SMBIOD_EV_SYNC, NULL); if (error) return error; return EXDEV; default: break; } SMB_IOD_RQLOCK(iod); for (;;) { if (vcp->vc_maxmux == 0) { SMBERROR("maxmux == 0\n"); break; } if (iod->iod_muxcnt < vcp->vc_maxmux) break; iod->iod_muxwant++; msleep(&iod->iod_muxwant, SMB_IOD_RQLOCKPTR(iod), PWAIT, "90mux", 0); } iod->iod_muxcnt++; TAILQ_INSERT_TAIL(&iod->iod_rqlist, rqp, sr_link); SMB_IOD_RQUNLOCK(iod); smb_iod_wakeup(iod); return 0; } int smb_iod_removerq(struct smb_rq *rqp) { struct smb_vc *vcp = rqp->sr_vc; struct smbiod *iod = vcp->vc_iod; SMBIODEBUG("\n"); if (rqp->sr_flags & SMBR_INTERNAL) { SMB_IOD_RQLOCK(iod); TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link); SMB_IOD_RQUNLOCK(iod); return 0; } SMB_IOD_RQLOCK(iod); while (rqp->sr_flags & SMBR_XLOCK) { rqp->sr_flags |= SMBR_XLOCKWANT; msleep(rqp, SMB_IOD_RQLOCKPTR(iod), PWAIT, "90xrm", 0); } TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link); iod->iod_muxcnt--; if (iod->iod_muxwant) { iod->iod_muxwant--; wakeup(&iod->iod_muxwant); } SMB_IOD_RQUNLOCK(iod); return 0; } int smb_iod_waitrq(struct smb_rq *rqp) { struct smbiod *iod = rqp->sr_vc->vc_iod; int error; SMBIODEBUG("\n"); if (rqp->sr_flags & SMBR_INTERNAL) { for (;;) { smb_iod_sendall(iod); smb_iod_recvall(iod); if (rqp->sr_rpgen != rqp->sr_rplast) break; tsleep(&iod->iod_flags, PWAIT, "90irq", hz); } smb_iod_removerq(rqp); return rqp->sr_lerror; } SMBRQ_SLOCK(rqp); if (rqp->sr_rpgen == rqp->sr_rplast) msleep(&rqp->sr_state, SMBRQ_SLOCKPTR(rqp), PWAIT, "90wrq", 0); rqp->sr_rplast++; SMBRQ_SUNLOCK(rqp); error = rqp->sr_lerror; if (rqp->sr_flags & SMBR_MULTIPACKET) { /* * If request should stay in the list, then reinsert it * at the end of queue so other waiters have chance to concur */ SMB_IOD_RQLOCK(iod); TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link); TAILQ_INSERT_TAIL(&iod->iod_rqlist, rqp, sr_link); SMB_IOD_RQUNLOCK(iod); } else smb_iod_removerq(rqp); return error; } static int smb_iod_sendall(struct smbiod *iod) { struct smb_vc *vcp = iod->iod_vc; struct smb_rq *rqp; struct timespec ts, tstimeout; int herror; herror = 0; /* * Loop through the list of requests and send them if possible */ SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { switch (rqp->sr_state) { case SMBRQ_NOTSENT: rqp->sr_flags |= SMBR_XLOCK; SMB_IOD_RQUNLOCK(iod); herror = smb_iod_sendrq(iod, rqp); SMB_IOD_RQLOCK(iod); rqp->sr_flags &= ~SMBR_XLOCK; if (rqp->sr_flags & SMBR_XLOCKWANT) { rqp->sr_flags &= ~SMBR_XLOCKWANT; wakeup(rqp); } break; case SMBRQ_SENT: SMB_TRAN_GETPARAM(vcp, SMBTP_TIMEOUT, &tstimeout); timespecadd(&tstimeout, &tstimeout); getnanotime(&ts); timespecsub(&ts, &tstimeout); if (timespeccmp(&ts, &rqp->sr_timesent, >)) { smb_iod_rqprocessed(rqp, ETIMEDOUT); } break; default: break; } if (herror) break; } SMB_IOD_RQUNLOCK(iod); if (herror == ENOTCONN) smb_iod_dead(iod); return 0; } /* * "main" function for smbiod daemon */ static __inline void smb_iod_main(struct smbiod *iod) { /* struct smb_vc *vcp = iod->iod_vc;*/ struct smbiod_event *evp; /* struct timespec tsnow;*/ int error; SMBIODEBUG("\n"); error = 0; /* * Check all interesting events */ for (;;) { SMB_IOD_EVLOCK(iod); evp = STAILQ_FIRST(&iod->iod_evlist); if (evp == NULL) { SMB_IOD_EVUNLOCK(iod); break; } STAILQ_REMOVE_HEAD(&iod->iod_evlist, ev_link); evp->ev_type |= SMBIOD_EV_PROCESSING; SMB_IOD_EVUNLOCK(iod); switch (evp->ev_type & SMBIOD_EV_MASK) { case SMBIOD_EV_CONNECT: iod->iod_state = SMBIOD_ST_RECONNECT; evp->ev_error = smb_iod_connect(iod); break; case SMBIOD_EV_DISCONNECT: evp->ev_error = smb_iod_disconnect(iod); break; case SMBIOD_EV_TREECONNECT: evp->ev_error = smb_iod_treeconnect(iod, evp->ev_ident); break; case SMBIOD_EV_SHUTDOWN: iod->iod_flags |= SMBIOD_SHUTDOWN; break; case SMBIOD_EV_NEWRQ: break; } if (evp->ev_type & SMBIOD_EV_SYNC) { SMB_IOD_EVLOCK(iod); wakeup(evp); SMB_IOD_EVUNLOCK(iod); } else free(evp, M_SMBIOD); } #if 0 if (iod->iod_state == SMBIOD_ST_VCACTIVE) { getnanotime(&tsnow); timespecsub(&tsnow, &iod->iod_pingtimo); if (timespeccmp(&tsnow, &iod->iod_lastrqsent, >)) { smb_smb_echo(vcp, &iod->iod_scred); } } #endif smb_iod_sendall(iod); smb_iod_recvall(iod); return; } void smb_iod_thread(void *arg) { struct smbiod *iod = arg; mtx_lock(&Giant); /* * 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); if (iod->iod_flags & SMBIOD_SHUTDOWN) break; tsleep(&iod->iod_flags, PWAIT, "90idle", iod->iod_sleeptimo); } /* We can now safely destroy the mutexes and free the iod structure. */ smb_sl_destroy(&iod->iod_rqlock); smb_sl_destroy(&iod->iod_evlock); free(iod, M_SMBIOD); mtx_unlock(&Giant); kproc_exit(0); } int smb_iod_create(struct smb_vc *vcp) { struct smbiod *iod; int error; iod = smb_zmalloc(sizeof(*iod), M_SMBIOD, M_WAITOK); iod->iod_id = smb_iod_next++; iod->iod_state = SMBIOD_ST_NOTCONN; iod->iod_vc = vcp; iod->iod_sleeptimo = hz * SMBIOD_SLEEP_TIMO; iod->iod_pingtimo.tv_sec = SMBIOD_PING_TIMO; getnanotime(&iod->iod_lastrqsent); vcp->vc_iod = iod; smb_sl_init(&iod->iod_rqlock, "90rql"); TAILQ_INIT(&iod->iod_rqlist); smb_sl_init(&iod->iod_evlock, "90evl"); STAILQ_INIT(&iod->iod_evlist); error = kproc_create(smb_iod_thread, iod, &iod->iod_p, RFNOWAIT, 0, "smbiod%d", iod->iod_id); if (error) { SMBERROR("can't start smbiod: %d", error); + vcp->vc_iod = NULL; + smb_sl_destroy(&iod->iod_rqlock); + smb_sl_destroy(&iod->iod_evlock); free(iod, M_SMBIOD); return error; } return 0; } int smb_iod_destroy(struct smbiod *iod) { smb_iod_request(iod, SMBIOD_EV_SHUTDOWN | SMBIOD_EV_SYNC, NULL); return 0; } int smb_iod_init(void) { return 0; } int smb_iod_done(void) { return 0; }