Fix some bugs in NQNFS (malformed RPC requests, no directory lease eviction);
authorderaadt <deraadt@openbsd.org>
Fri, 18 Apr 1997 10:02:36 +0000 (10:02 +0000)
committerderaadt <deraadt@openbsd.org>
Fri, 18 Apr 1997 10:02:36 +0000 (10:02 +0000)
fvdl

sys/nfs/nfs_nqlease.c

index d2628f0..acb88b0 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: nfs_nqlease.c,v 1.7 1996/06/01 04:43:58 mickey Exp $  */
+/*     $OpenBSD: nfs_nqlease.c,v 1.8 1997/04/18 10:02:36 deraadt Exp $ */
 /*     $NetBSD: nfs_nqlease.c,v 1.14 1996/02/18 14:06:50 fvdl Exp $    */
 
 /*
@@ -456,9 +456,10 @@ nqsrv_send_eviction(vp, lp, slp, nam, cred)
        struct mbuf *mreq, *mb, *mb2, *nam2, *mheadend;
        struct socket *so;
        struct sockaddr_in *saddr;
+       nfsfh_t nfh;
        fhandle_t *fhp;
        caddr_t bpos, cp;
-       u_int32_t xid;
+       u_int32_t xid, *tl;
        int len = 1, ok = 1, i = 0;
        int sotype, *solockp;
 
@@ -489,12 +490,12 @@ nqsrv_send_eviction(vp, lp, slp, nam, cred)
                        else
                                solockp = (int *)0;
                        nfsm_reqhead((struct vnode *)0, NQNFSPROC_EVICTED,
-                               NFSX_V3FH);
-                       nfsm_build(cp, caddr_t, NFSX_V3FH);
-                       bzero(cp, NFSX_V3FH);
-                       fhp = (fhandle_t *)cp;
+                           NFSX_V3FH + NFSX_UNSIGNED);
+                       fhp = &nfh.fh_generic;
+                       bzero((caddr_t)fhp, sizeof(nfh));
                        fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
                        VFS_VPTOFH(vp, &fhp->fh_fid);
+                       nfsm_srvfhtom(fhp, 1);
                        m = mreq;
                        siz = 0;
                        while (m) {
@@ -834,7 +835,7 @@ nqnfs_getlease(vp, rwflag, cred, p)
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
        int cachable;
        u_quad_t frev;
-       
+
        nfsstats.rpccnt[NQNFSPROC_GETLEASE]++;
        mb = mreq = nfsm_reqh(vp, NQNFSPROC_GETLEASE, NFSX_V3FH+2*NFSX_UNSIGNED,
                 &bpos);
@@ -877,10 +878,10 @@ nqnfs_vacated(vp, cred)
        struct mbuf *mreq, *mb, *mb2, *mheadend;
        struct nfsmount *nmp;
        struct nfsreq myrep;
-       
+
        nmp = VFSTONFS(vp->v_mount);
        nfsstats.rpccnt[NQNFSPROC_VACATED]++;
-       nfsm_reqhead(vp, NQNFSPROC_VACATED, NFSX_V3FH);
+       nfsm_reqhead(vp, NQNFSPROC_VACATED, NFSX_FH(1));
        nfsm_fhtom(vp, 1);
        m = mreq;
        i = 0;
@@ -1055,14 +1056,16 @@ nqnfs_clientd(nmp, cred, ncd, flag, argp, p)
                             if (vpid == vp->v_id) {
                                CIRCLEQ_REMOVE(&nmp->nm_timerhead, np, n_timer);
                                np->n_timer.cqe_next = 0;
-                               if ((np->n_flag & (NMODIFIED | NQNFSEVICTED))
-                                   && vp->v_type == VREG) {
+                               if (np->n_flag & (NMODIFIED | NQNFSEVICTED)) {
                                        if (np->n_flag & NQNFSEVICTED) {
+                                               if (vp->v_type == VDIR)
+                                                       nfs_invaldir(vp);
+                                               cache_purge(vp);
                                                (void) nfs_vinvalbuf(vp,
                                                       V_SAVE, cred, p, 0);
                                                np->n_flag &= ~NQNFSEVICTED;
                                                (void) nqnfs_vacated(vp, cred);
-                                       } else {
+                                       } else if (vp->v_type == VREG) {
                                                (void) VOP_FSYNC(vp, cred,
                                                    MNT_WAIT, p);
                                                np->n_flag &= ~NMODIFIED;