Module Name: src Committed By: martin Date: Tue Dec 12 16:48:59 UTC 2023
Modified Files: src/sys/nfs [netbsd-8]: nfs_vnops.c Log Message: Pull up following revision(s) (requested by schmonz in ticket #1927): sys/nfs/nfs_vnops.c: revision 1.325 NFS client: fix interop with macOS 14 servers. Symptom: a bunch of "Cannot open `.' (Invalid argument)". thorpej@ analysis and fix: on the first request to read a given directory, make sure READDIR and READDIRPLUS cookie verifiers are being set to 0. This is in RFC1813 and macOS must have gotten stricter about it. Verified on 10.0_RC1/aarch64 to fix the reproducers in PR kern/57691 as well as the original use case in which I met the bug: pkg_rr once again runs to completion. To generate a diff of this commit: cvs rdiff -u -r1.310 -r1.310.4.1 src/sys/nfs/nfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/nfs/nfs_vnops.c diff -u src/sys/nfs/nfs_vnops.c:1.310 src/sys/nfs/nfs_vnops.c:1.310.4.1 --- src/sys/nfs/nfs_vnops.c:1.310 Wed Apr 26 03:02:49 2017 +++ src/sys/nfs/nfs_vnops.c Tue Dec 12 16:48:59 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_vnops.c,v 1.310 2017/04/26 03:02:49 riastradh Exp $ */ +/* $NetBSD: nfs_vnops.c,v 1.310.4.1 2023/12/12 16:48:59 martin Exp $ */ /* * Copyright (c) 1989, 1993 @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.310 2017/04/26 03:02:49 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.310.4.1 2023/12/12 16:48:59 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_nfs.h" @@ -2466,8 +2466,13 @@ nfs_readdirrpc(struct vnode *vp, struct 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]; + } } else #endif { @@ -2676,8 +2681,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);