CVS commit: src/external/apache2/mDNSResponder/dist/mDNSPosix

2023-12-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Dec 13 07:15:41 UTC 2023

Modified Files:
src/external/apache2/mDNSResponder/dist/mDNSPosix: mDNSPosix.c

Log Message:
mDNSPlatformInit(): If we fail to create an IPv6 socket, ignore the
error and just continue without IPv6 support.

PR bin/57769


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
src/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/apache2/mDNSResponder/dist/mDNSPosix

2023-12-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Dec 13 07:15:41 UTC 2023

Modified Files:
src/external/apache2/mDNSResponder/dist/mDNSPosix: mDNSPosix.c

Log Message:
mDNSPlatformInit(): If we fail to create an IPv6 socket, ignore the
error and just continue without IPv6 support.

PR bin/57769


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
src/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c
diff -u src/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c:1.19 src/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c:1.20
--- src/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c:1.19	Tue Aug 15 00:02:16 2023
+++ src/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c	Wed Dec 13 07:15:40 2023
@@ -1324,7 +1324,16 @@ mDNSexport mStatus mDNSPlatformInit(mDNS
 #if HAVE_IPV6
 sa.sa_family = AF_INET6;
 m->p->unicastSocket6 = -1;
-if (err == mStatus_NoError) err = SetupSocket(, zeroIPPort, 0, >p->unicastSocket6);
+if (err == mStatus_NoError)
+{
+	err = SetupSocket(, zeroIPPort, 0, >p->unicastSocket6);
+	if (err != mStatus_NoError)
+	{
+	// Ignore errors configuring IPv6.
+	m->p->unicastSocket6 = -1;
+	err = mStatus_NoError;
+	}
+}
 #endif
 
 // Tell mDNS core about the network interfaces on this machine.



CVS commit: src/sbin/gpt

2023-12-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 13 06:51:57 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
avoid use after free.  skip the QUIET check already in gpt_warn().


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.86 src/sbin/gpt/gpt.c:1.87
--- src/sbin/gpt/gpt.c:1.86	Mon Dec 11 12:45:22 2023
+++ src/sbin/gpt/gpt.c	Wed Dec 13 06:51:57 2023
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.86 2023/12/11 12:45:22 mlelstv Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.87 2023/12/13 06:51:57 mrg Exp $");
 #endif
 
 #include 
@@ -604,9 +604,8 @@ gpt_open(const char *dev, int flags, int
  close:
 	if (gpt->fd != -1)
 		close(gpt->fd);
+	gpt_warn(gpt, "No GPT found");
 	free(gpt);
-	if (!(flags & GPT_QUIET))
-		gpt_warn(gpt, "No GPT found");
 	return NULL;
 }
 



CVS commit: src/sbin/gpt

2023-12-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Dec 13 06:51:57 UTC 2023

Modified Files:
src/sbin/gpt: gpt.c

Log Message:
avoid use after free.  skip the QUIET check already in gpt_warn().


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sbin/gpt/gpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/arm32

2023-12-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 13 06:42:41 UTC 2023

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
arm: pmap: Fix clang build without DIAGNOSTIC


To generate a diff of this commit:
cvs rdiff -u -r1.440 -r1.441 src/sys/arch/arm/arm32/pmap.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/arch/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.440 src/sys/arch/arm/arm32/pmap.c:1.441
--- src/sys/arch/arm/arm32/pmap.c:1.440	Thu Oct 12 11:33:37 2023
+++ src/sys/arch/arm/arm32/pmap.c	Wed Dec 13 06:42:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.440 2023/10/12 11:33:37 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.441 2023/12/13 06:42:40 rin Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -193,7 +193,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.440 2023/10/12 11:33:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.441 2023/12/13 06:42:40 rin Exp $");
 
 #include 
 #include 
@@ -547,7 +547,7 @@ pmap_release_page_lock(struct vm_page_md
 	mutex_exit(_lock);
 }
 
-static inline int
+static inline int __diagused
 pmap_page_locked_p(struct vm_page_md *md)
 {
 	return mutex_owned(_lock);



CVS commit: src/sys/arch/arm/arm32

2023-12-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 13 06:42:41 UTC 2023

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
arm: pmap: Fix clang build without DIAGNOSTIC


To generate a diff of this commit:
cvs rdiff -u -r1.440 -r1.441 src/sys/arch/arm/arm32/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 23:38:11 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: zs.c
src/sys/arch/sun2/dev: zs.c

Log Message:
remove TTY_DEBUG code from sun2/sparc64 zs.c code. it doesn't look relevant
to this particular drivers and likely is a leftover from some historical code.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sparc64/dev/zs.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sun2/dev/zs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 23:38:11 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: zs.c
src/sys/arch/sun2/dev: zs.c

Log Message:
remove TTY_DEBUG code from sun2/sparc64 zs.c code. it doesn't look relevant
to this particular drivers and likely is a leftover from some historical code.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sparc64/dev/zs.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sun2/dev/zs.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/arch/sparc64/dev/zs.c
diff -u src/sys/arch/sparc64/dev/zs.c:1.80 src/sys/arch/sparc64/dev/zs.c:1.81
--- src/sys/arch/sparc64/dev/zs.c:1.80	Wed Oct 26 23:59:56 2022
+++ src/sys/arch/sparc64/dev/zs.c	Tue Dec 12 23:38:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.80 2022/10/26 23:59:56 riastradh Exp $	*/
+/*	$NetBSD: zs.c,v 1.81 2023/12/12 23:38:11 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.80 2022/10/26 23:59:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.81 2023/12/12 23:38:11 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -532,9 +532,6 @@ zscheckintr(void *arg)
 }
 
 
-/*
- * We need this only for TTY_DEBUG purposes.
- */
 static void
 zssoft(void *arg)
 {
@@ -545,18 +542,6 @@ zssoft(void *arg)
 	ttylock(tp);
 #endif
 	(void)zsc_intr_soft(zsc);
-#ifdef TTY_DEBUG
-	{
-		struct zstty_softc *zst0 = zsc->zsc_cs[0]->cs_private;
-		struct zstty_softc *zst1 = zsc->zsc_cs[1]->cs_private;
-		if (zst0->zst_overflows || zst1->zst_overflows ) {
-			struct trapframe *frame = (struct trapframe *)arg;
-			
-			printf("zs silo overflow from %p\n",
-			   (long)frame->tf_pc);
-		}
-	}
-#endif
 #if 0 /* not yet */
 	ttyunlock(tp);
 #endif

Index: src/sys/arch/sun2/dev/zs.c
diff -u src/sys/arch/sun2/dev/zs.c:1.25 src/sys/arch/sun2/dev/zs.c:1.26
--- src/sys/arch/sun2/dev/zs.c:1.25	Wed Oct 26 23:38:09 2022
+++ src/sys/arch/sun2/dev/zs.c	Tue Dec 12 23:38:11 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.25 2022/10/26 23:38:09 riastradh Exp $	*/
+/*	$NetBSD: zs.c,v 1.26 2023/12/12 23:38:11 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.25 2022/10/26 23:38:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.26 2023/12/12 23:38:11 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -373,9 +373,6 @@ zscheckintr(void *arg)
 }
 
 
-/*
- * We need this only for TTY_DEBUG purposes.
- */
 static void
 zssoft(void *arg)
 {
@@ -385,18 +382,7 @@ zssoft(void *arg)
 	/* Make sure we call the tty layer at spltty. */
 	s = spltty();
 	(void)zsc_intr_soft(zsc);
-#ifdef TTY_DEBUG
-	{
-		struct zstty_softc *zst0 = zsc->zsc_cs[0]->cs_private;
-		struct zstty_softc *zst1 = zsc->zsc_cs[1]->cs_private;
-		if (zst0->zst_overflows || zst1->zst_overflows ) {
-			struct trapframe *frame = arg;	/* XXX */
 
-			printf("zs silo overflow from %p\n",
-			(long)frame->tf_pc);
-		}
-	}
-#endif
 	splx(s);
 }
 



CVS commit: src/sys/arch/sparc64/dev

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 21:34:34 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
extract capacity variable to make VDSK_DEBUG enabled code build.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/vdsk.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/arch/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.10 src/sys/arch/sparc64/dev/vdsk.c:1.11
--- src/sys/arch/sparc64/dev/vdsk.c:1.10	Mon May 16 17:13:28 2022
+++ src/sys/arch/sparc64/dev/vdsk.c	Tue Dec 12 21:34:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.10 2022/05/16 17:13:28 palle Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.11 2023/12/12 21:34:34 andvar Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -1323,10 +1323,13 @@ vdsk_scsi_capacity16(struct vdsk_softc *
 {
 
 	struct scsipi_read_capacity_16_data rcd;
+	uint64_t capacity;
 
 	bzero(, sizeof(rcd));
 
-	_lto8b(sc->sc_vdisk_size - 1, rcd.addr);
+	capacity = sc->sc_vdisk_size - 1;
+
+	_lto8b(capacity, rcd.addr);
 	_lto4b(sc->sc_vdisk_block_size, rcd.length);
 
 	DPRINTF(("%s() capacity %lu  block size %u\n",



CVS commit: src/sys/arch/sparc64/dev

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 21:34:34 UTC 2023

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
extract capacity variable to make VDSK_DEBUG enabled code build.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/vdsk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sparc64/doc

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 20:24:00 UTC 2023

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
s/maked/marked/


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/sparc64/doc/TODO

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.47 src/sys/arch/sparc64/doc/TODO:1.48
--- src/sys/arch/sparc64/doc/TODO:1.47	Sat Jan 15 18:45:13 2022
+++ src/sys/arch/sparc64/doc/TODO	Tue Dec 12 20:24:00 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.47 2022/01/15 18:45:13 palle Exp $ */
+/* $NetBSD: TODO,v 1.48 2023/12/12 20:24:00 andvar Exp $ */
 
 Things to be done:
 
@@ -41,7 +41,7 @@ sun4v:
 - interrupts not handled properly (com at ebus only...)
 - mpt(4) complains: mpt0: Phy 0: Link Status Unknown
 - man pages for drivers imported from OpenBSD lke vpci, vbus, cbus, vdsk, ldc etc.
-- vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly
+- vdsk and ldc drivers: code marked with OPENBSD_BUSDMA - make the bus_dma stuff work properly
 - vbus.c: handle prom_getprop() memory leaks
 - locore.s: rft_user (sun4v specific manual fill) - seems to work, but is it good enough (compared to openbsds rft_user?
 - openfirmware interface



CVS commit: src/sys/arch/sparc64/doc

2023-12-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec 12 20:24:00 UTC 2023

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
s/maked/marked/


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/sparc64/doc/TODO

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-8] src/doc

2023-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 12 16:49:51 UTC 2023

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1927


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.213 -r1.1.2.214 src/doc/CHANGES-8.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.213 src/doc/CHANGES-8.3:1.1.2.214
--- src/doc/CHANGES-8.3:1.1.2.213	Mon Dec 11 12:30:22 2023
+++ src/doc/CHANGES-8.3	Tue Dec 12 16:49:51 2023
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES-8.3,v 1.1.2.213 2023/12/11 12:30:22 martin Exp $
+$NetBSD: CHANGES-8.3,v 1.1.2.214 2023/12/12 16:49:51 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -4141,3 +4141,9 @@ usr.bin/systat/vmstat.c1.92
 	systat(1): PR 56014: fix redraw handling.
 	[kre, ticket #1926]
 
+sys/nfs/nfs_vnops.c1.325
+
+	NFS client: PR 57691: fix RFC 1813 compliance for
+	READDIR and READDIRPLUS cookie verifiers.
+	[schmonz, ticket #1927]
+



CVS commit: [netbsd-8] src/doc

2023-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 12 16:49:51 UTC 2023

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1927


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.213 -r1.1.2.214 src/doc/CHANGES-8.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-8] src/sys/nfs

2023-12-12 Thread Martin Husemann
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 
-__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);



CVS commit: [netbsd-8] src/sys/nfs

2023-12-12 Thread Martin Husemann
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.



CVS commit: [netbsd-10] src/doc

2023-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 12 16:46:06 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #491


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.170 -r1.1.2.171 src/doc/CHANGES-10.0

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.170 src/doc/CHANGES-10.0:1.1.2.171
--- src/doc/CHANGES-10.0:1.1.2.170	Mon Dec 11 12:33:54 2023
+++ src/doc/CHANGES-10.0	Tue Dec 12 16:46:06 2023
@@ -1,5 +1,5 @@
 
-# $NetBSD: CHANGES-10.0,v 1.1.2.170 2023/12/11 12:33:54 martin Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.171 2023/12/12 16:46:06 martin Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -14295,3 +14295,12 @@ sys/nfs/nfs_vnops.c1.325
 	READDIR and READDIRPLUS cookie verifiers.
 	[schmonz, ticket #490]
 
+sbin/ifconfig/lagg.c1.4
+sys/net/lagg/if_lagg.c1.56,1.57
+
+	lagg(4):
+	 - use sadl for lagg(4) configured by a user
+	 - eliminate unnecessary reset by the change of if_flags
+	 - fix "ifconfig lagg* lagglacp -maxports" command
+	[yamaguchi, ticket #491]
+



CVS commit: [netbsd-10] src/doc

2023-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 12 16:46:06 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Ticket #491


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.170 -r1.1.2.171 src/doc/CHANGES-10.0

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-10] src

2023-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 12 16:45:00 UTC 2023

Modified Files:
src/sbin/ifconfig [netbsd-10]: lagg.c
src/sys/net/lagg [netbsd-10]: if_lagg.c

Log Message:
Pull up following revision(s) (requested by yamaguchi in ticket #491):

sys/net/lagg/if_lagg.c: revision 1.56
sys/net/lagg/if_lagg.c: revision 1.57
sbin/ifconfig/lagg.c: revision 1.4

lagg(4): use sadl for lagg(4) configured by a user

lagg(4): eliminate unnecessary reset by the change of if_flags

Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.2.1 src/sbin/ifconfig/lagg.c
cvs rdiff -u -r1.48.4.2 -r1.48.4.3 src/sys/net/lagg/if_lagg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.3 src/sbin/ifconfig/lagg.c:1.3.2.1
--- src/sbin/ifconfig/lagg.c:1.3	Thu Mar 31 01:53:22 2022
+++ src/sbin/ifconfig/lagg.c	Tue Dec 12 16:45:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.3.2.1 2023/12/12 16:45:00 martin Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.3 2022/03/31 01:53:22 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.3.2.1 2023/12/12 16:45:00 martin Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -132,27 +132,35 @@ struct piface	 laggportpri_if = PIFACE_I
 
 static const struct kwinst	 lagglacpkw[] = {
 	  {.k_word = "dumpdu", .k_key = "lacpdumpdu",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_DUMPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-dumpdu", .k_key = "lacpdumpdu",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_DUMPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "stopdu", .k_key = "lacpstopdu",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_STOPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-stopdu", .k_key = "lacpstopdu",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_STOPDU,
+	   .k_exec = setlagglacp}
 	, {.k_word = "optimistic", .k_key = "lacpoptimistic",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_OPTIMISTIC,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-optimistic", .k_key = "lacpoptimistic",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_OPTIMISTIC,
+	   .k_exec = setlagglacp}
 	, {.k_word = "maxports", .k_nextparser = _parser}
 	, {.k_word = "-maxports", .k_key = "lacpmaxports",
-	   .k_type = KW_T_INT, .k_int = 0}
+	   .k_type = KW_T_INT, .k_int = 0, .k_exec = setlagglacpmaxports}
 	, {.k_word = "multi-linkspeed", .k_key = "lacpmultils",
-	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS}
+	   .k_type = KW_T_INT, .k_int = LAGGLACPOPT_MULTILS,
+	   .k_exec = setlagglacp}
 	, {.k_word = "-multi-linkspeed", .k_key = "lacpmultils",
-	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS}
+	   .k_type = KW_T_INT, .k_int = -LAGGLACPOPT_MULTILS,
+	   .k_exec = setlagglacp}
 };
 struct pkw	 lagglacp = PKW_INITIALIZER(, "lagg-lacp-option",
-		setlagglacp, NULL, lagglacpkw, __arraycount(lagglacpkw),
+		NULL, NULL, lagglacpkw, __arraycount(lagglacpkw),
 		_root.pb_parser);
 
 static const struct kwinst	 laggfailkw[] = {

Index: src/sys/net/lagg/if_lagg.c
diff -u src/sys/net/lagg/if_lagg.c:1.48.4.2 src/sys/net/lagg/if_lagg.c:1.48.4.3
--- src/sys/net/lagg/if_lagg.c:1.48.4.2	Mon Nov 27 20:05:57 2023
+++ src/sys/net/lagg/if_lagg.c	Tue Dec 12 16:45:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.48.4.2 2023/11/27 20:05:57 martin Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.48.4.3 2023/12/12 16:45:00 martin Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.48.4.2 2023/11/27 20:05:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.48.4.3 2023/12/12 16:45:00 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -722,7 +722,6 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
 			if_stop(ifp, 1);
 			break;
 		case IFF_UP:
-		case IFF_UP | IFF_RUNNING:
 			error = if_init(ifp);
 			break;
 		}
@@ -2178,13 +2177,20 @@ lagg_port_setup(struct lagg_softc *sc,
 	struct ifnet *ifp;
 	u_char if_type;
 	int error;
-	bool stopped, is_1st_port;
+	bool stopped, use_lagg_sadl;
 
 	KASSERT(LAGG_LOCKED(sc));
 	IFNET_ASSERT_UNLOCKED(ifp_port);
 
 	ifp = >sc_if;
-	is_1st_port = SIMPLEQ_EMPTY(>sc_ports);
+
+	use_lagg_sadl = true;
+	if 

CVS commit: [netbsd-10] src

2023-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 12 16:45:00 UTC 2023

Modified Files:
src/sbin/ifconfig [netbsd-10]: lagg.c
src/sys/net/lagg [netbsd-10]: if_lagg.c

Log Message:
Pull up following revision(s) (requested by yamaguchi in ticket #491):

sys/net/lagg/if_lagg.c: revision 1.56
sys/net/lagg/if_lagg.c: revision 1.57
sbin/ifconfig/lagg.c: revision 1.4

lagg(4): use sadl for lagg(4) configured by a user

lagg(4): eliminate unnecessary reset by the change of if_flags

Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.2.1 src/sbin/ifconfig/lagg.c
cvs rdiff -u -r1.48.4.2 -r1.48.4.3 src/sys/net/lagg/if_lagg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/i386/stand/libsa

2023-12-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 12 09:16:17 UTC 2023

Modified Files:
src/sys/arch/i386/stand/libsa: nfs.c

Log Message:
Merge with generic libsa NFS code to minimize differences and to learn NFSv3.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/stand/libsa/nfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/i386/stand/libsa

2023-12-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 12 09:16:17 UTC 2023

Modified Files:
src/sys/arch/i386/stand/libsa: nfs.c

Log Message:
Merge with generic libsa NFS code to minimize differences and to learn NFSv3.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/stand/libsa/nfs.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/arch/i386/stand/libsa/nfs.c
diff -u src/sys/arch/i386/stand/libsa/nfs.c:1.19 src/sys/arch/i386/stand/libsa/nfs.c:1.20
--- src/sys/arch/i386/stand/libsa/nfs.c:1.19	Sun Dec 25 06:09:09 2011
+++ src/sys/arch/i386/stand/libsa/nfs.c	Tue Dec 12 09:16:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.c,v 1.19 2011/12/25 06:09:09 tsutsui Exp $	*/
+/*	$NetBSD: nfs.c,v 1.20 2023/12/12 09:16:17 mlelstv Exp $	*/
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -28,6 +28,16 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/*
+ * XXX Does not currently implement:
+ * XXX
+ * XXX LIBSA_NO_FS_CLOSE
+ * XXX LIBSA_NO_FS_SEEK
+ * XXX LIBSA_NO_FS_WRITE
+ * XXX LIBSA_NO_FS_SYMLINK (does this even make sense?)
+ * XXX LIBSA_FS_SINGLECOMPONENT (does this even make sense?)
+ */
+
 #include 
 #include 
 #include 
@@ -43,6 +53,7 @@
 
 #include "rpcv2.h"
 #include "nfsv2.h"
+#include "nfsv3.h"
 
 #include 
 #include "net.h"
@@ -50,40 +61,11 @@
 #include "nfs.h"
 #include "rpc.h"
 
-/* Define our own NFS attributes. */
-struct nfsv2_fattrs {
-	n_long	fa_type;
-	n_long	fa_mode;
-	n_long	fa_nlink;
-	n_long	fa_uid;
-	n_long	fa_gid;
-	n_long	fa_size;
-	n_long	fa_blocksize;
-	n_long	fa_rdev;
-	n_long	fa_blocks;
-	n_long	fa_fsid;
-	n_long	fa_fileid;
-	struct nfsv2_time fa_atime;
-	struct nfsv2_time fa_mtime;
-	struct nfsv2_time fa_ctime;
-};
-
-
-struct nfs_read_args {
-	u_char	fh[NFS_FHSIZE];
-	n_long	off;
-	n_long	len;
-	n_long	xxx;			/* XXX what's this for? */
-};
+/* Storage for any filehandle (including length for V3) */
+#define NFS_FHSTORE (NFS_FHSIZE < NFS_V3FHSIZE ? NFS_V3FHSIZE + 4: NFS_FHSIZE)
 
 /* Data part of nfs rpc reply (also the largest thing we receive) */
 #define NFSREAD_SIZE 1024
-struct nfs_read_repl {
-	n_long	errno;
-	struct	nfsv2_fattrs fa;
-	n_long	count;
-	u_char	data[NFSREAD_SIZE];
-};
 
 #ifndef NFS_NOSYMLINK
 struct nfs_readlnk_repl {
@@ -93,36 +75,88 @@ struct nfs_readlnk_repl {
 };
 #endif
 
+static inline uint64_t
+getnquad(n_long x[2]) {
+	return (uint64_t)ntohl(x[0]) << 32 | ntohl(x[1]);
+}
+
+static inline void
+setnquad(n_long x[2], uint64_t v)
+{
+	x[0] = htonl((n_long)(v >> 32));
+	x[1] = htonl((n_long)(v & 0x));
+}
+
 struct nfs_iodesc {
 	struct	iodesc	*iodesc;
 	off_t	off;
-	u_char	fh[NFS_FHSIZE];
-	struct nfsv2_fattrs fa;	/* all in network order */
+	int	version;
+	u_char	fh[NFS_FHSTORE];
+	union {
+		/* all in network order */
+		struct nfsv2_fattr v2;
+		struct nfsv3_fattr v3;
+	} u_fa;
 };
 
-int	nfs_getrootfh(struct iodesc *, char *, u_char *);
+static inline size_t
+fhstore(int version, u_char *fh)
+{
+	size_t len;
+
+	switch (version) {
+	case NFS_VER2:
+		len = NFS_FHSIZE;
+		break;
+	case NFS_VER3:
+		len = fh[0] << 24 | fh[1] << 16 | fh[2] << 8 | fh[3];
+		if (len > NFS_V3FHSIZE)
+			len = NFS_V3FHSIZE;
+		len = 4 + roundup(len, 4);
+		break;
+	default:
+		len = 0;
+		break;
+	}
+
+	return len;
+}
+
+static inline size_t
+fhcopy(int version, u_char *src, u_char *dst)
+{
+	size_t len = fhstore(version, src);
+	memcpy(dst, src, len);
+	return len;
+}
+
+#define setfh(d, s) fhcopy((d)->version, (s), (d)->fh)
+#define getfh(d, s) fhcopy((d)->version, (d)->fh, (s))
+
+
+struct nfs_iodesc nfs_root_node;
+
+int	nfs_getrootfh(struct iodesc *, char *, u_char *, int *);
 int	nfs_lookupfh(struct nfs_iodesc *, const char *, int,
 	struct nfs_iodesc *);
-#ifndef NFS_NOSYMLINK
 int	nfs_readlink(struct nfs_iodesc *, char *);
-#endif
 ssize_t	nfs_readdata(struct nfs_iodesc *, off_t, void *, size_t);
 
 /*
  * Fetch the root file handle (call mount daemon)
- * Return zero or error number.
+ * On error, return non-zero and set errno.
  */
 int
-nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp)
+nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp, int *versionp)
 {
-	size_t len;
+	int len;
 	struct args {
 		n_long	len;
 		char	path[FNAME_SIZE];
 	} *args;
 	struct repl {
 		n_long	errno;
-		u_char	fh[NFS_FHSIZE];
+		u_char	fh[NFS_FHSTORE];
 	} *repl;
 	struct {
 		n_long	h[RPC_HEADER_WORDS];
@@ -136,32 +170,42 @@ nfs_getrootfh(struct iodesc *d, char *pa
 
 #ifdef NFS_DEBUG
 	if (debug)
-		printf("nfs_getrootfh: %s\n", path);
+		printf("%s: %s\n", __func__, path);
 #endif
 
 	args = 
 	repl = 
 
-	memset(args, 0, sizeof(*args));
+	(void)memset(args, 0, sizeof(*args));
 	len = strlen(path);
-	if (len > sizeof(args->path))
+	if ((size_t)len > sizeof(args->path))
 		len = sizeof(args->path);
 	args->len = htonl(len);
-	memcpy(args->path, path, len);
+	(void)memcpy(args->path, path, len);
 	len = 4 + roundup(len, 4);
 
-	cc = 

CVS commit: src/sys/lib/libsa

2023-12-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 12 09:12:55 UTC 2023

Modified Files:
src/sys/lib/libsa: nfs.c nfsv2.h rpcv2.h
Added Files:
src/sys/lib/libsa: nfsv3.h

Log Message:
Add NFSv3 support. Try NFSv3 and fall back to NFSv2.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/lib/libsa/nfs.c
cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/nfsv2.h
cvs rdiff -u -r0 -r1.1 src/sys/lib/libsa/nfsv3.h
cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libsa/rpcv2.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/lib/libsa/nfs.c
diff -u src/sys/lib/libsa/nfs.c:1.50 src/sys/lib/libsa/nfs.c:1.51
--- src/sys/lib/libsa/nfs.c:1.50	Sun Jan 26 10:13:10 2020
+++ src/sys/lib/libsa/nfs.c	Tue Dec 12 09:12:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.c,v 1.50 2020/01/26 10:13:10 skrll Exp $	*/
+/*	$NetBSD: nfs.c,v 1.51 2023/12/12 09:12:55 mlelstv Exp $	*/
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -53,46 +53,18 @@
 
 #include "rpcv2.h"
 #include "nfsv2.h"
+#include "nfsv3.h"
 
 #include "stand.h"
 #include "net.h"
 #include "nfs.h"
 #include "rpc.h"
 
-/* Define our own NFS attributes */
-struct nfsv2_fattrs {
-	n_long	fa_type;
-	n_long	fa_mode;
-	n_long	fa_nlink;
-	n_long	fa_uid;
-	n_long	fa_gid;
-	n_long	fa_size;
-	n_long	fa_blocksize;
-	n_long	fa_rdev;
-	n_long	fa_blocks;
-	n_long	fa_fsid;
-	n_long	fa_fileid;
-	struct nfsv2_time fa_atime;
-	struct nfsv2_time fa_mtime;
-	struct nfsv2_time fa_ctime;
-};
-
-
-struct nfs_read_args {
-	u_char	fh[NFS_FHSIZE];
-	n_long	off;
-	n_long	len;
-	n_long	xxx;			/* XXX what's this for? */
-};
+/* Storage for any filehandle (including length for V3) */
+#define NFS_FHSTORE (NFS_FHSIZE < NFS_V3FHSIZE ? NFS_V3FHSIZE + 4: NFS_FHSIZE)
 
 /* Data part of nfs rpc reply (also the largest thing we receive) */
 #define NFSREAD_SIZE 1024
-struct nfs_read_repl {
-	n_long	errno;
-	struct	nfsv2_fattrs fa;
-	n_long	count;
-	u_char	data[NFSREAD_SIZE];
-};
 
 #ifndef NFS_NOSYMLINK
 struct nfs_readlnk_repl {
@@ -102,16 +74,68 @@ struct nfs_readlnk_repl {
 };
 #endif
 
+static inline uint64_t
+getnquad(n_long x[2]) {
+	return (uint64_t)ntohl(x[0]) << 32 | ntohl(x[1]);
+}
+
+static inline void
+setnquad(n_long x[2], uint64_t v)
+{
+	x[0] = htonl((n_long)(v >> 32));
+	x[1] = htonl((n_long)(v & 0x));
+}
+
 struct nfs_iodesc {
 	struct	iodesc	*iodesc;
 	off_t	off;
-	u_char	fh[NFS_FHSIZE];
-	struct nfsv2_fattrs fa;	/* all in network order */
+	int	version;
+	u_char	fh[NFS_FHSTORE];
+	union {
+		/* all in network order */
+		struct nfsv2_fattr v2;
+		struct nfsv3_fattr v3;
+	} u_fa;
 };
 
+static inline size_t
+fhstore(int version, u_char *fh)
+{
+	size_t len;
+
+	switch (version) {
+	case NFS_VER2:
+		len = NFS_FHSIZE;
+		break;
+	case NFS_VER3:
+		len = fh[0] << 24 | fh[1] << 16 | fh[2] << 8 | fh[3];
+		if (len > NFS_V3FHSIZE)
+			len = NFS_V3FHSIZE;
+		len = 4 + roundup(len, 4);
+		break;
+	default:
+		len = 0;
+		break;
+	}
+
+	return len;
+}
+
+static inline size_t
+fhcopy(int version, u_char *src, u_char *dst)
+{
+	size_t len = fhstore(version, src);
+	memcpy(dst, src, len);
+	return len;
+}
+
+#define setfh(d, s) fhcopy((d)->version, (s), (d)->fh)
+#define getfh(d, s) fhcopy((d)->version, (d)->fh, (s))
+
+
 struct nfs_iodesc nfs_root_node;
 
-int	nfs_getrootfh(struct iodesc *, char *, u_char *);
+int	nfs_getrootfh(struct iodesc *, char *, u_char *, int *);
 int	nfs_lookupfh(struct nfs_iodesc *, const char *, int,
 	struct nfs_iodesc *);
 int	nfs_readlink(struct nfs_iodesc *, char *);
@@ -122,7 +146,7 @@ ssize_t	nfs_readdata(struct nfs_iodesc *
  * On error, return non-zero and set errno.
  */
 int
-nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp)
+nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp, int *versionp)
 {
 	int len;
 	struct args {
@@ -131,7 +155,7 @@ nfs_getrootfh(struct iodesc *d, char *pa
 	} *args;
 	struct repl {
 		n_long	errno;
-		u_char	fh[NFS_FHSIZE];
+		u_char	fh[NFS_FHSTORE];
 	} *repl;
 	struct {
 		n_long	h[RPC_HEADER_WORDS];
@@ -159,8 +183,14 @@ nfs_getrootfh(struct iodesc *d, char *pa
 	(void)memcpy(args->path, path, len);
 	len = 4 + roundup(len, 4);
 
-	cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT,
+	*versionp = NFS_VER3;
+	cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER3, RPCMNT_MOUNT,
 	args, len, repl, sizeof(*repl));
+	if (cc == -1 || cc < 4 || repl->errno) {
+		*versionp = NFS_VER2;
+		cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT,
+		args, len, repl, sizeof(*repl));
+	}
 	if (cc == -1) {
 		/* errno was set by rpc_call */
 		return -1;
@@ -173,7 +203,7 @@ nfs_getrootfh(struct iodesc *d, char *pa
 		errno = ntohl(repl->errno);
 		return -1;
 	}
-	(void)memcpy(fhp, repl->fh, sizeof(repl->fh));
+	fhcopy(*versionp, repl->fh, fhp);
 	return 0;
 }
 
@@ -185,58 +215,126 @@ int
 nfs_lookupfh(struct nfs_iodesc *d, const char *name, int len,
 	struct nfs_iodesc *newfd)
 {
-	int rlen;
-	struct 

CVS commit: src/sys/lib/libsa

2023-12-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 12 09:12:55 UTC 2023

Modified Files:
src/sys/lib/libsa: nfs.c nfsv2.h rpcv2.h
Added Files:
src/sys/lib/libsa: nfsv3.h

Log Message:
Add NFSv3 support. Try NFSv3 and fall back to NFSv2.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/lib/libsa/nfs.c
cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/nfsv2.h
cvs rdiff -u -r0 -r1.1 src/sys/lib/libsa/nfsv3.h
cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libsa/rpcv2.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.