Re: CVS commit: src/etc/rc.d

2017-12-06 Thread David Holland
On Wed, Dec 06, 2017 at 08:25:08AM +0700, Robert Elz wrote:
 > It isn't the precedence of the operators that is at issue, but
 > deciding what is an operator -

oh right, I'm pretty sure I knew about that at one point and blocked
it out for the sake of my sanity :-)

-- 
David A. Holland
dholl...@netbsd.org


CVS commit: othersrc/external/bsd/testcompat

2017-12-06 Thread David A. Holland
Module Name:othersrc
Committed By:   dholland
Date:   Thu Dec  7 05:55:36 UTC 2017

Added Files:
othersrc/external/bsd/testcompat: Makefile README
othersrc/external/bsd/testcompat/gen: Makefile main.ml
othersrc/external/bsd/testcompat/mk: base.mk ocaml.mk subdir.mk
othersrc/external/bsd/testcompat/parser: Makefile lexer.mll parser.mly
ptcheck.ml ptree.ml
othersrc/external/bsd/testcompat/specs: cases.def mips.mach
syscalls.def ultrix.kern
othersrc/external/bsd/testcompat/support: Makefile pos.ml types.ml
util.ml

Log Message:
Add some preliminary stuff in pursuit of testing compat syscalls.

So far this just has some (partial) specs and some code for reading
the specs in; it doesn't actually do anything yet...

It is ocaml because ocaml is the least awful choice for prototyping
compiler stuff.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/Makefile \
othersrc/external/bsd/testcompat/README
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/gen/Makefile \
othersrc/external/bsd/testcompat/gen/main.ml
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/mk/base.mk \
othersrc/external/bsd/testcompat/mk/ocaml.mk \
othersrc/external/bsd/testcompat/mk/subdir.mk
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/parser/Makefile \
othersrc/external/bsd/testcompat/parser/lexer.mll \
othersrc/external/bsd/testcompat/parser/parser.mly \
othersrc/external/bsd/testcompat/parser/ptcheck.ml \
othersrc/external/bsd/testcompat/parser/ptree.ml
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/specs/cases.def \
othersrc/external/bsd/testcompat/specs/mips.mach \
othersrc/external/bsd/testcompat/specs/syscalls.def \
othersrc/external/bsd/testcompat/specs/ultrix.kern
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/support/Makefile \
othersrc/external/bsd/testcompat/support/pos.ml \
othersrc/external/bsd/testcompat/support/types.ml \
othersrc/external/bsd/testcompat/support/util.ml

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

Added files:

Index: othersrc/external/bsd/testcompat/Makefile
diff -u /dev/null othersrc/external/bsd/testcompat/Makefile:1.1
--- /dev/null	Thu Dec  7 05:55:36 2017
+++ othersrc/external/bsd/testcompat/Makefile	Thu Dec  7 05:55:35 2017
@@ -0,0 +1,6 @@
+TOP=.
+include $(TOP)/mk/base.mk
+
+SUBDIRS=support parser gen
+
+include $(TOP)/mk/subdir.mk
Index: othersrc/external/bsd/testcompat/README
diff -u /dev/null othersrc/external/bsd/testcompat/README:1.1
--- /dev/null	Thu Dec  7 05:55:36 2017
+++ othersrc/external/bsd/testcompat/README	Thu Dec  7 05:55:35 2017
@@ -0,0 +1,25 @@
+Compat syscall testing framework.
+
+The general idea here is that we declare the following things:
+   - abstract syscalls
+   - kernel ABIs
+   - machines
+   - syscall ABIs (for the call sequence itself)
+
+and then for each syscall specify a set of test cases based on known
+issues (in the syscall spec itself, in the ABIs, etc.) and then for
+each combination generate an assembly-language sequence that exercises
+the test case.
+
+These can then be assembled into static binaries that can be run
+against an actual kernel (can't use rump for this, it needs to be
+making actual syscalls at the machine level) without needing includes
+or libraries for the compat environment.
+
+(This is desirable because old or foreign includes and libraries are
+problematic; they can be hard to get, hard to build against, are
+sometimes nonredistributable, etc.)
+
+The program that builds the tests is called, in a fit of originality,
+"testcompatgen". It's written in OCaml because that's the least awful
+of a variety of dismal choices for rapid compiler prototyping.

Index: othersrc/external/bsd/testcompat/gen/Makefile
diff -u /dev/null othersrc/external/bsd/testcompat/gen/Makefile:1.1
--- /dev/null	Thu Dec  7 05:55:36 2017
+++ othersrc/external/bsd/testcompat/gen/Makefile	Thu Dec  7 05:55:35 2017
@@ -0,0 +1,28 @@
+TOP=..
+include $(TOP)/mk/base.mk
+
+PROG=testcompatgen
+SRCS=\
+	main.ml
+
+SUPPORTDIR=../support
+PARSERDIR=../parser
+
+#
+# Note: unlike with normal Unix C libs, which work the other way
+# around, OCAMLLIBS must be ordered with lower-level stuff first;
+# otherwise the higher-level stuff won't link to it.
+#
+
+#OCAMLLIBS+=unix.$(OCAMLLIBEXT) nums.$(OCAMLLIBEXT)
+OCAMLLIBS+=nums.$(OCAMLLIBEXT)
+
+OCAMLINCS+=-I $(SUPPORTDIR)
+OCAMLLIBS+=$(SUPPORTDIR)/libsupport.$(OCAMLLIBEXT)
+OCAMLLIBDEPS+=$(SUPPORTDIR)/libsupport.$(OCAMLLIBEXT)
+
+OCAMLINCS+=-I $(PARSERDIR)
+OCAMLLIBS+=$(PARSERDIR)/libparser.$(OCAMLLIBEXT)
+OCAMLLIBDEPS+=$(PARSERDIR)/libparser.$(OCAMLLIBEXT)
+
+include $(TOP)/mk/ocaml.mk
Index: othersrc/external/bsd/testcompat/gen/main.ml
diff -u /dev/null othersrc/external/bsd/testcompat/gen/main.ml:1.1
--- /dev/null	Thu Dec  7 05:55:36 2017
+++ 

CVS commit: othersrc/external/bsd/testcompat

2017-12-06 Thread David A. Holland
Module Name:othersrc
Committed By:   dholland
Date:   Thu Dec  7 05:55:36 UTC 2017

Added Files:
othersrc/external/bsd/testcompat: Makefile README
othersrc/external/bsd/testcompat/gen: Makefile main.ml
othersrc/external/bsd/testcompat/mk: base.mk ocaml.mk subdir.mk
othersrc/external/bsd/testcompat/parser: Makefile lexer.mll parser.mly
ptcheck.ml ptree.ml
othersrc/external/bsd/testcompat/specs: cases.def mips.mach
syscalls.def ultrix.kern
othersrc/external/bsd/testcompat/support: Makefile pos.ml types.ml
util.ml

Log Message:
Add some preliminary stuff in pursuit of testing compat syscalls.

So far this just has some (partial) specs and some code for reading
the specs in; it doesn't actually do anything yet...

It is ocaml because ocaml is the least awful choice for prototyping
compiler stuff.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/Makefile \
othersrc/external/bsd/testcompat/README
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/gen/Makefile \
othersrc/external/bsd/testcompat/gen/main.ml
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/mk/base.mk \
othersrc/external/bsd/testcompat/mk/ocaml.mk \
othersrc/external/bsd/testcompat/mk/subdir.mk
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/parser/Makefile \
othersrc/external/bsd/testcompat/parser/lexer.mll \
othersrc/external/bsd/testcompat/parser/parser.mly \
othersrc/external/bsd/testcompat/parser/ptcheck.ml \
othersrc/external/bsd/testcompat/parser/ptree.ml
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/specs/cases.def \
othersrc/external/bsd/testcompat/specs/mips.mach \
othersrc/external/bsd/testcompat/specs/syscalls.def \
othersrc/external/bsd/testcompat/specs/ultrix.kern
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/testcompat/support/Makefile \
othersrc/external/bsd/testcompat/support/pos.ml \
othersrc/external/bsd/testcompat/support/types.ml \
othersrc/external/bsd/testcompat/support/util.ml

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



CVS commit: src/sys/arch/amd64/amd64

2017-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Dec  7 03:25:51 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: trap.c

Log Message:
Attempt to clarify panic messages for null pointer access/execute.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/amd64/amd64/trap.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/amd64/amd64/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.105 src/sys/arch/amd64/amd64/trap.c:1.106
--- src/sys/arch/amd64/amd64/trap.c:1.105	Sat Dec  2 12:40:03 2017
+++ src/sys/arch/amd64/amd64/trap.c	Thu Dec  7 03:25:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.105 2017/12/02 12:40:03 maxv Exp $	*/
+/*	$NetBSD: trap.c,v 1.106 2017/12/07 03:25:51 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.105 2017/12/02 12:40:03 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.106 2017/12/07 03:25:51 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -518,16 +518,26 @@ trap(struct trapframe *frame)
 
 		if (frame->tf_err & PGEX_X) {
 			/* SMEP might have brought us here */
-			if (cr2 < VM_MAXUSER_ADDRESS)
-panic("prevented execution of %p (SMEP)",
-(void *)cr2);
+			if (cr2 < VM_MAXUSER_ADDRESS) {
+if (cr2 == 0)
+	panic("prevented jump to null"
+	" instruction pointer (SMEP)");
+else
+	panic("prevented execution of"
+	" user address %p (SMEP)",
+	(void *)cr2);
+			}
 		}
 
 		if (cr2 < VM_MAXUSER_ADDRESS) {
 			/* SMAP might have brought us here */
-			if (onfault_handler(pcb, frame) == NULL)
-panic("prevented access to %p (SMAP)",
+			if (onfault_handler(pcb, frame) == NULL) {
+panic("prevented %s %p (SMAP)",
+(cr2 < PAGE_SIZE
+	? "null pointer dereference at"
+	: "access to"),
 (void *)cr2);
+			}
 		}
 
 		goto faultcommon;



CVS commit: src/sys/arch/amd64/amd64

2017-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Dec  7 03:25:51 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64: trap.c

Log Message:
Attempt to clarify panic messages for null pointer access/execute.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/amd64/amd64/trap.c

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



CVS commit: src/sys

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec  7 03:16:25 UTC 2017

Modified Files:
src/sys/net: if.c if_spppsubr.c
src/sys/rump/net/lib/libnetinet: netinet_component.c

Log Message:
Ensure to call if_addr_init with holding if_ioctl_lock


To generate a diff of this commit:
cvs rdiff -u -r1.407 -r1.408 src/sys/net/if.c
cvs rdiff -u -r1.175 -r1.176 src/sys/net/if_spppsubr.c
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/net/lib/libnetinet/netinet_component.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/net/if.c
diff -u src/sys/net/if.c:1.407 src/sys/net/if.c:1.408
--- src/sys/net/if.c:1.407	Thu Dec  7 01:23:53 2017
+++ src/sys/net/if.c	Thu Dec  7 03:16:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.407 2017/12/07 01:23:53 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.408 2017/12/07 03:16:24 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.407 2017/12/07 01:23:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.408 2017/12/07 03:16:24 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -3517,6 +3517,7 @@ if_addr_init(ifnet_t *ifp, struct ifaddr
 {
 	int rc;
 
+	KASSERT(mutex_owned(ifp->if_ioctl_lock));
 	if (ifp->if_initaddr != NULL)
 		rc = (*ifp->if_initaddr)(ifp, ifa, src);
 	else if (src ||

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.175 src/sys/net/if_spppsubr.c:1.176
--- src/sys/net/if_spppsubr.c:1.175	Wed Nov 22 17:11:51 2017
+++ src/sys/net/if_spppsubr.c	Thu Dec  7 03:16:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.175 2017/11/22 17:11:51 christos Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.176 2017/12/07 03:16:24 ozaki-r Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.175 2017/11/22 17:11:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.176 2017/12/07 03:16:24 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -5271,6 +5271,8 @@ sppp_set_ip_addrs_work(struct work *wk, 
 	uint32_t myaddr = 0, hisaddr = 0;
 	int s;
 
+	mutex_enter(ifp->if_ioctl_lock);
+
 	/*
 	 * Pick the first AF_INET address from the list,
 	 * aliases don't make any sense on a p2p link anyway.
@@ -5334,6 +5336,8 @@ sppp_set_ip_addrs_work(struct work *wk, 
 			ifp->if_xname, ifp->if_mtu);
 	}
 
+	mutex_exit(ifp->if_ioctl_lock);
+
 	sppp_notify_con(sp);
 }
 
@@ -5365,6 +5369,8 @@ sppp_clear_ip_addrs_work(struct work *wk
 	struct sockaddr_in *si, *dest;
 	int s;
 
+	mutex_enter(ifp->if_ioctl_lock);
+
 	/*
 	 * Pick the first AF_INET address from the list,
 	 * aliases don't make any sense on a p2p link anyway.
@@ -5414,6 +5420,8 @@ sppp_clear_ip_addrs_work(struct work *wk
 			"%s: resetting MTU to %" PRIu64 " bytes\n",
 			ifp->if_xname, ifp->if_mtu);
 	}
+
+	mutex_exit(ifp->if_ioctl_lock);
 }
 
 static void
@@ -5531,6 +5539,8 @@ sppp_set_ip6_addr(struct sppp *sp, const
 	int s;
 	struct psref psref;
 
+	mutex_enter(ifp->if_ioctl_lock);
+
 	/*
 	 * Pick the first link-local AF_INET6 address from the list,
 	 * aliases don't make any sense on a p2p link anyway.
@@ -5568,6 +5578,8 @@ sppp_set_ip6_addr(struct sppp *sp, const
 		}
 		ifa_release(ifa, );
 	}
+
+	mutex_exit(ifp->if_ioctl_lock);
 }
 #endif
 

Index: src/sys/rump/net/lib/libnetinet/netinet_component.c
diff -u src/sys/rump/net/lib/libnetinet/netinet_component.c:1.8 src/sys/rump/net/lib/libnetinet/netinet_component.c:1.9
--- src/sys/rump/net/lib/libnetinet/netinet_component.c:1.8	Fri Jan 20 08:35:33 2017
+++ src/sys/rump/net/lib/libnetinet/netinet_component.c	Thu Dec  7 03:16:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: netinet_component.c,v 1.8 2017/01/20 08:35:33 ozaki-r Exp $	*/
+/*	$NetBSD: netinet_component.c,v 1.9 2017/12/07 03:16:25 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netinet_component.c,v 1.8 2017/01/20 08:35:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netinet_component.c,v 1.9 2017/12/07 03:16:25 ozaki-r Exp $");
 
 #include 
 #include 
@@ -94,7 +94,9 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET_IFCFG)
 	sin->sin_len = sizeof(struct sockaddr_in);
 	sin->sin_addr.s_addr = inet_addr("127.255.255.255");
 
+	mutex_enter(lo0ifp->if_ioctl_lock);
 	in_control(so, SIOCAIFADDR, , lo0ifp);
+	mutex_exit(lo0ifp->if_ioctl_lock);
 	if_up(lo0ifp);
 	soclose(so);
 }



CVS commit: src/sys

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec  7 03:16:25 UTC 2017

Modified Files:
src/sys/net: if.c if_spppsubr.c
src/sys/rump/net/lib/libnetinet: netinet_component.c

Log Message:
Ensure to call if_addr_init with holding if_ioctl_lock


To generate a diff of this commit:
cvs rdiff -u -r1.407 -r1.408 src/sys/net/if.c
cvs rdiff -u -r1.175 -r1.176 src/sys/net/if_spppsubr.c
cvs rdiff -u -r1.8 -r1.9 src/sys/rump/net/lib/libnetinet/netinet_component.c

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



CVS commit: src/sys/net

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec  7 01:23:53 UTC 2017

Modified Files:
src/sys/net: if.c

Log Message:
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH

At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.


To generate a diff of this commit:
cvs rdiff -u -r1.406 -r1.407 src/sys/net/if.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/net/if.c
diff -u src/sys/net/if.c:1.406 src/sys/net/if.c:1.407
--- src/sys/net/if.c:1.406	Wed Dec  6 09:54:47 2017
+++ src/sys/net/if.c	Thu Dec  7 01:23:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.406 2017/12/06 09:54:47 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.407 2017/12/07 01:23:53 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.406 2017/12/06 09:54:47 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.407 2017/12/07 01:23:53 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1378,9 +1378,11 @@ if_detach(struct ifnet *ifp)
 again:
 	/*
 	 * At this point, no other one tries to remove ifa in the list,
-	 * so we don't need to take a lock or psref.
+	 * so we don't need to take a lock or psref.  Avoid using
+	 * IFADDR_READER_FOREACH to pass over an inspection of contract
+	 * violations of pserialize.
 	 */
-	IFADDR_READER_FOREACH(ifa, ifp) {
+	IFADDR_WRITER_FOREACH(ifa, ifp) {
 		family = ifa->ifa_addr->sa_family;
 #ifdef IFAREF_DEBUG
 		printf("if_detach: ifaddr %p, family %d, refcnt %d\n",



CVS commit: src/sys/net

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Dec  7 01:23:53 UTC 2017

Modified Files:
src/sys/net: if.c

Log Message:
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH

At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.


To generate a diff of this commit:
cvs rdiff -u -r1.406 -r1.407 src/sys/net/if.c

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



CVS commit: src/sys/dev/pci

2017-12-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  7 00:38:38 UTC 2017

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Fix a bug that 8257[56] can't receive packet reported by Bert Kiers in
PR#52717. For 82575 and 82576, the RX descriptors must be initialized after
the setting of RCTL.EN in wm_set_filter(). This bug was added in if_wm.c
rev. 1.515.


To generate a diff of this commit:
cvs rdiff -u -r1.547 -r1.548 src/sys/dev/pci/if_wm.c

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



CVS commit: src/sys/dev/pci

2017-12-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  7 00:38:38 UTC 2017

Modified Files:
src/sys/dev/pci: if_wm.c

Log Message:
 Fix a bug that 8257[56] can't receive packet reported by Bert Kiers in
PR#52717. For 82575 and 82576, the RX descriptors must be initialized after
the setting of RCTL.EN in wm_set_filter(). This bug was added in if_wm.c
rev. 1.515.


To generate a diff of this commit:
cvs rdiff -u -r1.547 -r1.548 src/sys/dev/pci/if_wm.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/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.547 src/sys/dev/pci/if_wm.c:1.548
--- src/sys/dev/pci/if_wm.c:1.547	Wed Dec  6 09:03:12 2017
+++ src/sys/dev/pci/if_wm.c	Thu Dec  7 00:38:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.547 2017/12/06 09:03:12 ozaki-r Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.548 2017/12/07 00:38:38 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.547 2017/12/06 09:03:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.548 2017/12/07 00:38:38 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -5814,6 +5814,14 @@ wm_init_locked(struct ifnet *ifp)
 		break;
 	}
 
+	/*
+	 * Set the receive filter.
+	 *
+	 * For 82575 and 82576, the RX descriptors must be initialized after
+	 * the setting of RCTL.EN in wm_set_filter()
+	 */
+	wm_set_filter(sc);
+
 	/* On 575 and later set RDT only if RX enabled */
 	if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
 		int qidx;
@@ -5828,9 +5836,6 @@ wm_init_locked(struct ifnet *ifp)
 		}
 	}
 
-	/* Set the receive filter. */
-	wm_set_filter(sc);
-
 	wm_unset_stopping_flags(sc);
 
 	/* Start the one second link check clock. */
@@ -6688,13 +6693,13 @@ wm_init_rx_buffer(struct wm_softc *sc, s
 return ENOMEM;
 			}
 		} else {
-			if ((sc->sc_flags & WM_F_NEWQUEUE) == 0)
-wm_init_rxdesc(rxq, i);
 			/*
-			 * For 82575 and newer device, the RX descriptors
-			 * must be initialized after the setting of RCTL.EN in
+			 * For 82575 and 82576, the RX descriptors must be
+			 * initialized after the setting of RCTL.EN in
 			 * wm_set_filter()
 			 */
+			if ((sc->sc_flags & WM_F_NEWQUEUE) == 0)
+wm_init_rxdesc(rxq, i);
 		}
 	}
 	rxq->rxq_ptr = 0;



CVS commit: src/lib/libnpf

2017-12-06 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Thu Dec  7 00:22:06 UTC 2017

Modified Files:
src/lib/libnpf: libnpf.3

Log Message:
libnpf(3): improve the wording, fix and expand some sections.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libnpf/libnpf.3

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



CVS commit: src/lib/libnpf

2017-12-06 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Thu Dec  7 00:22:06 UTC 2017

Modified Files:
src/lib/libnpf: libnpf.3

Log Message:
libnpf(3): improve the wording, fix and expand some sections.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libnpf/libnpf.3

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

Modified files:

Index: src/lib/libnpf/libnpf.3
diff -u src/lib/libnpf/libnpf.3:1.4 src/lib/libnpf/libnpf.3:1.5
--- src/lib/libnpf/libnpf.3:1.4	Tue Dec 27 21:25:12 2016
+++ src/lib/libnpf/libnpf.3	Thu Dec  7 00:22:06 2017
@@ -1,6 +1,6 @@
-.\"	$NetBSD: libnpf.3,v 1.4 2016/12/27 21:25:12 wiz Exp $
+.\"	$NetBSD: libnpf.3,v 1.5 2017/12/07 00:22:06 rmind Exp $
 .\"
-.\" Copyright (c) 2011-2015 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2011-2017 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This material is based upon work partially supported by The
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 19, 2015
+.Dd December 7, 2017
 .Dt LIBNPF 3
 .Os
 .Sh NAME
@@ -110,23 +110,24 @@ The configuration can be submitted to th
 .Ss Configuration
 .Bl -tag -width 4n
 .It Fn npf_config_create
-Create a configuration.
+Create a new configuration object.
 .It Fn npf_config_submit "ncf" "fd" "errinfo"
-Submit configuration
-.Fa ncf
+Submit the configuration object, specified by
+.Fa ncf ,
 to the kernel.
-On error, the the description is written into the structure specified by
+On failure, the error information is written into the structure
+specified by
 .Fa errinfo .
 .It Fn npf_config_export "fd" "len"
-Serialize the given configuration and return binary object and its
-length in
+Serialize the current configuration and return the binary object as
+well as its length in
 .Fa len
 parameter.
 The binary object is dynamically allocated and should be destroyed using
 .Xr free 3 .
 .It Fn npf_config_import "blob" "len"
 Read the configuration from a binary object of the specified length,
-unserialize, construct and return the configuration object.
+unserialize, and return the configuration object.
 .It Fn npf_config_flush "fd"
 Flush the current configuration.
 .It Fn npf_config_retrieve "fd" "active" "loaded"
@@ -135,7 +136,7 @@ Retrieve and return the loaded configura
 Indicate whether the retrieved configuration is active (true if yes
 and false otherwise).
 .It Fn npf_config_destroy "ncf"
-Destroy the configuration
+Destroy the configuration object, specified by
 .Fa ncf .
 .El
 .\" ---
@@ -143,91 +144,97 @@ Destroy the configuration
 .Bl -tag -width 4n
 .It Fn npf_rule_create "name" "attr" "ifname"
 Create a rule with a given name, attribute and priorty.
-Name can be
+If the name is specified, then it should be unique within the
+configuration object.
+Otherwise, the name can be
 .Dv NULL ,
-in which case rule has no unique identifier.
-Otherwise, rules shall not have duplicate names.
+in which case the rule will have no identifier.
 The following attributes, which can be ORed, are available:
 .Bl -tag -width indent
 .It Dv NPF_RULE_PASS
-Decision of this rule is "pass".
+The decision of this rule shall be "pass".
 If this attribute is not
-specified, then packet "block" (drop) is the default.
+specified, then "block" (drop the packet) is the default.
 .It Dv NPF_RULE_IN
-Match incoming packets.
+Match the incoming packets.
 .It Dv NPF_RULE_OUT
-Match outgoing packets.
+Match the outgoing packets.
 .It Dv NPF_RULE_FINAL
-Indicates that on rule match, further processing of the
-ruleset should be stopped and this rule applied instantly.
+Indicate that on rule match, further processing of the ruleset should
+be stopped and this rule should be applied instantly.
 .It Dv NPF_RULE_STATEFUL
-Create a state (session) on match, track the connection and
-therefore pass the backwards stream without inspection.
+Create a state (session) on match, track the connection and pass the
+backwards stream (the returning packets) without the ruleset inspection.
 The state is uniquely identified by a 5-tuple (source and destination
 IP addresses, port numbers and an interface identifier).
 .It Dv NPF_RULE_MULTIENDS
-Exclude the interface from the state identifier.
+Exclude the interface identifier from the state key i.e. use a 4-tuple.
 .It Dv NPF_RULE_RETRST
 Return TCP RST packet in a case of packet block.
 .It Dv NPF_RULE_RETICMP
 Return ICMP destination unreachable in a case of packet block.
 .It Dv NPF_RULE_GROUP
 Allow this rule to have sub-rules.
-If used with
+If this flag is used with the
 .Dv NPF_RULE_DYNAMIC
-flag set, the can be added dynamically.
+flag set, then it is a dynamic group.
+The sub-rules can be added dynamically to a dynamic group, also meaning
+that the sub-rules must have the
+.Dv NPF_RULE_DYNAMIC
+flag set.
 Otherwise rules must be added statically i.e. created with the configuration.
 .It Dv 

re: CVS commit: src/sys/compat/netbsd32

2017-12-06 Thread Christos Zoulas
On Dec 7,  7:34am, m...@eterna.com.au (matthew green) wrote:
-- Subject: re: CVS commit: src/sys/compat/netbsd32

| can they make 32 bit trace records instead?  if not, why not?

Because every other syscall is making 64 bit records, so ktrace.out
file is only parseable/readable by the 64 bit ktrace. Putting a 32
bit signal record inside a 64 bit record file does not make any sense
(try it).

When/if we fix 32 bit processes to emit 32 bit records then we can
switch back.

christos


re: CVS commit: src/sys/compat/netbsd32

2017-12-06 Thread matthew green
"Christos Zoulas" writes:
> Module Name:  src
> Committed By: christos
> Date: Wed Dec  6 19:15:27 UTC 2017
> 
> Modified Files:
>   src/sys/compat/netbsd32: netbsd32_netbsd.c netbsd32_signal.c
> 
> Log Message:
> disable 32 bit signal ktrace records; 32 bit traced process produce 64 bit
> trace records, the only record that we can't parse is that one :-)
> XXX: pullup-8

can they make 32 bit trace records instead?  if not, why not?

thanks.


.mrg.


CVS commit: src

2017-12-06 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  6 19:34:00 UTC 2017

Modified Files:
src: Makefile

Log Message:
Include somewhat misleadingly named do-x11 into BUILDTARGETS even with
NOBINARIES set (subject to MKX11).


To generate a diff of this commit:
cvs rdiff -u -r1.320 -r1.321 src/Makefile

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



CVS commit: src

2017-12-06 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  6 19:34:00 UTC 2017

Modified Files:
src: Makefile

Log Message:
Include somewhat misleadingly named do-x11 into BUILDTARGETS even with
NOBINARIES set (subject to MKX11).


To generate a diff of this commit:
cvs rdiff -u -r1.320 -r1.321 src/Makefile

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

Modified files:

Index: src/Makefile
diff -u src/Makefile:1.320 src/Makefile:1.321
--- src/Makefile:1.320	Wed Dec  6 19:27:56 2017
+++ src/Makefile	Wed Dec  6 19:34:00 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.320 2017/12/06 19:27:56 uwe Exp $
+#	$NetBSD: Makefile,v 1.321 2017/12/06 19:34:00 uwe Exp $
 
 #
 # This is the top-level makefile for building NetBSD. For an outline of
@@ -235,10 +235,10 @@ BUILDTARGETS+=	includes
 .endif
 BUILDTARGETS+=	do-lib
 BUILDTARGETS+=	do-compat-lib
-.if !defined(NOBINARIES)
 .if ${MKX11} != "no"
 BUILDTARGETS+=	do-x11
 .endif
+.if !defined(NOBINARIES)
 BUILDTARGETS+=	do-build
 .if ${MKEXTSRC} != "no"
 BUILDTARGETS+=	do-extsrc



CVS commit: src

2017-12-06 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  6 19:27:56 UTC 2017

Modified Files:
src: Makefile

Log Message:
do-x11 target builds and installs only the tools and libraries, X11
programs are built during the regular recursive build in extsrc.  Edit
its description accordingly and move it before do-build to match their
order in BUILDTARGETS.

While here, drop the "either" clause that has lost its "or" a few
years ago when xfree86 reachover was removed.


To generate a diff of this commit:
cvs rdiff -u -r1.319 -r1.320 src/Makefile

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

Modified files:

Index: src/Makefile
diff -u src/Makefile:1.319 src/Makefile:1.320
--- src/Makefile:1.319	Wed Oct  4 23:54:33 2017
+++ src/Makefile	Wed Dec  6 19:27:56 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.319 2017/10/04 23:54:33 christos Exp $
+#	$NetBSD: Makefile,v 1.320 2017/12/06 19:27:56 uwe Exp $
 
 #
 # This is the top-level makefile for building NetBSD. For an outline of
@@ -97,9 +97,9 @@
 #if ${MKCOMPAT} != "no".
 #   do-compat-lib:   builds and installs prerequisites from compat/lib
 #if ${MKCOMPAT} != "no".
+#   do-x11:  builds and installs X11 tools and libraries
+#from src/external/mit/xorg if ${MKX11} != "no".
 #   do-build:builds and installs the entire system.
-#   do-x11:  builds and installs X11 if ${MKX11} != "no"; either
-#X11R7 from src/external/mit/xorg 
 #   do-extsrc:   builds and installs extsrc if ${MKEXTSRC} != "no".
 #   do-obsolete: installs the obsolete sets (for the postinstall-* targets).
 #



CVS commit: src

2017-12-06 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  6 19:27:56 UTC 2017

Modified Files:
src: Makefile

Log Message:
do-x11 target builds and installs only the tools and libraries, X11
programs are built during the regular recursive build in extsrc.  Edit
its description accordingly and move it before do-build to match their
order in BUILDTARGETS.

While here, drop the "either" clause that has lost its "or" a few
years ago when xfree86 reachover was removed.


To generate a diff of this commit:
cvs rdiff -u -r1.319 -r1.320 src/Makefile

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



CVS commit: src/sys/compat/netbsd32

2017-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 19:15:27 UTC 2017

Modified Files:
src/sys/compat/netbsd32: netbsd32_netbsd.c netbsd32_signal.c

Log Message:
disable 32 bit signal ktrace records; 32 bit traced process produce 64 bit
trace records, the only record that we can't parse is that one :-)
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/sys/compat/netbsd32/netbsd32_netbsd.c
cvs rdiff -u -r1.43 -r1.44 src/sys/compat/netbsd32/netbsd32_signal.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/compat/netbsd32/netbsd32_netbsd.c
diff -u src/sys/compat/netbsd32/netbsd32_netbsd.c:1.207 src/sys/compat/netbsd32/netbsd32_netbsd.c:1.208
--- src/sys/compat/netbsd32/netbsd32_netbsd.c:1.207	Mon Jul 31 11:38:01 2017
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c	Wed Dec  6 14:15:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_netbsd.c,v 1.207 2017/07/31 15:38:01 maxv Exp $	*/
+/*	$NetBSD: netbsd32_netbsd.c,v 1.208 2017/12/06 19:15:27 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.207 2017/07/31 15:38:01 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.208 2017/12/06 19:15:27 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -159,7 +159,11 @@ struct emul emul_netbsd32 = {
 	.e_usertrap =		NULL,
 	.e_ucsize =		sizeof(ucontext32_t),
 	.e_startlwp =		startlwp32,
-	.e_ktrpsig =		netbsd32_ktrpsig
+#ifdef notyet
+	.e_ktrpsig =		netbsd32_ktrpsig,
+#else
+	.e_ktrpsig =		NULL,
+#endif
 };
 
 /*

Index: src/sys/compat/netbsd32/netbsd32_signal.c
diff -u src/sys/compat/netbsd32/netbsd32_signal.c:1.43 src/sys/compat/netbsd32/netbsd32_signal.c:1.44
--- src/sys/compat/netbsd32/netbsd32_signal.c:1.43	Sun Sep 18 01:16:21 2016
+++ src/sys/compat/netbsd32/netbsd32_signal.c	Wed Dec  6 14:15:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_signal.c,v 1.43 2016/09/18 05:16:21 christos Exp $	*/
+/*	$NetBSD: netbsd32_signal.c,v 1.44 2017/12/06 19:15:27 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.43 2016/09/18 05:16:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.44 2017/12/06 19:15:27 christos Exp $");
 
 #if defined(_KERNEL_OPT) 
 #include "opt_ktrace.h"
@@ -226,6 +226,7 @@ netbsd32_ksi32_to_ksi(struct _ksiginfo *
 	}
 }
 
+#ifdef notyet
 #ifdef KTRACE
 static void
 netbsd32_ksi_to_ksi32(struct __ksiginfo32 *si32, const struct _ksiginfo *si)
@@ -268,6 +269,7 @@ netbsd32_ksi_to_ksi32(struct __ksiginfo3
 	}
 }
 #endif
+#endif
 
 void
 netbsd32_si_to_si32(siginfo32_t *si32, const siginfo_t *si)
@@ -513,6 +515,7 @@ struct netbsd32_ktr_psig {
 	/* and optional siginfo_t */
 };
 
+#ifdef notyet
 #ifdef KTRACE
 void
 netbsd32_ktrpsig(int sig, sig_t action, const sigset_t *mask,
@@ -548,5 +551,4 @@ netbsd32_ktrpsig(int sig, sig_t action, 
 	ktraddentry(l, kte, KTA_WAITOK);
 }
 #endif
-
-
+#endif



CVS commit: src/sys/compat/netbsd32

2017-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 19:15:27 UTC 2017

Modified Files:
src/sys/compat/netbsd32: netbsd32_netbsd.c netbsd32_signal.c

Log Message:
disable 32 bit signal ktrace records; 32 bit traced process produce 64 bit
trace records, the only record that we can't parse is that one :-)
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/sys/compat/netbsd32/netbsd32_netbsd.c
cvs rdiff -u -r1.43 -r1.44 src/sys/compat/netbsd32/netbsd32_signal.c

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



CVS commit: src/games/fortune/datfiles

2017-12-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Dec  6 17:54:58 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
attributions are supposed to be indented.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/games/fortune/datfiles/fortunes

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

Modified files:

Index: src/games/fortune/datfiles/fortunes
diff -u src/games/fortune/datfiles/fortunes:1.69 src/games/fortune/datfiles/fortunes:1.70
--- src/games/fortune/datfiles/fortunes:1.69	Wed Dec  6 17:41:15 2017
+++ src/games/fortune/datfiles/fortunes	Wed Dec  6 17:54:58 2017
@@ -16209,17 +16209,17 @@ druid in a hurry?
 A. Call the copse.
 %
 A truly great library contains something in it to offend everyone.
--- Jo Godwin
+		-- Jo Godwin
 %
 Give a man a 0day and he'll have access for a day, teach a man to phish
 and he'll have access for life.
--- the grugq
+		-- the grugq
 %
 Information wants to be free and also extremely difficult to use.
--- An ancient open source proverb
+		-- An ancient open source proverb
 %
 I haven't slept for ten days, because that would be too long.
--- Mitch Hedberg
+		-- Mitch Hedberg
 %
 You, the Poles, have a funny nature. When the people going along the
 road are attacked by a dog with its insistent and noisy barking, you
@@ -16231,4 +16231,4 @@ against dogs we calmly continue our jour
 destination. It seems that you care more about barking than the dog
 does, and more about winning the war with any lousy puppy than about
 reaching the destination quickly.
--- Jozef Pilsudski
+		-- Jozef Pilsudski



CVS commit: src/games/fortune/datfiles

2017-12-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Dec  6 17:54:58 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
attributions are supposed to be indented.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/games/fortune/datfiles/fortunes

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



CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Dec  6 17:41:16 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
Correct code flow of a quote translation (by Tom Ivar Helbekkmo)


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/games/fortune/datfiles/fortunes

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

Modified files:

Index: src/games/fortune/datfiles/fortunes
diff -u src/games/fortune/datfiles/fortunes:1.68 src/games/fortune/datfiles/fortunes:1.69
--- src/games/fortune/datfiles/fortunes:1.68	Wed Dec  6 08:38:33 2017
+++ src/games/fortune/datfiles/fortunes	Wed Dec  6 17:41:15 2017
@@ -16226,7 +16226,7 @@ road are attacked by a dog with its insi
 immediately feel like jumping off the vehicle, standing on all fours
 and starting to bark back at it. We, in the Vilnius region, let the
 dog bark because that is what its canine nature is like but we do not
-stop our journey because of its canine barking and without any war
+stop our journey because of its barking, and without any war
 against dogs we calmly continue our journey until we reach our
 destination. It seems that you care more about barking than the dog
 does, and more about winning the war with any lousy puppy than about



CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Dec  6 17:41:16 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
Correct code flow of a quote translation (by Tom Ivar Helbekkmo)


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/games/fortune/datfiles/fortunes

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



Re: CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Kamil Rytarowski
On 06.12.2017 17:58, Taylor R Campbell wrote:
>> Date: Wed, 6 Dec 2017 16:41:27 +0800 (+08)
>> From: Paul Goyette 
>>
>>> Oh, and I'd also change "its canine barking" to "its barking," (note the
>>> addition of a comma), which would make that sentence flow better, and
>>> avoid the unnecessary re-use of the word 'canine'.
>>
>> Hmmm, it'd be nice if there were a definitive source for this quote; 
>> without that, I'd rather not "adjust" the language.
> 
> I expect the original quote was probably something in Polish.
> 

I was the coauthor of the original translation. There are many other
good quotes but they could be difficult to explain to foreigners,
explain background context etc... or needlessly controversial (even if
true) for fortunes (no need to discuss German-Polish-Russian relations
via fortunes).



signature.asc
Description: OpenPGP digital signature


CVS commit: src/external/bsd/nvi/dist/cl

2017-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec  6 17:16:14 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/cl: cl_main.c

Log Message:
When testing to see if a signal handler was previously installed in
h_winch, test sa_handler against all SIG_* actions defined in sys/signal.h
instead of just 0. Corrects an issue where vi crashes after a window is
resized.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/cl/cl_main.c

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



CVS commit: src/external/bsd/nvi/dist/cl

2017-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec  6 17:16:14 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/cl: cl_main.c

Log Message:
When testing to see if a signal handler was previously installed in
h_winch, test sa_handler against all SIG_* actions defined in sys/signal.h
instead of just 0. Corrects an issue where vi crashes after a window is
resized.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/cl/cl_main.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/bsd/nvi/dist/cl/cl_main.c
diff -u src/external/bsd/nvi/dist/cl/cl_main.c:1.8 src/external/bsd/nvi/dist/cl/cl_main.c:1.9
--- src/external/bsd/nvi/dist/cl/cl_main.c:1.8	Mon Nov  6 03:27:34 2017
+++ src/external/bsd/nvi/dist/cl/cl_main.c	Wed Dec  6 17:16:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cl_main.c,v 1.8 2017/11/06 03:27:34 rin Exp $ */
+/*	$NetBSD: cl_main.c,v 1.9 2017/12/06 17:16:14 jmcneill Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: cl_main.c,v 10.54 2001/07/29 19:07:27 skimo Exp  (Berkeley) Date: 2001/07/29 19:07:27 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: cl_main.c,v 1.8 2017/11/06 03:27:34 rin Exp $");
+__RCSID("$NetBSD: cl_main.c,v 1.9 2017/12/06 17:16:14 jmcneill Exp $");
 #endif
 
 #include 
@@ -314,8 +314,12 @@ h_winch(int signo)
 	F_SET(clp, CL_SIGWINCH);
 
 	/* If there was a previous handler, call that. */
-	if (clp->oact[INDX_WINCH].sa_handler)
+	if (clp->oact[INDX_WINCH].sa_handler != SIG_DFL &&
+	clp->oact[INDX_WINCH].sa_handler != SIG_IGN &&
+	clp->oact[INDX_WINCH].sa_handler != SIG_ERR &&
+	clp->oact[INDX_WINCH].sa_handler != SIG_HOLD) {
 		clp->oact[INDX_WINCH].sa_handler(signo);
+	}
 }
 #undef	GLOBAL_CLP
 



Re: CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Taylor R Campbell
> Date: Wed, 6 Dec 2017 16:41:27 +0800 (+08)
> From: Paul Goyette 
> 
> > Oh, and I'd also change "its canine barking" to "its barking," (note the
> > addition of a comma), which would make that sentence flow better, and
> > avoid the unnecessary re-use of the word 'canine'.
> 
> Hmmm, it'd be nice if there were a definitive source for this quote; 
> without that, I'd rather not "adjust" the language.

I expect the original quote was probably something in Polish.


CVS commit: src/lib/libc/gen

2017-12-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Dec  6 16:38:22 UTC 2017

Modified Files:
src/lib/libc/gen: signal.3

Log Message:
The list of async-signal-safe functions got moved to sigaction(2).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/gen/signal.3

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



CVS commit: src/lib/libc/gen

2017-12-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Dec  6 16:38:22 UTC 2017

Modified Files:
src/lib/libc/gen: signal.3

Log Message:
The list of async-signal-safe functions got moved to sigaction(2).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/gen/signal.3

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

Modified files:

Index: src/lib/libc/gen/signal.3
diff -u src/lib/libc/gen/signal.3:1.27 src/lib/libc/gen/signal.3:1.28
--- src/lib/libc/gen/signal.3:1.27	Mon Jun  6 08:28:18 2016
+++ src/lib/libc/gen/signal.3	Wed Dec  6 16:38:22 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: signal.3,v 1.27 2016/06/06 08:28:18 wiz Exp $
+.\"	$NetBSD: signal.3,v 1.28 2017/12/06 16:38:22 dholland Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -149,7 +149,7 @@ ignored signals remain ignored.
 .Pp
 Only functions that are async-signal-safe can safely be used in signal
 handlers, see
-.Xr signal 7
+.Xr sigaction 2
 for a complete list.
 .Sh RETURN VALUES
 The previous action is returned on a successful call.



Re: CVS commit: src/sys (and netbsd-8 stalled pullup request #390)

2017-12-06 Thread Roy Marples

On 28/11/2017 16:36, Roy Marples wrote:

On 27/11/2017 20:27, Robert Elz wrote:

The new test should be moved down to rule 3, probably just before the
deprecated addr test, that is, a deprecated addr which is still valid
should be preferred over a detached (or tentative) addr  - detached I
will come back to in the next section, but for tentative this means that
if an old addr has become deprecated, and we're in the process of 
generating

a new one, but DaD has not completed yet, we keep using the old addr
until the new one is no longer tentative, and then switch (the way your
code is now would also do that - but because the check is much too 
violent.)
This is why you might consider this just to be a coding change (with 
functional

side effects.)


I don't see a problem with moving the detached/tentative test there


src/sys/netinet6/in6_src.c r1.84 addresses this.

Roy



CVS commit: src/sys/netinet6

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 14:17:42 UTC 2017

Modified Files:
src/sys/netinet6: in6_src.c

Log Message:
Treat unvalidated addresses as deprecated in rule 3.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/netinet6/in6_src.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/netinet6/in6_src.c
diff -u src/sys/netinet6/in6_src.c:1.83 src/sys/netinet6/in6_src.c:1.84
--- src/sys/netinet6/in6_src.c:1.83	Fri Nov 24 14:03:25 2017
+++ src/sys/netinet6/in6_src.c	Wed Dec  6 14:17:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_src.c,v 1.83 2017/11/24 14:03:25 roy Exp $	*/
+/*	$NetBSD: in6_src.c,v 1.84 2017/12/06 14:17:42 roy Exp $	*/
 /*	$KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $	*/
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.83 2017/11/24 14:03:25 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.84 2017/12/06 14:17:42 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -135,6 +135,9 @@ static int walk_addrsel_policy(int (*)(s
 static int dump_addrsel_policyent(struct in6_addrpolicy *, void *);
 static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
 
+#define	IFA6_IS_VALIDATED(ia) \
+	(((ia)->ia6_flags & (IN6_IFF_TENTATIVE | IN6_IFF_DETACHED)) == 0)
+
 /*
  * Return an IPv6 address, which is the most appropriate for a given
  * destination and user specified options.
@@ -219,12 +222,6 @@ in6_select_best_ia(struct sockaddr_in6 *
 		/* avoid unusable addresses */
 		if ((ia->ia6_flags & (IN6_IFF_DUPLICATED | IN6_IFF_ANYCAST)))
 			continue;
-		/* Prefer validated addresses */
-		if (!(ia->ia6_flags & (IN6_IFF_TENTATIVE | IN6_IFF_DETACHED)) &&
-		ia_best != NULL &&
-		ia_best->ia6_flags & (IN6_IFF_TENTATIVE | IN6_IFF_DETACHED))
-			REPLACE(0);
-
 		if (!ip6_use_deprecated && IFA6_IS_DEPRECATED(ia))
 			continue;
 
@@ -261,7 +258,12 @@ in6_select_best_ia(struct sockaddr_in6 *
 		/*
 		 * Rule 3: Avoid deprecated addresses.  Note that the case of
 		 * !ip6_use_deprecated is already rejected above.
+		 * Treat unvalidated addresses as deprecated here.
 		 */
+		if (IFA6_IS_VALIDATED(ia_best) && !IFA6_IS_VALIDATED(ia))
+			NEXT(3);
+		if (!IFA6_IS_VALIDATED(ia_best) && IFA6_IS_VALIDATED(ia))
+			REPLACE(3);
 		if (!IFA6_IS_DEPRECATED(ia_best) && IFA6_IS_DEPRECATED(ia))
 			NEXT(3);
 		if (IFA6_IS_DEPRECATED(ia_best) && !IFA6_IS_DEPRECATED(ia))



CVS commit: src/sys/netinet6

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 14:17:42 UTC 2017

Modified Files:
src/sys/netinet6: in6_src.c

Log Message:
Treat unvalidated addresses as deprecated in rule 3.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/netinet6/in6_src.c

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



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 14:05:14 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Fix possible use of uninitialized variable in case of WIN32 && !_WIN64.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/gen/fmtcheck.c

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

Modified files:

Index: src/lib/libc/gen/fmtcheck.c
diff -u src/lib/libc/gen/fmtcheck.c:1.14 src/lib/libc/gen/fmtcheck.c:1.15
--- src/lib/libc/gen/fmtcheck.c:1.14	Wed Dec  6 12:32:02 2017
+++ src/lib/libc/gen/fmtcheck.c	Wed Dec  6 14:05:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $	*/
+/*	$NetBSD: fmtcheck.c,v 1.15 2017/12/06 14:05:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $");
+__RCSID("$NetBSD: fmtcheck.c,v 1.15 2017/12/06 14:05:14 rin Exp $");
 #endif
 
 #include "namespace.h"
@@ -149,11 +149,13 @@ get_next_format_from_precision(const cha
 			f += 2;
 			modifier = MOD_QUAD;
 		}
-#ifdef _WIN64
 		else {
+#ifdef _WIN64
 			modifier = MOD_QUAD;
-		}
+#else
+			modifier = MOD_NONE;
 #endif
+		}
 		break;
 #endif
 	default:



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 14:05:14 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Fix possible use of uninitialized variable in case of WIN32 && !_WIN64.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/gen/fmtcheck.c

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



CVS commit: src/distrib/sets/lists/tests

2017-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 13:55:31 UTC 2017

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
add interp test.


To generate a diff of this commit:
cvs rdiff -u -r1.767 -r1.768 src/distrib/sets/lists/tests/mi

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



CVS commit: src/distrib/sets/lists/tests

2017-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 13:55:31 UTC 2017

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
add interp test.


To generate a diff of this commit:
cvs rdiff -u -r1.767 -r1.768 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.767 src/distrib/sets/lists/tests/mi:1.768
--- src/distrib/sets/lists/tests/mi:1.767	Sun Nov 19 16:05:26 2017
+++ src/distrib/sets/lists/tests/mi	Wed Dec  6 08:55:31 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.767 2017/11/19 21:05:26 martin Exp $
+# $NetBSD: mi,v 1.768 2017/12/06 13:55:31 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2156,6 +2156,7 @@
 ./usr/tests/kernel/t_extattrctl			tests-kernel-tests	atf,rump
 ./usr/tests/kernel/t_extent			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/t_filedesc			tests-kernel-tests	atf,rump
+./usr/tests/kernel/t_interp			tests-kernel-tests	atf
 ./usr/tests/kernel/t_kauth_pr_47598		tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/t_lock			tests-kernel-tests	compattestfile,atf
 ./usr/tests/kernel/t_lockf			tests-kernel-tests	compattestfile,atf



CVS commit: src/tests/kernel

2017-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 13:54:26 UTC 2017

Modified Files:
src/tests/kernel: Makefile
Added Files:
src/tests/kernel: t_interp.sh

Log Message:
add a test to check that the interpreter is preserved when executing scripts.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/tests/kernel/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/kernel/t_interp.sh

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

Modified files:

Index: src/tests/kernel/Makefile
diff -u src/tests/kernel/Makefile:1.46 src/tests/kernel/Makefile:1.47
--- src/tests/kernel/Makefile:1.46	Mon Apr  3 01:06:28 2017
+++ src/tests/kernel/Makefile	Wed Dec  6 08:54:26 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.46 2017/04/03 05:06:28 kamil Exp $
+# $NetBSD: Makefile,v 1.47 2017/12/06 13:54:26 christos Exp $
 
 NOMAN=		# defined
 
@@ -19,6 +19,7 @@ TESTS_C+=	t_sysctl
 TESTS_SH=	t_umount
 TESTS_SH+=	t_umountstress
 TESTS_SH+=	t_ps_strings
+TESTS_SH+=	t_interp
 
 BINDIR=		${TESTSDIR}
 PROGS=		h_ps_strings1

Added files:

Index: src/tests/kernel/t_interp.sh
diff -u /dev/null src/tests/kernel/t_interp.sh:1.1
--- /dev/null	Wed Dec  6 08:54:26 2017
+++ src/tests/kernel/t_interp.sh	Wed Dec  6 08:54:26 2017
@@ -0,0 +1,45 @@
+# $NetBSD: t_interp.sh,v 1.1 2017/12/06 13:54:26 christos Exp $
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christos Zoulas.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+atf_test_case procfs_interp
+procfs_interp_head() {
+	atf_set "descr" "Tests the exe name in procfs is correct"
+}
+procfs_interp_body() {
+	atf_require_prog readlink
+	if [ ! -d /proc/curproc/. ]; then
+		atf_skip "procfs not mounted"
+		return
+	fi
+	local me=$(readlink /proc/$$/exe)
+	if [ "$me" != "/bin/sh" ]; then
+		atf_fail "Interpreter is not '/bin/sh': '$me'"
+	fi
+}
+
+atf_init_test_cases() {
+	atf_add_test_case procfs_interp
+}



CVS commit: src/tests/kernel

2017-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 13:54:26 UTC 2017

Modified Files:
src/tests/kernel: Makefile
Added Files:
src/tests/kernel: t_interp.sh

Log Message:
add a test to check that the interpreter is preserved when executing scripts.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/tests/kernel/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/kernel/t_interp.sh

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



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 12:32:02 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Teach fmtcheck(3) about wint_t, intmax_t, char *, intmax_t *, and wide string
arguments. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev181154


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/fmtcheck.c

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

Modified files:

Index: src/lib/libc/gen/fmtcheck.c
diff -u src/lib/libc/gen/fmtcheck.c:1.13 src/lib/libc/gen/fmtcheck.c:1.14
--- src/lib/libc/gen/fmtcheck.c:1.13	Wed Dec  6 12:30:27 2017
+++ src/lib/libc/gen/fmtcheck.c	Wed Dec  6 12:32:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $	*/
+/*	$NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $");
+__RCSID("$NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $");
 #endif
 
 #include "namespace.h"
@@ -47,20 +47,25 @@ enum __e_fmtcheck_types {
 	FMTCHECK_START,
 	FMTCHECK_SHORT,
 	FMTCHECK_INT,
+	FMTCHECK_WINTT,
 	FMTCHECK_LONG,
 	FMTCHECK_QUAD,
+	FMTCHECK_INTMAXT,
 	FMTCHECK_PTRDIFFT,
 	FMTCHECK_SIZET,
 	FMTCHECK_POINTER,
+	FMTCHECK_CHARPOINTER,
 	FMTCHECK_SHORTPOINTER,
 	FMTCHECK_INTPOINTER,
 	FMTCHECK_LONGPOINTER,
 	FMTCHECK_QUADPOINTER,
+	FMTCHECK_INTMAXTPOINTER,
 	FMTCHECK_PTRDIFFTPOINTER,
 	FMTCHECK_SIZETPOINTER,
 	FMTCHECK_DOUBLE,
 	FMTCHECK_LONGDOUBLE,
 	FMTCHECK_STRING,
+	FMTCHECK_WSTRING,
 	FMTCHECK_WIDTH,
 	FMTCHECK_PRECISION,
 	FMTCHECK_DONE,
@@ -68,6 +73,18 @@ enum __e_fmtcheck_types {
 };
 typedef enum __e_fmtcheck_types EFT;
 
+enum e_modifier {
+	MOD_NONE,
+	MOD_CHAR,
+	MOD_SHORT,
+	MOD_LONG,
+	MOD_QUAD,
+	MOD_INTMAXT,
+	MOD_LONGDOUBLE,
+	MOD_PTRDIFFT,
+	MOD_SIZET,
+};
+
 #define RETURN(pf,f,r) do { \
 			*(pf) = (f); \
 			return r; \
@@ -76,42 +93,50 @@ typedef enum __e_fmtcheck_types EFT;
 static EFT
 get_next_format_from_precision(const char **pf)
 {
-	int		sh, lg, quad, longdouble, ptrdifft, sizet;
+	enum e_modifier	modifier;
 	const char	*f;
 
-	sh = lg = quad = longdouble = ptrdifft = sizet = 0;
-
 	f = *pf;
 	switch (*f) {
 	case 'h':
 		f++;
-		sh = 1;
+		if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
+		if (*f == 'h') {
+			f++;
+			modifier = MOD_CHAR;
+		} else {
+			modifier = MOD_SHORT;
+		}
+		break;
+	case 'j':
+		f++;
+		modifier = MOD_INTMAXT;
 		break;
 	case 'l':
 		f++;
 		if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
 		if (*f == 'l') {
 			f++;
-			quad = 1;
+			modifier = MOD_QUAD;
 		} else {
-			lg = 1;
+			modifier = MOD_LONG;
 		}
 		break;
 	case 'q':
 		f++;
-		quad = 1;
+		modifier = MOD_QUAD;
 		break;
 	case 't':
 		f++;
-		ptrdifft = 1;
+		modifier = MOD_PTRDIFFT;
 		break;
 	case 'z':
 		f++;
-		sizet = 1;
+		modifier = MOD_SIZET;
 		break;
 	case 'L':
 		f++;
-		longdouble = 1;
+		modifier = MOD_LONGDOUBLE;
 		break;
 #ifdef WIN32
 	case 'I':
@@ -119,73 +144,113 @@ get_next_format_from_precision(const cha
 		if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
 		if (*f == '3' && f[1] == '2') {
 			f += 2;
+			modifier = MOD_NONE;
 		} else if (*f == '6' && f[1] == '4') {
 			f += 2;
-			quad = 1;
+			modifier = MOD_QUAD;
 		}
 #ifdef _WIN64
 		else {
-			quad = 1;
+			modifier = MOD_QUAD;
 		}
 #endif
 		break;
 #endif
 	default:
+		modifier = MOD_NONE;
 		break;
 	}
 	if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN);
 	if (strchr("diouxX", *f)) {
-		if (longdouble)
-			RETURN(pf,f,FMTCHECK_UNKNOWN);
-		if (lg)
+		switch (modifier) {
+		case MOD_LONG:
 			RETURN(pf,f,FMTCHECK_LONG);
-		if (quad)
+		case MOD_QUAD:
 			RETURN(pf,f,FMTCHECK_QUAD);
-		if (ptrdifft)
+		case MOD_INTMAXT:
+			RETURN(pf,f,FMTCHECK_INTMAXT);
+		case MOD_PTRDIFFT:
 			RETURN(pf,f,FMTCHECK_PTRDIFFT);
-		if (sizet)
+		case MOD_SIZET:
 			RETURN(pf,f,FMTCHECK_SIZET);
-		RETURN(pf,f,FMTCHECK_INT);
+		case MOD_CHAR:
+		case MOD_SHORT:
+		case MOD_NONE:
+			RETURN(pf,f,FMTCHECK_INT);
+		default:
+			RETURN(pf,f,FMTCHECK_UNKNOWN);
+		}
 	}
 	if (*f == 'n') {
-		if (longdouble)
-			RETURN(pf,f,FMTCHECK_UNKNOWN);
-		if (sh)
+		switch (modifier) {
+		case MOD_CHAR:
+			RETURN(pf,f,FMTCHECK_CHARPOINTER);
+		case MOD_SHORT:
 			RETURN(pf,f,FMTCHECK_SHORTPOINTER);
-		if (lg)
+		case MOD_LONG:
 			RETURN(pf,f,FMTCHECK_LONGPOINTER);
-		if (quad)
+		case MOD_QUAD:
 			RETURN(pf,f,FMTCHECK_QUADPOINTER);
-		if (ptrdifft)
+		case MOD_INTMAXT:
+			RETURN(pf,f,FMTCHECK_INTMAXTPOINTER);
+		case MOD_PTRDIFFT:
 			RETURN(pf,f,FMTCHECK_PTRDIFFTPOINTER);
-		if (sizet)
+		case MOD_SIZET:
 			RETURN(pf,f,FMTCHECK_SIZETPOINTER);
-		RETURN(pf,f,FMTCHECK_INTPOINTER);
+		case MOD_NONE:
+			RETURN(pf,f,FMTCHECK_INTPOINTER);
+		default:
+			RETURN(pf,f,FMTCHECK_UNKNOWN);
+		}
 	}
 	if (strchr("DOU", *f)) {
-		if (sh + lg + quad + 

CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 12:32:02 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Teach fmtcheck(3) about wint_t, intmax_t, char *, intmax_t *, and wide string
arguments. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev181154


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/fmtcheck.c

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



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 12:30:27 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Teach fmtcheck(3) about the ' (thousands separator) flag. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev143905


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/fmtcheck.c

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

Modified files:

Index: src/lib/libc/gen/fmtcheck.c
diff -u src/lib/libc/gen/fmtcheck.c:1.12 src/lib/libc/gen/fmtcheck.c:1.13
--- src/lib/libc/gen/fmtcheck.c:1.12	Wed Dec  6 12:28:53 2017
+++ src/lib/libc/gen/fmtcheck.c	Wed Dec  6 12:30:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $	*/
+/*	$NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $");
+__RCSID("$NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $");
 #endif
 
 #include "namespace.h"
@@ -242,7 +242,7 @@ get_next_format(const char **pf, EFT eft
 	}
 
 	/* Eat any of the flags */
-	while (*f && (strchr("#0- +", *f)))
+	while (*f && (strchr("#'0- +", *f)))
 		f++;
 
 	if (*f == '*') {



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 12:30:27 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Teach fmtcheck(3) about the ' (thousands separator) flag. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev143905


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/fmtcheck.c

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



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 12:28:53 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Teach fmtcheck(3) about the flags a, A, F, G, t, and z. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev117014


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/fmtcheck.c

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



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 12:28:53 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Teach fmtcheck(3) about the flags a, A, F, G, t, and z. Taken from FreeBSD:
https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev117014


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/fmtcheck.c

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

Modified files:

Index: src/lib/libc/gen/fmtcheck.c
diff -u src/lib/libc/gen/fmtcheck.c:1.11 src/lib/libc/gen/fmtcheck.c:1.12
--- src/lib/libc/gen/fmtcheck.c:1.11	Wed Dec  6 11:33:34 2017
+++ src/lib/libc/gen/fmtcheck.c	Wed Dec  6 12:28:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $	*/
+/*	$NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $");
+__RCSID("$NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $");
 #endif
 
 #include "namespace.h"
@@ -49,11 +49,15 @@ enum __e_fmtcheck_types {
 	FMTCHECK_INT,
 	FMTCHECK_LONG,
 	FMTCHECK_QUAD,
+	FMTCHECK_PTRDIFFT,
+	FMTCHECK_SIZET,
 	FMTCHECK_POINTER,
 	FMTCHECK_SHORTPOINTER,
 	FMTCHECK_INTPOINTER,
 	FMTCHECK_LONGPOINTER,
 	FMTCHECK_QUADPOINTER,
+	FMTCHECK_PTRDIFFTPOINTER,
+	FMTCHECK_SIZETPOINTER,
 	FMTCHECK_DOUBLE,
 	FMTCHECK_LONGDOUBLE,
 	FMTCHECK_STRING,
@@ -72,10 +76,10 @@ typedef enum __e_fmtcheck_types EFT;
 static EFT
 get_next_format_from_precision(const char **pf)
 {
-	int		sh, lg, quad, longdouble;
+	int		sh, lg, quad, longdouble, ptrdifft, sizet;
 	const char	*f;
 
-	sh = lg = quad = longdouble = 0;
+	sh = lg = quad = longdouble = ptrdifft = sizet = 0;
 
 	f = *pf;
 	switch (*f) {
@@ -97,6 +101,14 @@ get_next_format_from_precision(const cha
 		f++;
 		quad = 1;
 		break;
+	case 't':
+		f++;
+		ptrdifft = 1;
+		break;
+	case 'z':
+		f++;
+		sizet = 1;
+		break;
 	case 'L':
 		f++;
 		longdouble = 1;
@@ -129,6 +141,10 @@ get_next_format_from_precision(const cha
 			RETURN(pf,f,FMTCHECK_LONG);
 		if (quad)
 			RETURN(pf,f,FMTCHECK_QUAD);
+		if (ptrdifft)
+			RETURN(pf,f,FMTCHECK_PTRDIFFT);
+		if (sizet)
+			RETURN(pf,f,FMTCHECK_SIZET);
 		RETURN(pf,f,FMTCHECK_INT);
 	}
 	if (*f == 'n') {
@@ -140,32 +156,36 @@ get_next_format_from_precision(const cha
 			RETURN(pf,f,FMTCHECK_LONGPOINTER);
 		if (quad)
 			RETURN(pf,f,FMTCHECK_QUADPOINTER);
+		if (ptrdifft)
+			RETURN(pf,f,FMTCHECK_PTRDIFFTPOINTER);
+		if (sizet)
+			RETURN(pf,f,FMTCHECK_SIZETPOINTER);
 		RETURN(pf,f,FMTCHECK_INTPOINTER);
 	}
 	if (strchr("DOU", *f)) {
-		if (sh + lg + quad + longdouble)
+		if (sh + lg + quad + longdouble + ptrdifft + sizet)
 			RETURN(pf,f,FMTCHECK_UNKNOWN);
 		RETURN(pf,f,FMTCHECK_LONG);
 	}
-	if (strchr("eEfg", *f)) {
+	if (strchr("aAeEfFgG", *f)) {
 		if (longdouble)
 			RETURN(pf,f,FMTCHECK_LONGDOUBLE);
-		if (sh + lg + quad)
+		if (sh + lg + quad + ptrdifft + sizet)
 			RETURN(pf,f,FMTCHECK_UNKNOWN);
 		RETURN(pf,f,FMTCHECK_DOUBLE);
 	}
 	if (*f == 'c') {
-		if (sh + lg + quad + longdouble)
+		if (sh + lg + quad + longdouble + ptrdifft + sizet)
 			RETURN(pf,f,FMTCHECK_UNKNOWN);
 		RETURN(pf,f,FMTCHECK_INT);
 	}
 	if (*f == 's') {
-		if (sh + lg + quad + longdouble)
+		if (sh + lg + quad + longdouble + ptrdifft + sizet)
 			RETURN(pf,f,FMTCHECK_UNKNOWN);
 		RETURN(pf,f,FMTCHECK_STRING);
 	}
 	if (*f == 'p') {
-		if (sh + lg + quad + longdouble)
+		if (sh + lg + quad + longdouble + ptrdifft + sizet)
 			RETURN(pf,f,FMTCHECK_UNKNOWN);
 		RETURN(pf,f,FMTCHECK_POINTER);
 	}



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 11:33:35 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Correct oversight of wrong format string with fewer number of arguments than
default format string has.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gen/fmtcheck.c

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

Modified files:

Index: src/lib/libc/gen/fmtcheck.c
diff -u src/lib/libc/gen/fmtcheck.c:1.10 src/lib/libc/gen/fmtcheck.c:1.11
--- src/lib/libc/gen/fmtcheck.c:1.10	Wed Jan 20 15:43:05 2016
+++ src/lib/libc/gen/fmtcheck.c	Wed Dec  6 11:33:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmtcheck.c,v 1.10 2016/01/20 15:43:05 christos Exp $	*/
+/*	$NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fmtcheck.c,v 1.10 2016/01/20 15:43:05 christos Exp $");
+__RCSID("$NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $");
 #endif
 
 #include "namespace.h"
@@ -257,5 +257,8 @@ fmtcheck(const char *f1, const char *f2)
 		if (f1t != f2t)
 			return f2;
 	}
-	return f1;
+	if (get_next_format(, f2t) != FMTCHECK_DONE)
+		return f2;
+	else
+		return f1;
 }



CVS commit: src/lib/libc/gen

2017-12-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec  6 11:33:35 UTC 2017

Modified Files:
src/lib/libc/gen: fmtcheck.c

Log Message:
Correct oversight of wrong format string with fewer number of arguments than
default format string has.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gen/fmtcheck.c

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



CVS commit: src/doc

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 10:37:08 UTC 2017

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Note import of dhcpcd-7.0.0-rc4


To generate a diff of this commit:
cvs rdiff -u -r1.1488 -r1.1489 src/doc/3RDPARTY
cvs rdiff -u -r1.2336 -r1.2337 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1488 src/doc/3RDPARTY:1.1489
--- src/doc/3RDPARTY:1.1488	Thu Nov 30 19:49:31 2017
+++ src/doc/3RDPARTY	Wed Dec  6 10:37:08 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1488 2017/11/30 19:49:31 jmcneill Exp $
+#	$NetBSD: 3RDPARTY,v 1.1489 2017/12/06 10:37:08 roy Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -334,8 +334,8 @@ Notes:
 Use the dhcp2netbsd script.
 
 Package:	dhcpcd
-Version:	7.0.0-rc3
-Current Vers:	7.0.0-rc3
+Version:	7.0.0-rc4
+Current Vers:	7.0.0-rc4
 Maintainer:	roy
 Archive Site:	ftp://roy.marples.name/pub/dhcpcd/
 Home Page:	http://roy.marples.name/projects/dhcpcd/

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2336 src/doc/CHANGES:1.2337
--- src/doc/CHANGES:1.2336	Wed Nov 29 04:09:01 2017
+++ src/doc/CHANGES	Wed Dec  6 10:37:08 2017
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2336 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2337 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -89,3 +89,4 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 	qemufwcfg(4): Add driver for QEMU Firmware Configuration device.
 		[jmcneill 20171125]
 	gdb(1): Updated to 8.0.1.  [christos 20171128]
+	dhcpcd(8): Import dhcpcd-7.0.0-rc4. [roy 20171206]



CVS commit: src/doc

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 10:37:08 UTC 2017

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Note import of dhcpcd-7.0.0-rc4


To generate a diff of this commit:
cvs rdiff -u -r1.1488 -r1.1489 src/doc/3RDPARTY
cvs rdiff -u -r1.2336 -r1.2337 src/doc/CHANGES

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



CVS commit: src/external/bsd/dhcpcd/dist/src

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 10:35:05 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.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/bsd/dhcpcd/dist/src/bpf.c
diff -u src/external/bsd/dhcpcd/dist/src/bpf.c:1.4 src/external/bsd/dhcpcd/dist/src/bpf.c:1.5
--- src/external/bsd/dhcpcd/dist/src/bpf.c:1.4	Tue Sep 19 19:19:21 2017
+++ src/external/bsd/dhcpcd/dist/src/bpf.c	Wed Dec  6 10:35:05 2017
@@ -194,7 +194,8 @@ eexit:
 /* BPF requires that we read the entire buffer.
  * So we pass the buffer in the API so we can loop on >1 packet. */
 ssize_t
-bpf_read(struct interface *ifp, int fd, void *data, size_t len, int *flags)
+bpf_read(struct interface *ifp, int fd, void *data, size_t len,
+unsigned int *flags)
 {
 	ssize_t fl = (ssize_t)bpf_frame_header_len(ifp);
 	ssize_t bytes;
@@ -203,7 +204,7 @@ bpf_read(struct interface *ifp, int fd, 
 	struct bpf_hdr packet;
 	const char *payload;
 
-	*flags = 0;
+	*flags &= ~BPF_EOF;
 	for (;;) {
 		if (state->buffer_len == 0) {
 			bytes = read(fd, state->buffer, state->buffer_size);

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.6
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.5	Sat Oct  7 14:14:40 2017
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Wed Dec  6 10:35:05 2017
@@ -428,7 +428,6 @@ decode_rfc3442_rt(struct rt_head *routes
 
 		if ((rt = rt_new(ifp)) == NULL)
 			return -1;
-		TAILQ_INSERT_TAIL(routes, rt, rt_next);
 
 		/* If we have ocets then we have a destination and netmask */
 		dest.s_addr = 0;
@@ -461,6 +460,8 @@ decode_rfc3442_rt(struct rt_head *routes
 		/* If CIDR is 32 then it's a host route. */
 		if (cidr == 32)
 			rt->rt_flags = RTF_HOST;
+
+		TAILQ_INSERT_TAIL(routes, rt, rt_next);
 		n++;
 	}
 	return n;
@@ -1408,27 +1409,24 @@ dhcp_env(char **env, const char *prefix,
 			continue;
 		if (dhcp_getoverride(ifo, opt->option))
 			continue;
-		if ((p = get_option(ifp->ctx, bootp, bootp_len,
-		opt->option, )))
-		{
-			ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
-			opt, dhcp_getoption, p, pl);
-			if (opt->option == DHO_VIVSO &&
-			pl > (int)sizeof(uint32_t))
-			{
-			memcpy(, p, sizeof(en));
-en = ntohl(en);
-vo = vivso_find(en, ifp);
-if (vo) {
-	/* Skip over en + total size */
-	p += sizeof(en) + 1;
-	pl -= sizeof(en) + 1;
-	ep += dhcp_envoption(ifp->ctx,
-	ep, prefix, ifp->name,
-	vo, dhcp_getoption, p, pl);
-}
-			}
-		}
+		p = get_option(ifp->ctx, bootp, bootp_len, opt->option, );
+		if (p == NULL)
+			continue;
+		ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
+		opt, dhcp_getoption, p, pl);
+
+		if (opt->option != DHO_VIVSO || pl <= (int)sizeof(uint32_t))
+			continue;
+		memcpy(, p, sizeof(en));
+		en = ntohl(en);
+		vo = vivso_find(en, ifp);
+		if (vo == NULL)
+			continue;
+		/* Skip over en + total size */
+		p += sizeof(en) + 1;
+		pl -= sizeof(en) + 1;
+		ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
+		vo, dhcp_getoption, p, pl);
 	}
 
 	for (i = 0, opt = ifo->dhcp_override;
@@ -1437,10 +1435,11 @@ dhcp_env(char **env, const char *prefix,
 	{
 		if (has_option_mask(ifo->nomask, opt->option))
 			continue;
-		if ((p = get_option(ifp->ctx, bootp, bootp_len,
-		opt->option, )))
-			ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
-			opt, dhcp_getoption, p, pl);
+		p = get_option(ifp->ctx, bootp, bootp_len, opt->option, );
+		if (p == NULL)
+			continue;
+		ep += dhcp_envoption(ifp->ctx, ep, prefix, ifp->name,
+		opt, dhcp_getoption, p, pl);
 	}
 
 	return ep - env;
@@ -1519,6 +1518,8 @@ static void
 dhcp_new_xid(struct interface *ifp)
 {
 	struct dhcp_state *state;
+	const struct interface *ifp1;
+	const struct dhcp_state *state1;
 
 	state = D_STATE(ifp);
 	if (ifp->options->options & DHCPCD_XID_HWADDR &&
@@ -1527,8 +1528,30 @@ dhcp_new_xid(struct interface *ifp)
 		memcpy(>xid,
 		(ifp->hwaddr + ifp->hwlen) - sizeof(state->xid),
 		sizeof(state->xid));
-	else
+	else {
+again:
 		state->xid = arc4random();
+	}
+
+	/* Ensure it's unique */
+	TAILQ_FOREACH(ifp1, ifp->ctx->ifaces, next) {
+		if (ifp == ifp1)
+			continue;
+		if ((state1 = D_CSTATE(ifp1)) == NULL)
+			continue;
+		if (state1->xid == state->xid)
+			break;
+	}
+	if (ifp1 != NULL) {
+		if (ifp->options->options & DHCPCD_XID_HWADDR &&
+		ifp->hwlen >= sizeof(state->xid))
+		{
+			logerrx("%s: duplicate xid on %s",
+			ifp->name, ifp1->name);
+			return;
+		}
+		goto again;
+	}
 
 	/* We can't do this when sharing leases across 

CVS commit: src/external/bsd/dhcpcd/dist/src

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 10:35:05 UTC 2017

Modified Files:
src/external/bsd/dhcpcd/dist/src: bpf.c dhcp.c dhcpcd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/src/bpf.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcpcd/dist/src/dhcp.c \
src/external/bsd/dhcpcd/dist/src/dhcpcd.c

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



CVS import: src/external/bsd/dhcpcd/dist

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 10:33:30 UTC 2017

Update of /cvsroot/src/external/bsd/dhcpcd/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv23544

Log Message:
Import dhcpcd-7.0.0-rc4 with the following changes:
  *  Don't flush prefix routes/routers if kernel does not support RA
  *  dhcp: improve errors around UDP checksum failure
  *  dhcp: announce existing addresses before rebooting
  *  bpf: rework loop so that we can close/reopen fd inside and abort
  *  ipv6nd: don't handle NA/RA for non active interfaces
  *  dhcp6: listen on all addresses in non master mode
  *  dhcpcd-run-hooks: set protocol in dhcpcd, don't guess
  *  Ensure that xid is unique across all interfaces
  *  dhcp6: redirect message to interface which uses the xid
  *  bsd: strip scope from LL addresses when detecting their addition
  *  ipv6nd: fix address lifetime overflow on carrier up
  *  dhcp6: fix confirmation of lease on carrier up

Status:

Vendor Tag: roy
Release Tags:   dhcpcd-7-0-0-rc4

U src/external/bsd/dhcpcd/dist/.arcconfig
U src/external/bsd/dhcpcd/dist/.gitignore
U src/external/bsd/dhcpcd/dist/BUILDING.md
U src/external/bsd/dhcpcd/dist/LICENSE
U src/external/bsd/dhcpcd/dist/Makefile
U src/external/bsd/dhcpcd/dist/Makefile.inc
U src/external/bsd/dhcpcd/dist/README.md
U src/external/bsd/dhcpcd/dist/config-null.mk
U src/external/bsd/dhcpcd/dist/configure
U src/external/bsd/dhcpcd/dist/iconfig.mk
U src/external/bsd/dhcpcd/dist/compat/_strtoi.h
U src/external/bsd/dhcpcd/dist/compat/arc4random.c
U src/external/bsd/dhcpcd/dist/compat/arc4random.h
U src/external/bsd/dhcpcd/dist/compat/bitops.h
U src/external/bsd/dhcpcd/dist/compat/queue.h
U src/external/bsd/dhcpcd/dist/compat/arc4random_uniform.c
U src/external/bsd/dhcpcd/dist/compat/arc4random_uniform.h
U src/external/bsd/dhcpcd/dist/compat/reallocarray.c
U src/external/bsd/dhcpcd/dist/compat/dprintf.c
U src/external/bsd/dhcpcd/dist/compat/dprintf.h
U src/external/bsd/dhcpcd/dist/compat/endian.h
U src/external/bsd/dhcpcd/dist/compat/pidfile.c
U src/external/bsd/dhcpcd/dist/compat/pidfile.h
U src/external/bsd/dhcpcd/dist/compat/reallocarray.h
U src/external/bsd/dhcpcd/dist/compat/strlcpy.c
U src/external/bsd/dhcpcd/dist/compat/strlcpy.h
U src/external/bsd/dhcpcd/dist/compat/strtoi.c
U src/external/bsd/dhcpcd/dist/compat/strtoi.h
U src/external/bsd/dhcpcd/dist/compat/strtou.c
U src/external/bsd/dhcpcd/dist/compat/crypt/hmac.c
U src/external/bsd/dhcpcd/dist/compat/crypt/hmac.h
U src/external/bsd/dhcpcd/dist/compat/crypt/md5.c
U src/external/bsd/dhcpcd/dist/compat/crypt/md5.h
U src/external/bsd/dhcpcd/dist/compat/crypt/sha256.c
U src/external/bsd/dhcpcd/dist/compat/crypt/sha256.h
C src/external/bsd/dhcpcd/dist/src/dhcp.c
U src/external/bsd/dhcpcd/dist/src/GNUmakefile
U src/external/bsd/dhcpcd/dist/src/Makefile
U src/external/bsd/dhcpcd/dist/src/arp.c
U src/external/bsd/dhcpcd/dist/src/arp.h
U src/external/bsd/dhcpcd/dist/src/auth.c
U src/external/bsd/dhcpcd/dist/src/auth.h
C src/external/bsd/dhcpcd/dist/src/bpf.c
U src/external/bsd/dhcpcd/dist/src/bpf.h
U src/external/bsd/dhcpcd/dist/src/common.c
U src/external/bsd/dhcpcd/dist/src/common.h
U src/external/bsd/dhcpcd/dist/src/control.c
U src/external/bsd/dhcpcd/dist/src/control.h
U src/external/bsd/dhcpcd/dist/src/defs.h
U src/external/bsd/dhcpcd/dist/src/dev.c
U src/external/bsd/dhcpcd/dist/src/dev.h
U src/external/bsd/dhcpcd/dist/src/dhcp-common.c
U src/external/bsd/dhcpcd/dist/src/dhcp-common.h
U src/external/bsd/dhcpcd/dist/src/dhcp.h
U src/external/bsd/dhcpcd/dist/src/dhcp6.c
U src/external/bsd/dhcpcd/dist/src/dhcp6.h
U src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
U src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
U src/external/bsd/dhcpcd/dist/src/dhcpcd-definitions-small.conf
U src/external/bsd/dhcpcd/dist/src/dhcpcd-definitions.conf
U src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c.in
U src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h.in
C src/external/bsd/dhcpcd/dist/src/dhcpcd.c
U src/external/bsd/dhcpcd/dist/src/dhcpcd.conf
U src/external/bsd/dhcpcd/dist/src/genembedc
U src/external/bsd/dhcpcd/dist/src/dhcpcd.h
U src/external/bsd/dhcpcd/dist/src/duid.c
U src/external/bsd/dhcpcd/dist/src/duid.h
U src/external/bsd/dhcpcd/dist/src/eloop.c
U src/external/bsd/dhcpcd/dist/src/eloop.h
U src/external/bsd/dhcpcd/dist/src/if-linux-wext.c
U src/external/bsd/dhcpcd/dist/src/genembedh
U src/external/bsd/dhcpcd/dist/src/if-bsd.c
U src/external/bsd/dhcpcd/dist/src/if-linux.c
U src/external/bsd/dhcpcd/dist/src/if-options.c
U src/external/bsd/dhcpcd/dist/src/if-options.h
U src/external/bsd/dhcpcd/dist/src/if-sun.c
U src/external/bsd/dhcpcd/dist/src/if.c
U src/external/bsd/dhcpcd/dist/src/if.h
U src/external/bsd/dhcpcd/dist/src/ipv4.c
U src/external/bsd/dhcpcd/dist/src/ipv4.h
U src/external/bsd/dhcpcd/dist/src/ipv4ll.c
U src/external/bsd/dhcpcd/dist/src/ipv4ll.h
U src/external/bsd/dhcpcd/dist/src/ipv6.c
U src/external/bsd/dhcpcd/dist/src/ipv6.h
U 

CVS import: src/external/bsd/dhcpcd/dist

2017-12-06 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec  6 10:33:30 UTC 2017

Update of /cvsroot/src/external/bsd/dhcpcd/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv23544

Log Message:
Import dhcpcd-7.0.0-rc4 with the following changes:
  *  Don't flush prefix routes/routers if kernel does not support RA
  *  dhcp: improve errors around UDP checksum failure
  *  dhcp: announce existing addresses before rebooting
  *  bpf: rework loop so that we can close/reopen fd inside and abort
  *  ipv6nd: don't handle NA/RA for non active interfaces
  *  dhcp6: listen on all addresses in non master mode
  *  dhcpcd-run-hooks: set protocol in dhcpcd, don't guess
  *  Ensure that xid is unique across all interfaces
  *  dhcp6: redirect message to interface which uses the xid
  *  bsd: strip scope from LL addresses when detecting their addition
  *  ipv6nd: fix address lifetime overflow on carrier up
  *  dhcp6: fix confirmation of lease on carrier up

Status:

Vendor Tag: roy
Release Tags:   dhcpcd-7-0-0-rc4

U src/external/bsd/dhcpcd/dist/.arcconfig
U src/external/bsd/dhcpcd/dist/.gitignore
U src/external/bsd/dhcpcd/dist/BUILDING.md
U src/external/bsd/dhcpcd/dist/LICENSE
U src/external/bsd/dhcpcd/dist/Makefile
U src/external/bsd/dhcpcd/dist/Makefile.inc
U src/external/bsd/dhcpcd/dist/README.md
U src/external/bsd/dhcpcd/dist/config-null.mk
U src/external/bsd/dhcpcd/dist/configure
U src/external/bsd/dhcpcd/dist/iconfig.mk
U src/external/bsd/dhcpcd/dist/compat/_strtoi.h
U src/external/bsd/dhcpcd/dist/compat/arc4random.c
U src/external/bsd/dhcpcd/dist/compat/arc4random.h
U src/external/bsd/dhcpcd/dist/compat/bitops.h
U src/external/bsd/dhcpcd/dist/compat/queue.h
U src/external/bsd/dhcpcd/dist/compat/arc4random_uniform.c
U src/external/bsd/dhcpcd/dist/compat/arc4random_uniform.h
U src/external/bsd/dhcpcd/dist/compat/reallocarray.c
U src/external/bsd/dhcpcd/dist/compat/dprintf.c
U src/external/bsd/dhcpcd/dist/compat/dprintf.h
U src/external/bsd/dhcpcd/dist/compat/endian.h
U src/external/bsd/dhcpcd/dist/compat/pidfile.c
U src/external/bsd/dhcpcd/dist/compat/pidfile.h
U src/external/bsd/dhcpcd/dist/compat/reallocarray.h
U src/external/bsd/dhcpcd/dist/compat/strlcpy.c
U src/external/bsd/dhcpcd/dist/compat/strlcpy.h
U src/external/bsd/dhcpcd/dist/compat/strtoi.c
U src/external/bsd/dhcpcd/dist/compat/strtoi.h
U src/external/bsd/dhcpcd/dist/compat/strtou.c
U src/external/bsd/dhcpcd/dist/compat/crypt/hmac.c
U src/external/bsd/dhcpcd/dist/compat/crypt/hmac.h
U src/external/bsd/dhcpcd/dist/compat/crypt/md5.c
U src/external/bsd/dhcpcd/dist/compat/crypt/md5.h
U src/external/bsd/dhcpcd/dist/compat/crypt/sha256.c
U src/external/bsd/dhcpcd/dist/compat/crypt/sha256.h
C src/external/bsd/dhcpcd/dist/src/dhcp.c
U src/external/bsd/dhcpcd/dist/src/GNUmakefile
U src/external/bsd/dhcpcd/dist/src/Makefile
U src/external/bsd/dhcpcd/dist/src/arp.c
U src/external/bsd/dhcpcd/dist/src/arp.h
U src/external/bsd/dhcpcd/dist/src/auth.c
U src/external/bsd/dhcpcd/dist/src/auth.h
C src/external/bsd/dhcpcd/dist/src/bpf.c
U src/external/bsd/dhcpcd/dist/src/bpf.h
U src/external/bsd/dhcpcd/dist/src/common.c
U src/external/bsd/dhcpcd/dist/src/common.h
U src/external/bsd/dhcpcd/dist/src/control.c
U src/external/bsd/dhcpcd/dist/src/control.h
U src/external/bsd/dhcpcd/dist/src/defs.h
U src/external/bsd/dhcpcd/dist/src/dev.c
U src/external/bsd/dhcpcd/dist/src/dev.h
U src/external/bsd/dhcpcd/dist/src/dhcp-common.c
U src/external/bsd/dhcpcd/dist/src/dhcp-common.h
U src/external/bsd/dhcpcd/dist/src/dhcp.h
U src/external/bsd/dhcpcd/dist/src/dhcp6.c
U src/external/bsd/dhcpcd/dist/src/dhcp6.h
U src/external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in
U src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
U src/external/bsd/dhcpcd/dist/src/dhcpcd-definitions-small.conf
U src/external/bsd/dhcpcd/dist/src/dhcpcd-definitions.conf
U src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c.in
U src/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h.in
C src/external/bsd/dhcpcd/dist/src/dhcpcd.c
U src/external/bsd/dhcpcd/dist/src/dhcpcd.conf
U src/external/bsd/dhcpcd/dist/src/genembedc
U src/external/bsd/dhcpcd/dist/src/dhcpcd.h
U src/external/bsd/dhcpcd/dist/src/duid.c
U src/external/bsd/dhcpcd/dist/src/duid.h
U src/external/bsd/dhcpcd/dist/src/eloop.c
U src/external/bsd/dhcpcd/dist/src/eloop.h
U src/external/bsd/dhcpcd/dist/src/if-linux-wext.c
U src/external/bsd/dhcpcd/dist/src/genembedh
U src/external/bsd/dhcpcd/dist/src/if-bsd.c
U src/external/bsd/dhcpcd/dist/src/if-linux.c
U src/external/bsd/dhcpcd/dist/src/if-options.c
U src/external/bsd/dhcpcd/dist/src/if-options.h
U src/external/bsd/dhcpcd/dist/src/if-sun.c
U src/external/bsd/dhcpcd/dist/src/if.c
U src/external/bsd/dhcpcd/dist/src/if.h
U src/external/bsd/dhcpcd/dist/src/ipv4.c
U src/external/bsd/dhcpcd/dist/src/ipv4.h
U src/external/bsd/dhcpcd/dist/src/ipv4ll.c
U src/external/bsd/dhcpcd/dist/src/ipv4ll.h
U src/external/bsd/dhcpcd/dist/src/ipv6.c
U src/external/bsd/dhcpcd/dist/src/ipv6.h
U 

CVS commit: src/sys

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 09:54:47 UTC 2017

Modified Files:
src/sys/net: if.c
src/sys/netinet: ip_carp.c

Log Message:
Make if_link_queue MP-safe if IFEF_MPSAFE

if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.

Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.

Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).


To generate a diff of this commit:
cvs rdiff -u -r1.405 -r1.406 src/sys/net/if.c
cvs rdiff -u -r1.93 -r1.94 src/sys/netinet/ip_carp.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/net/if.c
diff -u src/sys/net/if.c:1.405 src/sys/net/if.c:1.406
--- src/sys/net/if.c:1.405	Wed Dec  6 09:03:12 2017
+++ src/sys/net/if.c	Wed Dec  6 09:54:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.405 2017/12/06 09:03:12 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.406 2017/12/06 09:54:47 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.405 2017/12/06 09:03:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.406 2017/12/06 09:54:47 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -715,7 +715,10 @@ if_initialize(ifnet_t *ifp)
 	IF_AFDATA_LOCK_INIT(ifp);
 
 	if (if_is_link_state_changeable(ifp)) {
-		ifp->if_link_si = softint_establish(SOFTINT_NET,
+		u_int flags = SOFTINT_NET;
+		flags |= ISSET(ifp->if_extflags, IFEF_MPSAFE) ?
+		SOFTINT_MPSAFE : 0;
+		ifp->if_link_si = softint_establish(flags,
 		if_link_state_change_si, ifp);
 		if (ifp->if_link_si == NULL) {
 			rv = ENOMEM;
@@ -2191,6 +2194,21 @@ link_rtrequest(int cmd, struct rtentry *
 		if (LQ_ITEM((q), (i)) == LINK_STATE_UNSET)		  \
 			break;		  \
 	}
+
+/*
+ * XXX reusing (ifp)->if_snd->ifq_lock rather than having another spin mutex
+ * for each ifnet.  It doesn't matter because:
+ * - if IFEF_MPSAFE is enabled, if_snd isn't used and lock contentions on
+ *   ifq_lock don't happen
+ * - if IFEF_MPSAFE is disabled, there is no lock contention on ifq_lock
+ *   because if_snd, if_link_state_change and if_link_state_change_softint
+ *   are all called with KERNEL_LOCK
+ */
+#define IF_LINK_STATE_CHANGE_LOCK(ifp)		\
+	mutex_enter((ifp)->if_snd.ifq_lock)
+#define IF_LINK_STATE_CHANGE_UNLOCK(ifp)	\
+	mutex_exit((ifp)->if_snd.ifq_lock)
+
 /*
  * Handle a change in the interface link state and
  * queue notifications.
@@ -2198,7 +2216,7 @@ link_rtrequest(int cmd, struct rtentry *
 void
 if_link_state_change(struct ifnet *ifp, int link_state)
 {
-	int s, idx;
+	int idx;
 
 	KASSERTMSG(if_is_link_state_changeable(ifp),
 	"%s: IFEF_NO_LINK_STATE_CHANGE must not be set, but if_extflags=0x%x",
@@ -2218,7 +2236,7 @@ if_link_state_change(struct ifnet *ifp, 
 		return;
 	}
 
-	s = splnet();
+	IF_LINK_STATE_CHANGE_LOCK(ifp);
 
 	/* Find the last unset event in the queue. */
 	LQ_FIND_UNSET(ifp->if_link_queue, idx);
@@ -2262,7 +2280,7 @@ if_link_state_change(struct ifnet *ifp, 
 	softint_schedule(ifp->if_link_si);
 
 out:
-	splx(s);
+	IF_LINK_STATE_CHANGE_UNLOCK(ifp);
 }
 
 /*
@@ -2273,12 +2291,15 @@ if_link_state_change_softint(struct ifne
 {
 	struct domain *dp;
 	int s = splnet();
+	bool notify;
 
 	KASSERT(!cpu_intr_p());
 
+	IF_LINK_STATE_CHANGE_LOCK(ifp);
+
 	/* Ensure the change is still valid. */
 	if (ifp->if_link_state == link_state) {
-		splx(s);
+		IF_LINK_STATE_CHANGE_UNLOCK(ifp);
 		return;
 	}
 
@@ -2301,9 +2322,14 @@ if_link_state_change_softint(struct ifne
 	 * listeners would have an address and expect it to work right
 	 * away.
 	 */
-	if (link_state == LINK_STATE_UP &&
-	ifp->if_link_state == LINK_STATE_UNKNOWN)
-	{
+	notify = (link_state == LINK_STATE_UP &&
+	ifp->if_link_state == LINK_STATE_UNKNOWN);
+	ifp->if_link_state = link_state;
+	/* The following routines may sleep so release the spin mutex */
+	IF_LINK_STATE_CHANGE_UNLOCK(ifp);
+
+	KERNEL_LOCK_UNLESS_NET_MPSAFE();
+	if (notify) {
 		DOMAIN_FOREACH(dp) {
 			if (dp->dom_if_link_state_change != NULL)
 dp->dom_if_link_state_change(ifp,
@@ -2311,8 +2337,6 @@ if_link_state_change_softint(struct ifne
 		}
 	}
 
-	ifp->if_link_state = link_state;
-
 	/* Notify that the link state has changed. */
 	rt_ifmsg(ifp);
 
@@ -2325,6 +2349,7 @@ if_link_state_change_softint(struct ifne
 		if (dp->dom_if_link_state_change != NULL)
 			dp->dom_if_link_state_change(ifp, link_state);
 	}
+	KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
 	splx(s);
 }
 
@@ 

CVS commit: src/sys

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 09:54:47 UTC 2017

Modified Files:
src/sys/net: if.c
src/sys/netinet: ip_carp.c

Log Message:
Make if_link_queue MP-safe if IFEF_MPSAFE

if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.

Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.

Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).


To generate a diff of this commit:
cvs rdiff -u -r1.405 -r1.406 src/sys/net/if.c
cvs rdiff -u -r1.93 -r1.94 src/sys/netinet/ip_carp.c

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



CVS commit: src/sys

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 09:03:13 UTC 2017

Modified Files:
src/sys/dev/pci: if_wm.c
src/sys/net: if.c if.h

Log Message:
Make if_timer MP-safe if IFEF_MPSAFE

if_timer, a counter used by if_watchdog (if_slowtimo), can be modified in
if_watchdog and if_start and/or interrupt handlers of some device drivers. All
such accesses were serialized by KERNEL_LOCK. If IFEF_MPSAFE is enabled,
KERNEL_LOCK of if_start (and perhaps interrupt handlers) is omitted and if_timer
becomes racy.

Fix the race condition by protecting if_timer by a spin mutex. if_watchdog_reset
and if_watchdog_stop are introduced to ensure to take the mutex on accessing
if_timer. Interface with IFEF_MPSAFE enabled must use the functions.

In addition, if_watchdog callout is now set CALLOUT_MPSAFE if IFEF_MPSAFE. It
means that if_watchdog implemented by a driver must be MP-safe if the driver is
set IFEF_MPSAFE.

Currenlty interfaces with IFEF_MPSAFE implementing if_watchdog and accessing
if_timer in if_start and interrupt handlers are only wm(4). wm is changed to
use the functions. (Its watchdog handler (wm_watchdog) is already MP-safe.

These contracts will be written somewhere in a further commit.

Note that the spin mutex is now ifp->if_snd.ifq_lock to avoid adding another
spin mutex to each interface. For now reusing it isn't problematic (see the
comment to know why) thought if that does matter in the future, feel free to
replace it with a new spin mutex. It's easy to do.


To generate a diff of this commit:
cvs rdiff -u -r1.546 -r1.547 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.404 -r1.405 src/sys/net/if.c
cvs rdiff -u -r1.248 -r1.249 src/sys/net/if.h

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



CVS commit: src/sys

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 09:03:13 UTC 2017

Modified Files:
src/sys/dev/pci: if_wm.c
src/sys/net: if.c if.h

Log Message:
Make if_timer MP-safe if IFEF_MPSAFE

if_timer, a counter used by if_watchdog (if_slowtimo), can be modified in
if_watchdog and if_start and/or interrupt handlers of some device drivers. All
such accesses were serialized by KERNEL_LOCK. If IFEF_MPSAFE is enabled,
KERNEL_LOCK of if_start (and perhaps interrupt handlers) is omitted and if_timer
becomes racy.

Fix the race condition by protecting if_timer by a spin mutex. if_watchdog_reset
and if_watchdog_stop are introduced to ensure to take the mutex on accessing
if_timer. Interface with IFEF_MPSAFE enabled must use the functions.

In addition, if_watchdog callout is now set CALLOUT_MPSAFE if IFEF_MPSAFE. It
means that if_watchdog implemented by a driver must be MP-safe if the driver is
set IFEF_MPSAFE.

Currenlty interfaces with IFEF_MPSAFE implementing if_watchdog and accessing
if_timer in if_start and interrupt handlers are only wm(4). wm is changed to
use the functions. (Its watchdog handler (wm_watchdog) is already MP-safe.

These contracts will be written somewhere in a further commit.

Note that the spin mutex is now ifp->if_snd.ifq_lock to avoid adding another
spin mutex to each interface. For now reusing it isn't problematic (see the
comment to know why) thought if that does matter in the future, feel free to
replace it with a new spin mutex. It's easy to do.


To generate a diff of this commit:
cvs rdiff -u -r1.546 -r1.547 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.404 -r1.405 src/sys/net/if.c
cvs rdiff -u -r1.248 -r1.249 src/sys/net/if.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/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.546 src/sys/dev/pci/if_wm.c:1.547
--- src/sys/dev/pci/if_wm.c:1.546	Thu Nov 30 09:24:18 2017
+++ src/sys/dev/pci/if_wm.c	Wed Dec  6 09:03:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.546 2017/11/30 09:24:18 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.547 2017/12/06 09:03:12 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.546 2017/11/30 09:24:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.547 2017/12/06 09:03:12 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -5932,7 +5932,7 @@ wm_stop_locked(struct ifnet *ifp, int di
 
 	/* Mark the interface as down and cancel the watchdog timer. */
 	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
-	ifp->if_timer = 0;
+	if_watchdog_stop(ifp);
 
 	if (disable) {
 		for (i = 0; i < sc->sc_nqueues; i++) {
@@ -7368,7 +7368,7 @@ wm_send_common_locked(struct ifnet *ifp,
 
 	if (txq->txq_free != ofree) {
 		/* Set a watchdog timer in case the chip flakes out. */
-		ifp->if_timer = 5;
+		if_watchdog_reset(ifp, 5);
 	}
 }
 
@@ -7940,7 +7940,7 @@ wm_nq_send_common_locked(struct ifnet *i
 
 	if (sent) {
 		/* Set a watchdog timer in case the chip flakes out. */
-		ifp->if_timer = 5;
+		if_watchdog_reset(ifp, 5);
 	}
 }
 
@@ -8077,7 +8077,7 @@ wm_txeof(struct wm_softc *sc, struct wm_
 	 * timer.
 	 */
 	if (txq->txq_sfree == WM_TXQUEUELEN(txq))
-		ifp->if_timer = 0;
+		if_watchdog_stop(ifp);
 
 	return processed;
 }

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.404 src/sys/net/if.c:1.405
--- src/sys/net/if.c:1.404	Wed Dec  6 08:23:17 2017
+++ src/sys/net/if.c	Wed Dec  6 09:03:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.404 2017/12/06 08:23:17 knakahara Exp $	*/
+/*	$NetBSD: if.c,v 1.405 2017/12/06 09:03:12 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.404 2017/12/06 08:23:17 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.405 2017/12/06 09:03:12 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -768,9 +768,11 @@ if_register(ifnet_t *ifp)
 	rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
 
 	if (ifp->if_slowtimo != NULL) {
+		int flags = ISSET(ifp->if_extflags, IFEF_MPSAFE) ?
+		CALLOUT_MPSAFE : 0;
 		ifp->if_slowtimo_ch =
 		kmem_zalloc(sizeof(*ifp->if_slowtimo_ch), KM_SLEEP);
-		callout_init(ifp->if_slowtimo_ch, 0);
+		callout_init(ifp->if_slowtimo_ch, flags);
 		callout_setfunc(ifp->if_slowtimo_ch, if_slowtimo, ifp);
 		if_slowtimo(ifp);
 	}
@@ -2503,6 +2505,18 @@ if_up_locked(struct ifnet *ifp)
 }
 
 /*
+ * XXX reusing (ifp)->if_snd->ifq_lock rather than having another spin mutex
+ * for each ifnet.  It doesn't matter because:
+ * - if IFEF_MPSAFE is enabled, if_snd isn't used and lock contention on
+ *   ifq_lock don't happen
+ * - if IFEF_MPSAFE is disabled, there is no lock contention on ifq_lock
+ *   because if_snd and if_watchdog_reset is used with KERNEL_LOCK on packet
+ *   transmissions and if_slowtimo is 

Re: CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Paul Goyette

On Wed, 6 Dec 2017, Tom Ivar Helbekkmo wrote:


Tom Ivar Helbekkmo  writes:


"stop out journey" should be "stop our journey", and the last sentence
should probably be "It seems that you care more about barking than the
dog does, and more about winning the war with a lousy puppy than about
reaching the destination quickly."


I fixed these, as suggested.


Oh, and I'd also change "its canine barking" to "its barking," (note the
addition of a comma), which would make that sentence flow better, and
avoid the unnecessary re-use of the word 'canine'.


Hmmm, it'd be nice if there were a definitive source for this quote; 
without that, I'd rather not "adjust" the language.



+--+--++
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:  |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+--+--++


CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Dec  6 08:38:33 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
Fix typos, thanks to Tom Ivar Helbekkmo


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/games/fortune/datfiles/fortunes

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

Modified files:

Index: src/games/fortune/datfiles/fortunes
diff -u src/games/fortune/datfiles/fortunes:1.67 src/games/fortune/datfiles/fortunes:1.68
--- src/games/fortune/datfiles/fortunes:1.67	Tue Dec  5 22:51:59 2017
+++ src/games/fortune/datfiles/fortunes	Wed Dec  6 08:38:33 2017
@@ -16226,9 +16226,9 @@ road are attacked by a dog with its insi
 immediately feel like jumping off the vehicle, standing on all fours
 and starting to bark back at it. We, in the Vilnius region, let the
 dog bark because that is what its canine nature is like but we do not
-stop out journey because of its canine barking and without any war
+stop our journey because of its canine barking and without any war
 against dogs we calmly continue our journey until we reach our
-destination. It seems that you care more about barking more than the
-dog does and about winning the war with any lousy puppy than about
+destination. It seems that you care more about barking than the dog
+does, and more about winning the war with any lousy puppy than about
 reaching the destination quickly.
 -- Jozef Pilsudski



CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Dec  6 08:38:33 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
Fix typos, thanks to Tom Ivar Helbekkmo


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/games/fortune/datfiles/fortunes

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



Re: CVS commit: src/games/fortune/datfiles

2017-12-06 Thread Tom Ivar Helbekkmo
Tom Ivar Helbekkmo  writes:

> "stop out journey" should be "stop our journey", and the last sentence
> should probably be "It seems that you care more about barking than the
> dog does, and more about winning the war with a lousy puppy than about
> reaching the destination quickly."

Oh, and I'd also change "its canine barking" to "its barking," (note the
addition of a comma), which would make that sentence flow better, and
avoid the unnecessary re-use of the word 'canine'.

-tih
-- 
Most people who graduate with CS degrees don't understand the significance
of Lisp.  Lisp is the most important idea in computer science.  --Alan Kay


CVS commit: src/sys/sys

2017-12-06 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  6 08:25:47 UTC 2017

Modified Files:
src/sys/sys: param.h

Log Message:
Bump kernel version for if_tunnel_check_nesting() used by gif(4) and l2tp(4) 
modules.

Welcome to 8.99.9


To generate a diff of this commit:
cvs rdiff -u -r1.553 -r1.554 src/sys/sys/param.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/sys/param.h
diff -u src/sys/sys/param.h:1.553 src/sys/sys/param.h:1.554
--- src/sys/sys/param.h:1.553	Fri Dec  1 19:04:19 2017
+++ src/sys/sys/param.h	Wed Dec  6 08:25:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.553 2017/12/01 19:04:19 christos Exp $	*/
+/*	$NetBSD: param.h,v 1.554 2017/12/06 08:25:47 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	899000800	/* NetBSD 8.99.8 */
+#define	__NetBSD_Version__	899000900	/* NetBSD 8.99.9 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/sys

2017-12-06 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  6 08:25:47 UTC 2017

Modified Files:
src/sys/sys: param.h

Log Message:
Bump kernel version for if_tunnel_check_nesting() used by gif(4) and l2tp(4) 
modules.

Welcome to 8.99.9


To generate a diff of this commit:
cvs rdiff -u -r1.553 -r1.554 src/sys/sys/param.h

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



CVS commit: src/sys/net

2017-12-06 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  6 08:23:17 UTC 2017

Modified Files:
src/sys/net: if.c if.h if_gif.c if_l2tp.c

Log Message:
unify processing to check nesting count for some tunnel protocols.


To generate a diff of this commit:
cvs rdiff -u -r1.403 -r1.404 src/sys/net/if.c
cvs rdiff -u -r1.247 -r1.248 src/sys/net/if.h
cvs rdiff -u -r1.134 -r1.135 src/sys/net/if_gif.c
cvs rdiff -u -r1.15 -r1.16 src/sys/net/if_l2tp.c

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



CVS commit: src/sys/net

2017-12-06 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  6 08:23:17 UTC 2017

Modified Files:
src/sys/net: if.c if.h if_gif.c if_l2tp.c

Log Message:
unify processing to check nesting count for some tunnel protocols.


To generate a diff of this commit:
cvs rdiff -u -r1.403 -r1.404 src/sys/net/if.c
cvs rdiff -u -r1.247 -r1.248 src/sys/net/if.h
cvs rdiff -u -r1.134 -r1.135 src/sys/net/if_gif.c
cvs rdiff -u -r1.15 -r1.16 src/sys/net/if_l2tp.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/net/if.c
diff -u src/sys/net/if.c:1.403 src/sys/net/if.c:1.404
--- src/sys/net/if.c:1.403	Wed Dec  6 08:12:54 2017
+++ src/sys/net/if.c	Wed Dec  6 08:23:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.403 2017/12/06 08:12:54 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.404 2017/12/06 08:23:17 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.403 2017/12/06 08:12:54 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.404 2017/12/06 08:23:17 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2762,6 +2762,43 @@ if_held(struct ifnet *ifp)
 	return psref_held(>if_psref, ifnet_psref_class);
 }
 
+/*
+ * Some tunnel interfaces can nest, e.g. IPv4 over IPv4 gif(4) tunnel over IPv4.
+ * Check the tunnel nesting count.
+ * Return > 0, if tunnel nesting count is more than limit.
+ * Return 0, if tunnel nesting count is equal or less than limit.
+ */
+int
+if_tunnel_check_nesting(struct ifnet *ifp, struct mbuf *m, int limit)
+{
+	struct m_tag *mtag;
+	int *count;
+
+	mtag = m_tag_find(m, PACKET_TAG_TUNNEL_INFO, NULL);
+	if (mtag != NULL) {
+		count = (int *)(mtag + 1);
+		if (++(*count) > limit) {
+			log(LOG_NOTICE,
+			"%s: recursively called too many times(%d)\n",
+			ifp->if_xname, *count);
+			return EIO;
+		}
+	} else {
+		mtag = m_tag_get(PACKET_TAG_TUNNEL_INFO, sizeof(*count),
+		M_NOWAIT);
+		if (mtag != NULL) {
+			m_tag_prepend(m, mtag);
+			count = (int *)(mtag + 1);
+			*count = 0;
+		} else {
+			log(LOG_DEBUG,
+			"%s: m_tag_get() failed, recursion calls are not prevented.\n",
+			ifp->if_xname);
+		}
+	}
+
+	return 0;
+}
 
 /* common */
 int

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.247 src/sys/net/if.h:1.248
--- src/sys/net/if.h:1.247	Wed Dec  6 08:12:54 2017
+++ src/sys/net/if.h	Wed Dec  6 08:23:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.247 2017/12/06 08:12:54 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.248 2017/12/06 08:23:17 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1034,6 +1034,8 @@ void	if_put(const struct ifnet *, struct
 void	if_acquire(struct ifnet *, struct psref *);
 #define	if_release	if_put
 
+int if_tunnel_check_nesting(struct ifnet *, struct mbuf *, int);
+
 static inline if_index_t
 if_get_index(const struct ifnet *ifp)
 {

Index: src/sys/net/if_gif.c
diff -u src/sys/net/if_gif.c:1.134 src/sys/net/if_gif.c:1.135
--- src/sys/net/if_gif.c:1.134	Mon Nov 27 05:05:50 2017
+++ src/sys/net/if_gif.c	Wed Dec  6 08:23:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.c,v 1.134 2017/11/27 05:05:50 knakahara Exp $	*/
+/*	$NetBSD: if_gif.c,v 1.135 2017/12/06 08:23:17 knakahara Exp $	*/
 /*	$KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.134 2017/11/27 05:05:50 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.135 2017/12/06 08:23:17 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -445,34 +445,8 @@ out:
 static int
 gif_check_nesting(struct ifnet *ifp, struct mbuf *m)
 {
-	struct m_tag *mtag;
-	int *count;
 
-	mtag = m_tag_find(m, PACKET_TAG_TUNNEL_INFO, NULL);
-	if (mtag != NULL) {
-		count = (int *)(mtag + 1);
-		if (++(*count) > max_gif_nesting) {
-			log(LOG_NOTICE,
-			"%s: recursively called too many times(%d)\n",
-			if_name(ifp),
-			*count);
-			return EIO;
-		}
-	} else {
-		mtag = m_tag_get(PACKET_TAG_TUNNEL_INFO, sizeof(*count),
-		M_NOWAIT);
-		if (mtag != NULL) {
-			m_tag_prepend(m, mtag);
-			count = (int *)(mtag + 1);
-			*count = 0;
-		} else {
-			log(LOG_DEBUG,
-			"%s: m_tag_get() failed, recursion calls are not prevented.\n",
-			if_name(ifp));
-		}
-	}
-
-	return 0;
+	return if_tunnel_check_nesting(ifp, m, max_gif_nesting);
 }
 
 static int

Index: src/sys/net/if_l2tp.c
diff -u src/sys/net/if_l2tp.c:1.15 src/sys/net/if_l2tp.c:1.16
--- src/sys/net/if_l2tp.c:1.15	Thu Nov 16 03:07:18 2017
+++ src/sys/net/if_l2tp.c	Wed Dec  6 08:23:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.c,v 1.15 2017/11/16 03:07:18 ozaki-r Exp $	*/
+/*	$NetBSD: if_l2tp.c,v 1.16 2017/12/06 08:23:17 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.15 

CVS commit: src/sys/net

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 08:12:54 UTC 2017

Modified Files:
src/sys/net: if.c if.h if_vlan.c

Log Message:
Ensure to hold if_ioctl_lock on if_up and if_down

One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.


To generate a diff of this commit:
cvs rdiff -u -r1.402 -r1.403 src/sys/net/if.c
cvs rdiff -u -r1.246 -r1.247 src/sys/net/if.h
cvs rdiff -u -r1.116 -r1.117 src/sys/net/if_vlan.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/net/if.c
diff -u src/sys/net/if.c:1.402 src/sys/net/if.c:1.403
--- src/sys/net/if.c:1.402	Wed Dec  6 05:59:59 2017
+++ src/sys/net/if.c	Wed Dec  6 08:12:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.402 2017/12/06 05:59:59 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.403 2017/12/06 08:12:54 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.402 2017/12/06 05:59:59 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.403 2017/12/06 08:12:54 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -209,6 +209,9 @@ static int if_transmit(struct ifnet *, s
 static int if_clone_create(const char *);
 static int if_clone_destroy(const char *);
 static void if_link_state_change_si(void *);
+static void if_up_locked(struct ifnet *);
+static void _if_down(struct ifnet *);
+static void if_down_deactivated(struct ifnet *);
 
 struct if_percpuq {
 	struct ifnet	*ipq_ifp;
@@ -1333,7 +1336,7 @@ if_detach(struct ifnet *ifp)
 	/*
 	 * Do an if_down() to give protocols a chance to do something.
 	 */
-	if_down(ifp);
+	if_down_deactivated(ifp);
 
 #ifdef ALTQ
 	if (ALTQ_IS_ENABLED(>if_snd))
@@ -2400,13 +2403,8 @@ p2p_rtrequest(int req, struct rtentry *r
 	pserialize_read_exit(s);
 }
 
-/*
- * Mark an interface down and notify protocols of
- * the transition.
- * NOTE: must be called at splsoftnet or equivalent.
- */
-void
-if_down(struct ifnet *ifp)
+static void
+_if_down(struct ifnet *ifp)
 {
 	struct ifaddr *ifa;
 	struct domain *dp;
@@ -2442,19 +2440,50 @@ if_down(struct ifnet *ifp)
 	}
 }
 
+static void
+if_down_deactivated(struct ifnet *ifp)
+{
+
+	KASSERT(if_is_deactivated(ifp));
+	_if_down(ifp);
+}
+
+void
+if_down_locked(struct ifnet *ifp)
+{
+
+	KASSERT(mutex_owned(ifp->if_ioctl_lock));
+	_if_down(ifp);
+}
+
 /*
- * Mark an interface up and notify protocols of
+ * Mark an interface down and notify protocols of
  * the transition.
  * NOTE: must be called at splsoftnet or equivalent.
  */
 void
-if_up(struct ifnet *ifp)
+if_down(struct ifnet *ifp)
+{
+
+	mutex_enter(ifp->if_ioctl_lock);
+	if_down_locked(ifp);
+	mutex_exit(ifp->if_ioctl_lock);
+}
+
+/*
+ * Must be called with holding if_ioctl_lock.
+ */
+static void
+if_up_locked(struct ifnet *ifp)
 {
 #ifdef notyet
 	struct ifaddr *ifa;
 #endif
 	struct domain *dp;
 
+	KASSERT(mutex_owned(ifp->if_ioctl_lock));
+
+	KASSERT(!if_is_deactivated(ifp));
 	ifp->if_flags |= IFF_UP;
 	nanotime(>if_lastchange);
 #ifdef notyet
@@ -2500,6 +2529,20 @@ if_slowtimo(void *arg)
 }
 
 /*
+ * Mark an interface up and notify protocols of
+ * the transition.
+ * NOTE: must be called at splsoftnet or equivalent.
+ */
+void
+if_up(struct ifnet *ifp)
+{
+
+	mutex_enter(ifp->if_ioctl_lock);
+	if_up_locked(ifp);
+	mutex_exit(ifp->if_ioctl_lock);
+}
+
+/*
  * Set/clear promiscuous mode on interface ifp based on the truth value
  * of pswitch.  The calls are reference counted so that only the first
  * "on" request actually has an effect, as does the final "off" request.
@@ -2789,12 +2832,12 @@ ifioctl_common(struct ifnet *ifp, u_long
 		KERNEL_LOCK_IF_IFP_MPSAFE(ifp);
 		if (ifp->if_flags & IFF_UP && (ifr->ifr_flags & IFF_UP) == 0) {
 			s = splsoftnet();
-			if_down(ifp);
+			if_down_locked(ifp);
 			splx(s);
 		}
 		if (ifr->ifr_flags & IFF_UP && (ifp->if_flags & IFF_UP) == 0) {
 			s = splsoftnet();
-			if_up(ifp);
+			if_up_locked(ifp);
 			splx(s);
 		}
 		KERNEL_UNLOCK_IF_IFP_MPSAFE(ifp);
@@ -3103,7 +3146,7 @@ doifioctl(struct socket *so, u_long cmd,
 	if (((oif_flags ^ ifp->if_flags) & IFF_UP) != 0) {
 		if ((ifp->if_flags & IFF_UP) != 0) {
 			int s = splsoftnet();
-			if_up(ifp);
+			if_up_locked(ifp);
 			splx(s);
 		}
 	}

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.246 src/sys/net/if.h:1.247
--- src/sys/net/if.h:1.246	Wed Dec  6 05:59:59 2017
+++ src/sys/net/if.h	Wed Dec  6 08:12:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.246 2017/12/06 05:59:59 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.247 2017/12/06 08:12:54 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1006,6 +1006,7 @@ bool	if_is_deactivated(const struct ifne
 void	if_purgeaddrs(struct ifnet *, int, void (*)(struct ifaddr *));
 void	if_detach(struct ifnet *);
 void	if_down(struct 

CVS commit: src/sys/net

2017-12-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 08:12:54 UTC 2017

Modified Files:
src/sys/net: if.c if.h if_vlan.c

Log Message:
Ensure to hold if_ioctl_lock on if_up and if_down

One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.


To generate a diff of this commit:
cvs rdiff -u -r1.402 -r1.403 src/sys/net/if.c
cvs rdiff -u -r1.246 -r1.247 src/sys/net/if.h
cvs rdiff -u -r1.116 -r1.117 src/sys/net/if_vlan.c

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