diff options
Diffstat (limited to 'sys/fs/nfsserver/nfs_nfsdserv.c')
-rw-r--r-- | sys/fs/nfsserver/nfs_nfsdserv.c | 357 |
1 files changed, 191 insertions, 166 deletions
diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 802868a..b6a365d 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -93,7 +93,7 @@ nfsrvd_access(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_postopattr(nd, 1, &nva); - return (0); + goto out; } NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); nfsmode = fxdr_unsigned(u_int32_t, *tl); @@ -103,7 +103,7 @@ nfsrvd_access(struct nfsrv_descript *nd, __unused int isdgram, NFSACCESS_EXECUTE))) { nd->nd_repstat = NFSERR_INVAL; vput(vp); - return (0); + goto out; } if (nfsmode & NFSACCESS_READ) { supported |= NFSACCESS_READ; @@ -155,9 +155,13 @@ nfsrvd_access(struct nfsrv_descript *nd, __unused int isdgram, } else NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(nfsmode); + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -180,12 +184,12 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram, accmode_t accmode; if (nd->nd_repstat) - return (0); + goto out; if (nd->nd_flag & ND_NFSV4) { error = nfsrv_getattrbits(nd, &attrbits, NULL, NULL); if (error) { vput(vp); - return (error); + goto out; } /* @@ -196,7 +200,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram, (void) nfsrv_putreferralattr(nd, &attrbits, refp, 1, &nd->nd_repstat); vput(vp); - return (0); + goto out; } if (nd->nd_repstat == 0) { accmode = 0; @@ -270,7 +274,10 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram, } else { vput(vp); } - return (0); + +out: + NFSEXITCODE2(error, nd); + return (error); } /* @@ -290,7 +297,7 @@ nfsrvd_setattr(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_wcc(nd, preat_ret, &nva2, postat_ret, &nva); - return (0); + goto out; } #ifdef NFS4_ACL_EXTATTR_NAME aclp = acl_alloc(M_WAITOK); @@ -326,7 +333,7 @@ nfsrvd_setattr(struct nfsrv_descript *nd, __unused int isdgram, acl_free(aclp); #endif nfsrv_wcc(nd, preat_ret, &nva2, postat_ret, &nva); - return (0); + goto out; } } else if (!nd->nd_repstat && (nd->nd_flag & ND_NFSV4)) nd->nd_repstat = nfsrv_checkuidgid(nd, &nva); @@ -440,6 +447,9 @@ nfsrvd_setattr(struct nfsrv_descript *nd, __unused int isdgram, (void) nfsrv_putattrbit(nd, &retbits); else if (!nd->nd_repstat) nfsrv_fillattr(nd, &nva); + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); @@ -454,6 +464,7 @@ nfsmout: */ (void) nfsrv_putattrbit(nd, &retbits); } + NFSEXITCODE2(error, nd); return (error); } @@ -468,14 +479,14 @@ nfsrvd_lookup(struct nfsrv_descript *nd, __unused int isdgram, { struct nameidata named; vnode_t vp, dirp = NULL; - int error, dattr_ret = 1; + int error = 0, dattr_ret = 1; struct nfsvattr nva, dattr; char *bufp; u_long *hashp; if (nd->nd_repstat) { nfsrv_postopattr(nd, dattr_ret, &dattr); - return (0); + goto out; } /* @@ -485,7 +496,7 @@ nfsrvd_lookup(struct nfsrv_descript *nd, __unused int isdgram, if (dp->v_type == VLNK && (nd->nd_flag & ND_NFSV4)) { nd->nd_repstat = NFSERR_SYMLINK; vrele(dp); - return (0); + goto out; } NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, LOOKUP, @@ -495,7 +506,7 @@ nfsrvd_lookup(struct nfsrv_descript *nd, __unused int isdgram, if (error) { vrele(dp); nfsvno_relpathbuf(&named); - return (error); + goto out; } if (!nd->nd_repstat) { nd->nd_repstat = nfsvno_namei(nd, &named, dp, 0, exp, p, &dirp); @@ -512,7 +523,7 @@ nfsrvd_lookup(struct nfsrv_descript *nd, __unused int isdgram, } if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, dattr_ret, &dattr); - return (0); + goto out; } if (named.ni_startdir) vrele(named.ni_startdir); @@ -542,7 +553,7 @@ nfsrvd_lookup(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, dattr_ret, &dattr); - return (0); + goto out; } if (nd->nd_flag & ND_NFSV2) { (void) nfsm_fhtom(nd, (u_int8_t *)fhp, 0, 0); @@ -552,7 +563,10 @@ nfsrvd_lookup(struct nfsrv_descript *nd, __unused int isdgram, nfsrv_postopattr(nd, 0, &nva); nfsrv_postopattr(nd, dattr_ret, &dattr); } - return (0); + +out: + NFSEXITCODE2(error, nd); + return (error); } /* @@ -569,7 +583,7 @@ nfsrvd_readlink(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &nva); - return (0); + goto out; } if (vnode_vtype(vp) != VLNK) { if (nd->nd_flag & ND_NFSV2) @@ -586,12 +600,15 @@ nfsrvd_readlink(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, getret, &nva); if (nd->nd_repstat) - return (0); + goto out; NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(len); mbuf_setnext(nd->nd_mb, mp); nd->nd_mb = mpend; nd->nd_bpos = NFSMTOD(mpend, caddr_t) + mbuf_len(mpend); + +out: + NFSEXITCODE2(0, nd); return (0); } @@ -614,7 +631,7 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &nva); - return (0); + goto out; } if (nd->nd_flag & ND_NFSV2) { NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED); @@ -690,7 +707,7 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram, vput(vp); if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, getret, &nva); - return (0); + goto out; } if (off >= nva.na_size) { cnt = 0; @@ -717,7 +734,7 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram, mbuf_freem(m3); if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, getret, &nva); - return (0); + goto out; } } vput(vp); @@ -742,9 +759,13 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram, nd->nd_mb = m2; nd->nd_bpos = NFSMTOD(m2, caddr_t) + mbuf_len(m2); } + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -769,7 +790,7 @@ nfsrvd_write(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_wcc(nd, forat_ret, &forat, aftat_ret, &nva); - return (0); + goto out; } if (nd->nd_flag & ND_NFSV2) { NFSM_DISSECT(tl, u_int32_t *, 4 * NFSX_UNSIGNED); @@ -862,7 +883,7 @@ nfsrvd_write(struct nfsrv_descript *nd, __unused int isdgram, vput(vp); if (nd->nd_flag & ND_NFSV3) nfsrv_wcc(nd, forat_ret, &forat, aftat_ret, &nva); - return (0); + goto out; } /* @@ -888,7 +909,7 @@ nfsrvd_write(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_flag & ND_NFSV3) nfsrv_wcc(nd, forat_ret, &forat, aftat_ret, &nva); if (nd->nd_repstat) - return (0); + goto out; NFSM_BUILD(tl, u_int32_t *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(retlen); if (stable == NFSWRITE_UNSTABLE) @@ -904,9 +925,13 @@ nfsrvd_write(struct nfsrv_descript *nd, __unused int isdgram, *tl = txdr_unsigned(nfsboottime.tv_usec); } else if (!nd->nd_repstat) nfsrv_fillattr(nd, &nva); + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -936,17 +961,14 @@ nfsrvd_create(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE, LOCKPARENT | LOCKLEAF | SAVESTART); nfsvno_setpathbuf(&named, &bufp, &hashp); error = nfsrv_parsename(nd, bufp, hashp, &named.ni_pathlen); - if (error) { - vput(dp); - nfsvno_relpathbuf(&named); - return (error); - } + if (error) + goto nfsmout; if (!nd->nd_repstat) { NFSVNO_ATTRINIT(&nva); if (nd->nd_flag & ND_NFSV2) { @@ -1001,7 +1023,7 @@ nfsrvd_create(struct nfsrv_descript *nd, __unused int isdgram, &diraft); } vput(dp); - return (0); + goto out; } nd->nd_repstat = nfsvno_namei(nd, &named, dp, 1, exp, p, &dirp); @@ -1020,7 +1042,7 @@ nfsrvd_create(struct nfsrv_descript *nd, __unused int isdgram, &diraft); if (dirp) vrele(dirp); - return (0); + goto out; } if (!(nd->nd_flag & ND_NFSV2)) { @@ -1074,10 +1096,14 @@ nfsrvd_create(struct nfsrv_descript *nd, __unused int isdgram, } nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); } + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(dp); nfsvno_relpathbuf(&named); + NFSEXITCODE2(error, nd); return (error); } @@ -1106,7 +1132,7 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, cnflags = (LOCKPARENT | SAVESTART); if (nd->nd_repstat) { nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } #ifdef NFS4_ACL_EXTATTR_NAME aclp = acl_alloc(M_WAITOK); @@ -1124,13 +1150,8 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, case NFLNK: error = nfsvno_getsymlink(nd, &nva, p, &pathcp, &pathlen); - if (error) { - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - return (error); - } + if (error) + goto nfsmout; break; case NFCHR: case NFBLK: @@ -1151,38 +1172,22 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, #ifdef NFS4_ACL_EXTATTR_NAME acl_free(aclp); #endif - return (0); - }; + goto out; + } } NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE, cnflags); nfsvno_setpathbuf(&named, &bufp, &hashp); error = nfsrv_parsename(nd, bufp, hashp, &named.ni_pathlen); - if (error) { - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - nfsvno_relpathbuf(&named); - if (pathcp) - FREE(pathcp, M_TEMP); - return (error); - } + if (error) + goto nfsmout; if (!nd->nd_repstat) { if (nd->nd_flag & ND_NFSV3) { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); vtyp = nfsv34tov_type(*tl); } error = nfsrv_sattr(nd, &nva, &attrbits, aclp, p); - if (error) { - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - nfsvno_relpathbuf(&named); - if (pathcp) - FREE(pathcp, M_TEMP); - return (error); - } + if (error) + goto nfsmout; nva.na_type = vtyp; if (!nd->nd_repstat && (nd->nd_flag & ND_NFSV3) && (vtyp == VCHR || vtyp == VBLK)) { @@ -1211,7 +1216,7 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_flag & ND_NFSV3) nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } /* @@ -1241,7 +1246,7 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_flag & ND_NFSV3) nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } if (dirp) dirfor_ret = nfsvno_getattr(dirp, &dirfor, nd->nd_cred, p, 0); @@ -1254,7 +1259,7 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, #ifdef NFS4_ACL_EXTATTR_NAME acl_free(aclp); #endif - return (0); + goto out; } else if (vtyp == VLNK) { nfsrvd_symlinksub(nd, &named, &nva, fhp, vpp, dirp, &dirfor, &diraft, &diraft_ret, &attrbits, @@ -1263,7 +1268,7 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, acl_free(aclp); #endif FREE(pathcp, M_TEMP); - return (0); + goto out; } } @@ -1302,6 +1307,9 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram, #ifdef NFS4_ACL_EXTATTR_NAME acl_free(aclp); #endif + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vrele(dp); @@ -1312,6 +1320,8 @@ nfsmout: nfsvno_relpathbuf(&named); if (pathcp) FREE(pathcp, M_TEMP); + + NFSEXITCODE2(error, nd); return (error); } @@ -1324,7 +1334,7 @@ nfsrvd_remove(struct nfsrv_descript *nd, __unused int isdgram, { struct nameidata named; u_int32_t *tl; - int error, dirfor_ret = 1, diraft_ret = 1; + int error = 0, dirfor_ret = 1, diraft_ret = 1; vnode_t dirp = NULL; struct nfsvattr dirfor, diraft; char *bufp; @@ -1332,7 +1342,7 @@ nfsrvd_remove(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, DELETE, LOCKPARENT | LOCKLEAF); @@ -1341,7 +1351,7 @@ nfsrvd_remove(struct nfsrv_descript *nd, __unused int isdgram, if (error) { vput(dp); nfsvno_relpathbuf(&named); - return (error); + goto out; } if (!nd->nd_repstat) { nd->nd_repstat = nfsvno_namei(nd, &named, dp, 1, exp, p, &dirp); @@ -1391,7 +1401,10 @@ nfsrvd_remove(struct nfsrv_descript *nd, __unused int isdgram, txdr_hyper(diraft.na_filerev, tl); } } - return (0); + +out: + NFSEXITCODE2(error, nd); + return (error); } /* @@ -1403,7 +1416,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, struct nfsexstuff *toexp) { u_int32_t *tl; - int error, fdirfor_ret = 1, fdiraft_ret = 1; + int error = 0, fdirfor_ret = 1, fdiraft_ret = 1; int tdirfor_ret = 1, tdiraft_ret = 1; struct nameidata fromnd, tond; vnode_t fdirp = NULL, tdirp = NULL, tdp = NULL; @@ -1416,7 +1429,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, if (nd->nd_repstat) { nfsrv_wcc(nd, fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); nfsrv_wcc(nd, tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft); - return (0); + goto out; } if (!(nd->nd_flag & ND_NFSV2)) fdirfor_ret = nfsvno_getattr(dp, &fdirfor, nd->nd_cred, p, 1); @@ -1430,7 +1443,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, if (todp) vrele(todp); nfsvno_relpathbuf(&fromnd); - return (error); + goto out; } if (nd->nd_flag & ND_NFSV4) { tdp = todp; @@ -1442,7 +1455,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, vput(dp); /* todp is always NULL except NFSv4 */ nfsvno_relpathbuf(&fromnd); - return (error); + goto out; } nd->nd_cred->cr_uid = nd->nd_saveduid; nfsd_fhtovp(nd, &tfh, LK_EXCLUSIVE, &tdp, &tnes, NULL, 0, p); @@ -1462,7 +1475,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, vput(dp); nfsvno_relpathbuf(&fromnd); nfsvno_relpathbuf(&tond); - return (error); + goto out; } } if (nd->nd_repstat) { @@ -1477,7 +1490,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, vput(dp); nfsvno_relpathbuf(&fromnd); nfsvno_relpathbuf(&tond); - return (0); + goto out; } /* @@ -1496,7 +1509,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, if (tdp) vrele(tdp); nfsvno_relpathbuf(&tond); - return (0); + goto out; } if (vnode_vtype(fromnd.ni_vp) == VDIR) tond.ni_cnd.cn_flags |= WILLBEDIR; @@ -1528,7 +1541,10 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, tl += 2; txdr_hyper(tdiraft.na_filerev, tl); } - return (0); + +out: + NFSEXITCODE2(error, nd); + return (error); } /* @@ -1552,7 +1568,7 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram, if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &at); nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } NFSVOPUNLOCK(vp, 0); if (vnode_vtype(vp) == VDIR) { @@ -1579,7 +1595,7 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram, if (error) { vrele(vp); /* tovp is always NULL unless NFSv4 */ - return (error); + goto out; } nfsd_fhtovp(nd, &dfh, LK_EXCLUSIVE, &dp, &tnes, NULL, 0, p); @@ -1597,7 +1613,7 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram, if (dp) vrele(dp); nfsvno_relpathbuf(&named); - return (error); + goto out; } if (!nd->nd_repstat) { nd->nd_repstat = nfsvno_namei(nd, &named, dp, 0, &tnes, @@ -1636,7 +1652,10 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram, tl += 2; txdr_hyper(diraft.na_filerev, tl); } - return (0); + +out: + NFSEXITCODE2(error, nd); + return (error); } /* @@ -1649,14 +1668,14 @@ nfsrvd_symlink(struct nfsrv_descript *nd, __unused int isdgram, { struct nfsvattr nva, dirfor, diraft; struct nameidata named; - int error, dirfor_ret = 1, diraft_ret = 1, pathlen; + int error = 0, dirfor_ret = 1, diraft_ret = 1, pathlen; vnode_t dirp = NULL; char *bufp, *pathcp = NULL; u_long *hashp; if (nd->nd_repstat) { nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } if (vpp) *vpp = NULL; @@ -1670,7 +1689,7 @@ nfsrvd_symlink(struct nfsrv_descript *nd, __unused int isdgram, if (error) { vrele(dp); nfsvno_relpathbuf(&named); - return (error); + goto out; } if (!nd->nd_repstat) { nd->nd_repstat = nfsvno_namei(nd, &named, dp, 0, exp, p, &dirp); @@ -1708,7 +1727,10 @@ nfsrvd_symlink(struct nfsrv_descript *nd, __unused int isdgram, } nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); } - return (0); + +out: + NFSEXITCODE2(error, nd); + return (error); } /* @@ -1752,6 +1774,8 @@ nfsrvd_symlinksub(struct nfsrv_descript *nd, struct nameidata *ndp, txdr_hyper(diraftp->na_filerev, tl); (void) nfsrv_putattrbit(nd, attrbitp); } + + NFSEXITCODE2(0, nd); } /* @@ -1765,33 +1789,27 @@ nfsrvd_mkdir(struct nfsrv_descript *nd, __unused int isdgram, struct nfsvattr nva, dirfor, diraft; struct nameidata named; u_int32_t *tl; - int error, dirfor_ret = 1, diraft_ret = 1; + int error = 0, dirfor_ret = 1, diraft_ret = 1; vnode_t dirp = NULL; char *bufp; u_long *hashp; if (nd->nd_repstat) { nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE, LOCKPARENT | SAVENAME); nfsvno_setpathbuf(&named, &bufp, &hashp); error = nfsrv_parsename(nd, bufp, hashp, &named.ni_pathlen); - if (error) { - vrele(dp); - nfsvno_relpathbuf(&named); - return (error); - } + if (error) + goto nfsmout; if (!nd->nd_repstat) { NFSVNO_ATTRINIT(&nva); if (nd->nd_flag & ND_NFSV3) { error = nfsrv_sattr(nd, &nva, NULL, NULL, p); - if (error) { - vrele(dp); - nfsvno_relpathbuf(&named); - return (error); - } + if (error) + goto nfsmout; } else { NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); nva.na_mode = nfstov_mode(*tl++); @@ -1816,7 +1834,7 @@ nfsrvd_mkdir(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_flag & ND_NFSV3) nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft); - return (0); + goto out; } if (dirp != NULL) dirfor_ret = nfsvno_getattr(dirp, &dirfor, nd->nd_cred, p, 0); @@ -1837,10 +1855,14 @@ nfsrvd_mkdir(struct nfsrv_descript *nd, __unused int isdgram, (void) nfsm_fhtom(nd, (u_int8_t *)fhp, 0, 0); nfsrv_fillattr(nd, &nva); } + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vrele(dp); nfsvno_relpathbuf(&named); + NFSEXITCODE2(error, nd); return (error); } @@ -1886,6 +1908,8 @@ nfsrvd_mkdirsub(struct nfsrv_descript *nd, struct nameidata *ndp, txdr_hyper(diraftp->na_filerev, tl); (void) nfsrv_putattrbit(nd, attrbitp); } + + NFSEXITCODE2(0, nd); } /* @@ -1902,7 +1926,7 @@ nfsrvd_commit(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_wcc(nd, for_ret, &bfor, aft_ret, &aft); - return (0); + goto out; } NFSM_DISSECT(tl, u_int32_t *, 3 * NFSX_UNSIGNED); /* @@ -1925,9 +1949,13 @@ nfsrvd_commit(struct nfsrv_descript *nd, __unused int isdgram, *tl++ = txdr_unsigned(nfsboottime.tv_sec); *tl = txdr_unsigned(nfsboottime.tv_usec); } + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -1947,7 +1975,7 @@ nfsrvd_statfs(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &at); - return (0); + goto out; } sf = &sfs; nd->nd_repstat = nfsvno_statfs(vp, sf); @@ -1956,7 +1984,7 @@ nfsrvd_statfs(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, getret, &at); if (nd->nd_repstat) - return (0); + goto out; if (nd->nd_flag & ND_NFSV2) { NFSM_BUILD(tl, u_int32_t *, NFSX_V2STATFS); *tl++ = txdr_unsigned(NFS_V2MAXDATA); @@ -1983,6 +2011,9 @@ nfsrvd_statfs(struct nfsrv_descript *nd, __unused int isdgram, txdr_hyper(tval, tl); tl += 2; *tl = 0; } + +out: + NFSEXITCODE2(0, nd); return (0); } @@ -2000,7 +2031,7 @@ nfsrvd_fsinfo(struct nfsrv_descript *nd, int isdgram, if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &at); - return (0); + goto out; } getret = nfsvno_getattr(vp, &at, nd->nd_cred, p, 1); nfsvno_getfs(&fs, isdgram); @@ -2019,6 +2050,9 @@ nfsrvd_fsinfo(struct nfsrv_descript *nd, int isdgram, txdr_nfsv3time(&fs.fs_timedelta, tl); tl += 2; *tl = txdr_unsigned(fs.fs_properties); + +out: + NFSEXITCODE2(0, nd); return (0); } @@ -2036,7 +2070,7 @@ nfsrvd_pathconf(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &at); - return (0); + goto out; } nd->nd_repstat = nfsvno_pathconf(vp, _PC_LINK_MAX, &linkmax, nd->nd_cred, p); @@ -2067,6 +2101,9 @@ nfsrvd_pathconf(struct nfsrv_descript *nd, __unused int isdgram, pc->pc_caseinsensitive = newnfs_false; pc->pc_casepreserving = newnfs_true; } + +out: + NFSEXITCODE2(0, nd); return (0); } @@ -2236,11 +2273,13 @@ nfsrvd_lock(struct nfsrv_descript *nd, __unused int isdgram, (void) nfsm_strtom(nd, cf.cl_owner, cf.cl_ownerlen); } vput(vp); + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); if (stp) free((caddr_t)stp, M_NFSDSTATE); + NFSEXITCODE2(error, nd); return (error); } @@ -2344,11 +2383,13 @@ nfsrvd_lockt(struct nfsrv_descript *nd, __unused int isdgram, } } vput(vp); + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); if (stp) free((caddr_t)stp, M_NFSDSTATE); + NFSEXITCODE2(error, nd); return (error); } @@ -2442,6 +2483,7 @@ nfsrvd_locku(struct nfsrv_descript *nd, __unused int isdgram, } nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -2481,11 +2523,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, i = fxdr_unsigned(int, *(tl + 5)); if (i <= 0 || i > NFSV4_OPAQUELIMIT) { nd->nd_repstat = NFSERR_BADXDR; - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - return (0); + goto nfsmout; } MALLOC(stp, struct nfsstate *, sizeof (struct nfsstate) + i, M_NFSDSTATE, M_WAITOK); @@ -2534,14 +2572,8 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, nd->nd_clientid.qval = clientid.qval; } error = nfsrv_mtostr(nd, stp->ls_owner, stp->ls_ownerlen); - if (error) { - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - FREE((caddr_t)stp, M_NFSDSTATE); - return (error); - } + if (error) + goto nfsmout; NFSVNO_ATTRINIT(&nva); NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); create = fxdr_unsigned(int, *tl); @@ -2556,14 +2588,8 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, case NFSCREATE_UNCHECKED: case NFSCREATE_GUARDED: error = nfsv4_sattr(nd, &nva, &attrbits, aclp, p); - if (error) { - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - FREE((caddr_t)stp, M_NFSDSTATE); - return (error); - } + if (error) + goto nfsmout; /* * If the na_gid being set is the same as that of * the directory it is going in, clear it, since @@ -2583,21 +2609,11 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, break; default: nd->nd_repstat = NFSERR_BADXDR; - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - FREE((caddr_t)stp, M_NFSDSTATE); - return (0); + goto nfsmout; }; } else if (create != NFSV4OPEN_NOCREATE) { nd->nd_repstat = NFSERR_BADXDR; - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - FREE((caddr_t)stp, M_NFSDSTATE); - return (0); + goto nfsmout; } /* @@ -2623,12 +2639,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, if (nd->nd_repstat) { nd->nd_repstat = nfsrv_opencheck(clientid, &stateid, stp, NULL, nd, p, nd->nd_repstat); - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - FREE((caddr_t)stp, M_NFSDSTATE); - return (0); + goto nfsmout; } if (create == NFSV4OPEN_CREATE) NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE, @@ -2645,6 +2656,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, #endif FREE((caddr_t)stp, M_NFSDSTATE); nfsvno_relpathbuf(&named); + NFSEXITCODE2(error, nd); return (error); } if (!nd->nd_repstat) { @@ -2694,12 +2706,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, break; default: nd->nd_repstat = NFSERR_BADXDR; - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - FREE((caddr_t)stp, M_NFSDSTATE); - return (0); + goto nfsmout; }; stp->ls_flags |= NFSLCK_RECLAIM; vp = dp; @@ -2711,12 +2718,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, nd->nd_repstat = NFSERR_PERM; } else { nd->nd_repstat = NFSERR_BADXDR; - vrele(dp); -#ifdef NFS4_ACL_EXTATTR_NAME - acl_free(aclp); -#endif - FREE((caddr_t)stp, M_NFSDSTATE); - return (0); + goto nfsmout; } /* @@ -2835,6 +2837,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int isdgram, #ifdef NFS4_ACL_EXTATTR_NAME acl_free(aclp); #endif + NFSEXITCODE2(0, nd); return (0); nfsmout: vrele(dp); @@ -2843,6 +2846,7 @@ nfsmout: #endif if (stp) FREE((caddr_t)stp, M_NFSDSTATE); + NFSEXITCODE2(error, nd); return (error); } @@ -2884,9 +2888,11 @@ nfsrvd_close(struct nfsrv_descript *nd, __unused int isdgram, *tl++ = txdr_unsigned(stateid.seqid); NFSBCOPY((caddr_t)stateid.other,(caddr_t)tl,NFSX_STATEIDOTHER); } + NFSEXITCODE2(0, nd); return (0); nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -2903,7 +2909,7 @@ nfsrvd_delegpurge(struct nfsrv_descript *nd, __unused int isdgram, if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) { nd->nd_repstat = NFSERR_WRONGSEC; - return (0); + goto nfsmout; } NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED); clientid.lval[0] = *tl++; @@ -2918,6 +2924,7 @@ nfsrvd_delegpurge(struct nfsrv_descript *nd, __unused int isdgram, nd->nd_repstat = nfsrv_delegupdate(clientid, NULL, NULL, NFSV4OP_DELEGPURGE, nd->nd_cred, p); nfsmout: + NFSEXITCODE2(error, nd); return (error); } @@ -2949,6 +2956,7 @@ nfsrvd_delegreturn(struct nfsrv_descript *nd, __unused int isdgram, NFSV4OP_DELEGRETURN, nd->nd_cred, p); nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -2965,6 +2973,7 @@ nfsrvd_getfh(struct nfsrv_descript *nd, __unused int isdgram, vput(vp); if (!nd->nd_repstat) (void) nfsm_fhtom(nd, (u_int8_t *)&fh, 0, 0); + NFSEXITCODE2(0, nd); return (0); } @@ -3008,6 +3017,7 @@ nfsrvd_openconfirm(struct nfsrv_descript *nd, __unused int isdgram, } nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -3085,6 +3095,7 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unused int isdgram, } nfsmout: vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -3101,7 +3112,7 @@ nfsrvd_renew(struct nfsrv_descript *nd, __unused int isdgram, if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) { nd->nd_repstat = NFSERR_WRONGSEC; - return (0); + goto nfsmout; } NFSM_DISSECT(tl, u_int32_t *, NFSX_HYPER); clientid.lval[0] = *tl++; @@ -3116,6 +3127,7 @@ nfsrvd_renew(struct nfsrv_descript *nd, __unused int isdgram, nd->nd_repstat = nfsrv_getclient(clientid, (CLOPS_RENEWOP|CLOPS_RENEW), NULL, (nfsquad_t)((u_quad_t)0), nd, p); nfsmout: + NFSEXITCODE2(error, nd); return (error); } @@ -3133,7 +3145,7 @@ nfsrvd_secinfo(struct nfsrv_descript *nd, int isdgram, struct nfsrvfh fh; struct nfsexstuff retnes; u_int32_t *sizp; - int error, savflag, i; + int error = 0, savflag, i; char *bufp; u_long *hashp; @@ -3147,7 +3159,7 @@ nfsrvd_secinfo(struct nfsrv_descript *nd, int isdgram, if (error) { vput(dp); nfsvno_relpathbuf(&named); - return (error); + goto out; } if (!nd->nd_repstat) { nd->nd_repstat = nfsvno_namei(nd, &named, dp, 1, exp, p, &dirp); @@ -3158,7 +3170,7 @@ nfsrvd_secinfo(struct nfsrv_descript *nd, int isdgram, if (dirp) vrele(dirp); if (nd->nd_repstat) - return (0); + goto out; vrele(named.ni_startdir); nfsvno_relpathbuf(&named); fh.nfsrvfh_len = NFSX_MYFH; @@ -3173,7 +3185,7 @@ nfsrvd_secinfo(struct nfsrv_descript *nd, int isdgram, } nd->nd_flag = savflag; if (nd->nd_repstat) - return (0); + goto out; /* * Finally have the export flags for name, so we can create @@ -3216,7 +3228,10 @@ nfsrvd_secinfo(struct nfsrv_descript *nd, int isdgram, } } *sizp = txdr_unsigned(len); - return (0); + +out: + NFSEXITCODE2(error, nd); + return (error); } /* @@ -3236,7 +3251,7 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused int isdgram, if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) { nd->nd_repstat = NFSERR_WRONGSEC; - return (0); + goto out; } NFSM_DISSECT(tl, u_int32_t *, NFSX_VERF + NFSX_UNSIGNED); verf = (u_char *)tl; @@ -3244,7 +3259,7 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused int isdgram, i = fxdr_unsigned(int, *tl); if (i > NFSV4_OPAQUELIMIT || i <= 0) { nd->nd_repstat = NFSERR_BADXDR; - return (error); + goto nfsmout; } idlen = i; if (nd->nd_flag & ND_GSS) @@ -3320,6 +3335,9 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused int isdgram, *tl++ = confirm.lval[0]; *tl = confirm.lval[1]; } + +out: + NFSEXITCODE2(0, nd); return (0); nfsmout: if (clp) { @@ -3327,6 +3345,7 @@ nfsmout: NFSFREEMUTEX(&clp->lc_req.nr_mtx); free((caddr_t)clp, M_NFSDCLIENT); } + NFSEXITCODE2(error, nd); return (error); } @@ -3344,7 +3363,7 @@ nfsrvd_setclientidcfrm(struct nfsrv_descript *nd, if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) { nd->nd_repstat = NFSERR_WRONGSEC; - return (0); + goto nfsmout; } NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_HYPER); clientid.lval[0] = *tl++; @@ -3359,6 +3378,7 @@ nfsrvd_setclientidcfrm(struct nfsrv_descript *nd, nd->nd_repstat = nfsrv_getclient(clientid, (CLOPS_CONFIRM|CLOPS_RENEW), NULL, confirm, nd, p); nfsmout: + NFSEXITCODE2(error, nd); return (error); } @@ -3395,6 +3415,7 @@ nfsrvd_verify(struct nfsrv_descript *nd, int isdgram, } } vput(vp); + NFSEXITCODE2(error, nd); return (error); } @@ -3414,6 +3435,7 @@ nfsrvd_openattr(struct nfsrv_descript *nd, __unused int isdgram, nd->nd_repstat = NFSERR_NOTSUPP; nfsmout: vrele(dp); + NFSEXITCODE2(error, nd); return (error); } @@ -3431,13 +3453,13 @@ nfsrvd_releaselckown(struct nfsrv_descript *nd, __unused int isdgram, if (nfs_rootfhset == 0 || nfsd_checkrootexp(nd) != 0) { nd->nd_repstat = NFSERR_WRONGSEC; - return (0); + goto nfsmout; } NFSM_DISSECT(tl, u_int32_t *, 3 * NFSX_UNSIGNED); len = fxdr_unsigned(int, *(tl + 2)); if (len <= 0 || len > NFSV4_OPAQUELIMIT) { nd->nd_repstat = NFSERR_BADXDR; - return (0); + goto nfsmout; } MALLOC(stp, struct nfsstate *, sizeof (struct nfsstate) + len, M_NFSDSTATE, M_WAITOK); @@ -3459,9 +3481,12 @@ nfsrvd_releaselckown(struct nfsrv_descript *nd, __unused int isdgram, goto nfsmout; nd->nd_repstat = nfsrv_releaselckown(stp, clientid, p); FREE((caddr_t)stp, M_NFSDSTATE); + + NFSEXITCODE2(0, nd); return (0); nfsmout: if (stp) free((caddr_t)stp, M_NFSDSTATE); + NFSEXITCODE2(error, nd); return (error); } |