Re: kern/57691: NFS client regression with macOS 14 server

2023-12-08 Thread Amitai Schleier

On 8 Dec 2023, at 14:17, Jason Thorpe wrote:


On Dec 8, 2023, at 10:55 AM, Jason Thorpe  wrote:

Probably what’s going on is that the server is verifying the 
directory cookie more strictly than before.  Those two lines that 
pack the cookieverf should be inserting 0s if uno_offset is 0.


Just confirmed by code inspection that FreeBSD always sends a 0 cookie 
verifier for uio_offset 0.



if (cookie.qval == 0) {
*tl++ = 0;
*tl++ = 0;
} else {



Thank you for looking into this and giving me something to try. Neither 
of the following diffs seems to make a difference, though (tested on my 
10.0_RC1/aarch64 NFS client). Have I misunderstood something?



Index: nfs/nfs_vnops.c
===
RCS file: /cvsroot/src/sys/nfs/nfs_vnops.c,v
retrieving revision 1.324
diff -u -p -r1.324 nfs_vnops.c
--- nfs/nfs_vnops.c 24 May 2022 06:28:02 -  1.324
+++ nfs/nfs_vnops.c 9 Dec 2023 03:23:02 -
@@ -2632,8 +2632,13 @@ nfs_readdirplusrpc(struct vnode *vp, str
txdr_cookie3(uiop->uio_offset, tl);
}
tl += 2;
-   *tl++ = dnp->n_cookieverf.nfsuquad[0];
-   *tl++ = dnp->n_cookieverf.nfsuquad[1];
+   if (uiop->uio_offset == 0) {
+   *tl++ = 0;
+   *tl++ = 0;
+   } else {
+   *tl++ = dnp->n_cookieverf.nfsuquad[0];
+   *tl++ = dnp->n_cookieverf.nfsuquad[1];
+   }
*tl++ = txdr_unsigned(nmp->nm_readdirsize);
*tl = txdr_unsigned(nmp->nm_rsize);
nfsm_request(dnp, NFSPROC_READDIRPLUS, curlwp, cred);



Index: nfs/nfs_vnops.c
===
RCS file: /cvsroot/src/sys/nfs/nfs_vnops.c,v
retrieving revision 1.324
diff -u -p -r1.324 nfs_vnops.c
--- nfs/nfs_vnops.c 24 May 2022 06:28:02 -  1.324
+++ nfs/nfs_vnops.c 9 Dec 2023 03:12:56 -
@@ -2632,6 +2632,10 @@ nfs_readdirplusrpc(struct vnode *vp, str
txdr_cookie3(uiop->uio_offset, tl);
}
tl += 2;
+   if (uiop->uio_offset == 0) {
+   dnp->n_cookieverf.nfsuquad[0] = 0;
+   dnp->n_cookieverf.nfsuquad[1] = 0;
+   }
*tl++ = dnp->n_cookieverf.nfsuquad[0];
*tl++ = dnp->n_cookieverf.nfsuquad[1];
*tl++ = txdr_unsigned(nmp->nm_readdirsize);


Re: kern/57691: NFS client regression with macOS 14 server

2023-12-08 Thread Jason Thorpe


> On Dec 8, 2023, at 10:55 AM, Jason Thorpe  wrote:
> 
> Probably what’s going on is that the server is verifying the directory cookie 
> more strictly than before.  Those two lines that pack the cookieverf should 
> be inserting 0s if uno_offset is 0.

Just confirmed by code inspection that FreeBSD always sends a 0 cookie verifier 
for uio_offset 0.


if (cookie.qval == 0) {
*tl++ = 0;
*tl++ = 0;
} else {


(From their nfsrpc_readdirplus().)

-- thorpej



Re: kern/57691: NFS client regression with macOS 14 server

2023-12-08 Thread Jason Thorpe


> On Nov 10, 2023, at 11:10 AM, schm...@netbsd.org  wrote:
> 
> tcpdump of "ls" after the problem has manifested:
> https://netbsd.schmonz.com/tmp/nfs/ls-after-the-problem-tcpdump.txt

The tcpdump shows:

16:16:35.683996 IP 10.0.2.2.shilp > 10.0.2.15.exp2: Flags [P.], seq 1573:1693, 
ack 1508, win 65535, length 120: NFS reply xid 834502658 reply ok 116 readdir 
ERROR: READDIR/READDIRPLUS cookie is stale

Looking at the code that issues READDIRPLUS in the kernel in 
nfs_readdirplusrpc():

if (nmp->nm_iflag & NFSMNT_SWAPCOOKIE) {
txdr_swapcookie3(uiop->uio_offset, tl);
} else {
txdr_cookie3(uiop->uio_offset, tl);
}
tl += 2;
*tl++ = dnp->n_cookieverf.nfsuquad[0];
*tl++ = dnp->n_cookieverf.nfsuquad[1];
*tl++ = txdr_unsigned(nmp->nm_readdirsize);

I think the cookie verifier is wrong.  See: 
https://www.rfc-editor.org/rfc/rfc1813#page-81

  cookieverf
This should be set to 0 on the first request to read a
directory. On subsequent requests, it should be a
cookieverf as returned by the server. The cookieverf
must match that returned by the READDIRPLUS call in
which the cookie was acquired.

Probably what’s going on is that the server is verifying the directory cookie 
more strictly than before.  Those two lines that pack the cookieverf should be 
inserting 0s if uno_offset is 0.

-- thorpej