CVS commit: src/games/fortune/datfiles

2018-05-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May  8 05:24:22 UTC 2018

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

Log Message:
make fortune fatter


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 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.71 src/games/fortune/datfiles/fortunes:1.72
--- src/games/fortune/datfiles/fortunes:1.71	Wed Dec 13 21:11:27 2017
+++ src/games/fortune/datfiles/fortunes	Tue May  8 05:24:22 2018
@@ -16227,3 +16227,7 @@ destination. It seems that you care more
 does, and more about winning the war with any lousy puppy than about
 reaching the destination quickly.
 		-- Jozef Pilsudski
+%
+[NeXT] attracted the strangest kind of hybrid, which was sort of like...
+Unix weenies by Armani.
+		-- John Perry Barlow



CVS commit: src/sys/dev/pci

2018-05-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue May  8 04:11:10 UTC 2018

Modified Files:
src/sys/dev/pci: if_bnx.c if_bnxvar.h

Log Message:
- Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
  Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
  if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pci/if_bnx.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_bnxvar.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_bnx.c
diff -u src/sys/dev/pci/if_bnx.c:1.63 src/sys/dev/pci/if_bnx.c:1.64
--- src/sys/dev/pci/if_bnx.c:1.63	Thu Feb  8 09:05:19 2018
+++ src/sys/dev/pci/if_bnx.c	Tue May  8 04:11:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bnx.c,v 1.63 2018/02/08 09:05:19 dholland Exp $	*/
+/*	$NetBSD: if_bnx.c,v 1.64 2018/05/08 04:11:09 msaitoh Exp $	*/
 /*	$OpenBSD: if_bnx.c,v 1.85 2009/11/09 14:32:41 dlg Exp $ */
 
 /*-
@@ -35,7 +35,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.63 2018/02/08 09:05:19 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.64 2018/05/08 04:11:09 msaitoh Exp $");
 
 /*
  * The following controllers are supported by this driver:
@@ -792,7 +792,8 @@ bnx_attach(device_t parent, device_t sel
 	IFCAP_CSUM_UDPv4_Tx | IFCAP_CSUM_UDPv4_Rx;
 
 	/* Hookup IRQ last. */
-	sc->bnx_intrhand = pci_intr_establish(pc, ih, IPL_NET, bnx_intr, sc);
+	sc->bnx_intrhand = pci_intr_establish_xname(pc, ih, IPL_NET, bnx_intr,
+	sc, device_xname(self));
 	if (sc->bnx_intrhand == NULL) {
 		aprint_error_dev(self, "couldn't establish interrupt");
 		if (intrstr != NULL)
@@ -890,17 +891,7 @@ bnx_detach(device_t dev, int flags)
 
 	/* Stop and reset the controller. */
 	s = splnet();
-	if (ifp->if_flags & IFF_RUNNING)
-		bnx_stop(ifp, 1);
-	else {
-		/* Disable the transmit/receive blocks. */
-		REG_WR(sc, BNX_MISC_ENABLE_CLR_BITS, 0x5ff);
-		REG_RD(sc, BNX_MISC_ENABLE_CLR_BITS);
-		DELAY(20);
-		bnx_disable_intr(sc);
-		bnx_reset(sc, BNX_DRV_MSG_CODE_RESET);
-	}
-
+	bnx_stop(ifp, 1);
 	splx(s);
 
 	pmf_device_deregister(dev);
@@ -3371,10 +3362,11 @@ bnx_stop(struct ifnet *ifp, int disable)
 
 	DBPRINT(sc, BNX_VERBOSE_RESET, "Entering %s()\n", __func__);
 
-	if ((ifp->if_flags & IFF_RUNNING) == 0)
-		return;
-
-	callout_stop(>bnx_timeout);
+	if (disable) {
+		sc->bnx_detaching = 1;
+		callout_halt(>bnx_timeout, NULL);
+	} else
+		callout_stop(>bnx_timeout);
 
 	mii_down(>bnx_mii);
 
@@ -5694,9 +5686,6 @@ bnx_tick(void *xsc)
 	/* Update the statistics from the hardware statistics block. */
 	bnx_stats_update(sc);
 
-	/* Schedule the next tick. */
-	callout_reset(>bnx_timeout, hz, bnx_tick, sc);
-
 	mii = >bnx_mii;
 	mii_tick(mii);
 
@@ -5707,6 +5696,11 @@ bnx_tick(void *xsc)
 	bnx_get_buf(sc, , _prod, _bseq);
 	sc->rx_prod = prod;
 	sc->rx_prod_bseq = prod_bseq;
+
+	/* Schedule the next tick. */
+	if (!sc->bnx_detaching)
+		callout_reset(>bnx_timeout, hz, bnx_tick, sc);
+
 	splx(s);
 	return;
 }

Index: src/sys/dev/pci/if_bnxvar.h
diff -u src/sys/dev/pci/if_bnxvar.h:1.6 src/sys/dev/pci/if_bnxvar.h:1.7
--- src/sys/dev/pci/if_bnxvar.h:1.6	Tue Jul  1 17:11:35 2014
+++ src/sys/dev/pci/if_bnxvar.h	Tue May  8 04:11:09 2018
@@ -210,6 +210,7 @@ struct bnx_softc
 	uint32_t		tx_prod_bseq;	/* Counts the bytes used.  */
 
 	struct callout		bnx_timeout;
+	int			bnx_detaching;
 
 	/* Frame size and mbuf allocation size for RX frames. */
 	uint32_t		max_frame_size;



CVS commit: src/sys/dev/acpi

2018-05-07 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue May  8 03:27:17 UTC 2018

Modified Files:
src/sys/dev/acpi: sdhc_acpi.c

Log Message:
Bail if we have a zero-length memory resource.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/sdhc_acpi.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/acpi/sdhc_acpi.c
diff -u src/sys/dev/acpi/sdhc_acpi.c:1.4 src/sys/dev/acpi/sdhc_acpi.c:1.5
--- src/sys/dev/acpi/sdhc_acpi.c:1.4	Fri Feb 17 10:51:48 2017
+++ src/sys/dev/acpi/sdhc_acpi.c	Tue May  8 03:27:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc_acpi.c,v 1.4 2017/02/17 10:51:48 nonaka Exp $	*/
+/*	$NetBSD: sdhc_acpi.c,v 1.5 2018/05/08 03:27:17 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.4 2017/02/17 10:51:48 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.5 2018/05/08 03:27:17 mlelstv Exp $");
 
 #include 
 #include 
@@ -168,6 +168,10 @@ sdhc_acpi_attach(device_t parent, device
 		aprint_error_dev(self, "incomplete resources\n");
 		goto cleanup;
 	}
+	if (mem->ar_length == 0) {
+		aprint_error_dev(self, "zero length memory resource\n");
+		goto cleanup;
+	}
 	sc->sc_memsize = mem->ar_length;
 
 	if (bus_space_map(sc->sc_memt, mem->ar_base, sc->sc_memsize, 0,



CVS commit: src/tests/lib/libc/sys

2018-05-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May  8 01:02:38 UTC 2018

Modified Files:
src/tests/lib/libc/sys: t_getrusage.c

Log Message:
add tests for maxrss, msgsnd


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_getrusage.c

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

Modified files:

Index: src/tests/lib/libc/sys/t_getrusage.c
diff -u src/tests/lib/libc/sys/t_getrusage.c:1.5 src/tests/lib/libc/sys/t_getrusage.c:1.6
--- src/tests/lib/libc/sys/t_getrusage.c:1.5	Fri Jan 13 15:31:06 2017
+++ src/tests/lib/libc/sys/t_getrusage.c	Mon May  7 21:02:38 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.5 2017/01/13 20:31:06 christos Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.6 2018/05/08 01:02:38 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,17 +29,21 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_getrusage.c,v 1.5 2017/01/13 20:31:06 christos Exp $");
+__RCSID("$NetBSD: t_getrusage.c,v 1.6 2018/05/08 01:02:38 christos Exp $");
 
 #include 
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
 
 static void		work(void);
 static void		sighandler(int);
@@ -117,6 +121,64 @@ ATF_TC_BODY(getrusage_sig, tc)
 		atf_tc_fail("getrusage(2) did not record signals");
 }
 
+ATF_TC(getrusage_maxrss);
+ATF_TC_HEAD(getrusage_maxrss, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test maxrss growing with getrusage(2)");
+}
+
+ATF_TC_BODY(getrusage_maxrss, tc)
+{
+	struct rusage ru;
+	long maxrss;
+	int i;
+
+	(void)memset(, 0, sizeof(struct rusage));
+	ATF_REQUIRE(getrusage(RUSAGE_SELF, ) == 0);
+	maxrss = ru.ru_maxrss;
+
+#define CHUNK (1024 * 1024)
+	for (i = 0; i < 40; i++) {
+		void *p = malloc(CHUNK);
+		memset(p, 0, CHUNK);
+	}
+	ATF_REQUIRE(getrusage(RUSAGE_SELF, ) == 0);
+	ATF_REQUIRE(maxrss < ru.ru_maxrss);
+}
+
+ATF_TC(getrusage_msgsnd);
+ATF_TC_HEAD(getrusage_msgsnd, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test send growing with getrusage(2)");
+}
+
+ATF_TC_BODY(getrusage_msgsnd, tc)
+{
+	struct rusage ru;
+	long msgsnd;
+	int s, i;
+	struct sockaddr_in sin;
+
+	ATF_REQUIRE(getrusage(RUSAGE_SELF, ) == 0);
+	msgsnd = ru.ru_msgsnd;
+
+	s = socket(AF_INET, SOCK_DGRAM, 0);
+	ATF_REQUIRE(s >= 0);
+	memset(, 0, sizeof(sin));
+	sin.sin_family = AF_INET;
+	sin.sin_len = sizeof(sin);
+	sin.sin_addr.s_addr = ntohl(INADDR_LOOPBACK);
+	sin.sin_port = htons();
+
+	for (i = 0; i < 10; i++)
+		ATF_REQUIRE(sendto(s, , sizeof(sin), 0, (void *),
+			(socklen_t)sizeof(sin)) != -1);
+
+	ATF_REQUIRE(getrusage(RUSAGE_SELF, ) == 0);
+	ATF_REQUIRE(msgsnd + 10 == ru.ru_msgsnd);
+	close(s);
+}
+
 ATF_TC(getrusage_utime_back);
 ATF_TC_HEAD(getrusage_utime_back, tc)
 {
@@ -192,6 +254,8 @@ ATF_TP_ADD_TCS(tp)
 
 	ATF_TP_ADD_TC(tp, getrusage_err);
 	ATF_TP_ADD_TC(tp, getrusage_sig);
+	ATF_TP_ADD_TC(tp, getrusage_maxrss);
+	ATF_TP_ADD_TC(tp, getrusage_msgsnd);
 	ATF_TP_ADD_TC(tp, getrusage_utime_back);
 	ATF_TP_ADD_TC(tp, getrusage_utime_zero);
 



CVS commit: src/sys/netinet

2018-05-07 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Mon May  7 23:42:13 UTC 2018

Modified Files:
src/sys/netinet: tcp_output.c

Log Message:
Fix unsigned wraparound on window size calculations.

This is another instance where tp->rcv_adv - tp->rcv_nxt can wrap
around after successful zero-window probe from the peer.  The first
one was fixed by chs@ in revision 1.112 on 2004-05-08.

While here, CSE and de-obfuscate the code a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/netinet/tcp_output.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/netinet/tcp_output.c
diff -u src/sys/netinet/tcp_output.c:1.206 src/sys/netinet/tcp_output.c:1.207
--- src/sys/netinet/tcp_output.c:1.206	Thu May  3 07:13:48 2018
+++ src/sys/netinet/tcp_output.c	Mon May  7 23:42:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_output.c,v 1.206 2018/05/03 07:13:48 maxv Exp $	*/
+/*	$NetBSD: tcp_output.c,v 1.207 2018/05/07 23:42:13 uwe Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -135,7 +135,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.206 2018/05/03 07:13:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.207 2018/05/07 23:42:13 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -987,16 +987,27 @@ again:
 		 * taking into account that we are limited by
 		 * TCP_MAXWIN << tp->rcv_scale.
 		 */
-		long adv = min(win, (long)TCP_MAXWIN << tp->rcv_scale) -
-			(tp->rcv_adv - tp->rcv_nxt);
+		long recwin = min(win, (long)TCP_MAXWIN << tp->rcv_scale);
+		long oldwin, adv;
 
 		/*
-		 * If the new window size ends up being the same as the old
-		 * size when it is scaled, then don't force a window update.
+		 * rcv_nxt may overtake rcv_adv when we accept a
+		 * zero-window probe.
 		 */
-		if ((tp->rcv_adv - tp->rcv_nxt) >> tp->rcv_scale ==
-		(adv + tp->rcv_adv - tp->rcv_nxt) >> tp->rcv_scale)
+		if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt))
+			oldwin = tp->rcv_adv - tp->rcv_nxt;
+		else
+			oldwin = 0;
+
+		/*
+		 * If the new window size ends up being the same as or
+		 * less than the old size when it is scaled, then
+		 * don't force a window update.
+		 */
+		if (recwin >> tp->rcv_scale <= oldwin >> tp->rcv_scale)
 			goto dontupdate;
+
+		adv = recwin - oldwin;
 		if (adv >= (long) (2 * rxsegsize))
 			goto send;
 		if (2 * adv >= (long) so->so_rcv.sb_hiwat)



CVS commit: src/sys

2018-05-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon May  7 21:03:45 UTC 2018

Modified Files:
src/sys/kern: kern_exit.c kern_resource.c
src/sys/sys: resourcevar.h

Log Message:
Load the struct rusage text, data, and stack fields from the vmspace struct.
Before they were all 0. We update them when we call getrusage() or on
process exit() so that the children rusage is accounted for.


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/kern/kern_exit.c
cvs rdiff -u -r1.177 -r1.178 src/sys/kern/kern_resource.c
cvs rdiff -u -r1.56 -r1.57 src/sys/sys/resourcevar.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/kern/kern_exit.c
diff -u src/sys/kern/kern_exit.c:1.270 src/sys/kern/kern_exit.c:1.271
--- src/sys/kern/kern_exit.c:1.270	Tue Nov  7 14:44:04 2017
+++ src/sys/kern/kern_exit.c	Mon May  7 17:03:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exit.c,v 1.270 2017/11/07 19:44:04 christos Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.271 2018/05/07 21:03:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.270 2017/11/07 19:44:04 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.271 2018/05/07 21:03:45 christos Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -325,6 +325,7 @@ exit1(struct lwp *l, int exitcode, int s
 	 * we run at this moment, nothing runs in userland
 	 * anymore.
 	 */
+	ruspace(p);	/* Update our vm resource use */
 	uvm_proc_exit(p);
 
 	/*

Index: src/sys/kern/kern_resource.c
diff -u src/sys/kern/kern_resource.c:1.177 src/sys/kern/kern_resource.c:1.178
--- src/sys/kern/kern_resource.c:1.177	Sun Apr  8 07:43:01 2018
+++ src/sys/kern/kern_resource.c	Mon May  7 17:03:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_resource.c,v 1.177 2018/04/08 11:43:01 mlelstv Exp $	*/
+/*	$NetBSD: kern_resource.c,v 1.178 2018/05/07 21:03:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.177 2018/04/08 11:43:01 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.178 2018/05/07 21:03:45 christos Exp $");
 
 #include 
 #include 
@@ -577,6 +577,7 @@ getrusage1(struct proc *p, int who, stru
 	switch (who) {
 	case RUSAGE_SELF:
 		mutex_enter(p->p_lock);
+		ruspace(p);
 		memcpy(ru, >p_stats->p_ru, sizeof(*ru));
 		calcru(p, >ru_utime, >ru_stime, NULL, NULL);
 		rulwps(p, ru);
@@ -595,6 +596,17 @@ getrusage1(struct proc *p, int who, stru
 }
 
 void
+ruspace(struct proc *p)
+{
+	struct vmspace *vm = p->p_vmspace;
+	struct rusage *ru = >p_stats->p_ru;
+
+	ru->ru_ixrss = vm->vm_tsize << (PAGE_SHIFT - 10);
+	ru->ru_idrss = vm->vm_dsize << (PAGE_SHIFT - 10);
+	ru->ru_isrss = vm->vm_ssize << (PAGE_SHIFT - 10);
+}
+
+void
 ruadd(struct rusage *ru, struct rusage *ru2)
 {
 	long *ip, *ip2;

Index: src/sys/sys/resourcevar.h
diff -u src/sys/sys/resourcevar.h:1.56 src/sys/sys/resourcevar.h:1.57
--- src/sys/sys/resourcevar.h:1.56	Sat Oct 17 20:28:15 2015
+++ src/sys/sys/resourcevar.h	Mon May  7 17:03:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: resourcevar.h,v 1.56 2015/10/18 00:28:15 jmcneill Exp $	*/
+/*	$NetBSD: resourcevar.h,v 1.57 2018/05/07 21:03:45 christos Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -115,6 +115,7 @@ void	lim_setcorename(struct proc *, char
 void	lim_free(struct plimit *);
 
 void	resource_init(void);
+void	ruspace(struct proc *);
 void	ruadd(struct rusage *, struct rusage *);
 void	rulwps(proc_t *, struct rusage *);
 struct	pstats *pstatscopy(struct pstats *);



CVS commit: src/sys/uvm

2018-05-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon May  7 21:00:14 UTC 2018

Modified Files:
src/sys/uvm: uvm_fault.c uvm_fault_i.h

Log Message:
update maxrss (used to always be 0). Patterned after the OpenBSD changes.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/uvm/uvm_fault.c
cvs rdiff -u -r1.29 -r1.30 src/sys/uvm/uvm_fault_i.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/uvm/uvm_fault.c
diff -u src/sys/uvm/uvm_fault.c:1.202 src/sys/uvm/uvm_fault.c:1.203
--- src/sys/uvm/uvm_fault.c:1.202	Mon Nov 20 16:06:54 2017
+++ src/sys/uvm/uvm_fault.c	Mon May  7 17:00:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_fault.c,v 1.202 2017/11/20 21:06:54 chs Exp $	*/
+/*	$NetBSD: uvm_fault.c,v 1.203 2018/05/07 21:00:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.202 2017/11/20 21:06:54 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.203 2018/05/07 21:00:14 christos Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -653,6 +653,33 @@ done:
 	return error;
 }
 
+/*
+ * Update statistics after fault resolution.
+ * - maxrss
+ */
+void
+uvmfault_update_stats(struct uvm_faultinfo *ufi)
+{
+	struct vm_map		*map;
+	struct proc		*p;
+	struct lwp		*l;
+	vsize_t			 res;
+
+	map = ufi->orig_map;
+
+	p = curproc;
+	KASSERT(p != NULL);
+	if (>p_vmspace->vm_map != map)
+		return;
+
+	res = pmap_resident_count(map->pmap);
+	/* Convert res from pages to kilobytes. */
+	res <<= (PAGE_SHIFT - 10);
+
+	l = curlwp;
+	if (l->l_ru.ru_maxrss < res)
+		l->l_ru.ru_maxrss = res;
+}
 
 /*
  *   F A U L T   -   m a i n   e n t r y   p o i n t

Index: src/sys/uvm/uvm_fault_i.h
diff -u src/sys/uvm/uvm_fault_i.h:1.29 src/sys/uvm/uvm_fault_i.h:1.30
--- src/sys/uvm/uvm_fault_i.h:1.29	Thu Apr 19 17:50:10 2018
+++ src/sys/uvm/uvm_fault_i.h	Mon May  7 17:00:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_fault_i.h,v 1.29 2018/04/19 21:50:10 christos Exp $	*/
+/*	$NetBSD: uvm_fault_i.h,v 1.30 2018/05/07 21:00:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -33,6 +33,8 @@
 /*
  * uvm_fault_i.h: fault inline functions
  */
+void uvmfault_update_stats(struct uvm_faultinfo *);
+
 
 /*
  * uvmfault_unlockmaps: unlock the maps
@@ -50,6 +52,7 @@ uvmfault_unlockmaps(struct uvm_faultinfo
 		return;
 	}
 
+	uvmfault_update_stats(ufi);
 	if (write_locked) {
 		vm_map_unlock(ufi->map);
 	} else {



CVS commit: src/sys/netinet

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 19:34:04 UTC 2018

Modified Files:
src/sys/netinet: ip_mroute.c

Log Message:
Fix possible buffer overflow. We need to make sure the inner IPv4 packet
doesn't have options, because we validate only an option-less header.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/netinet/ip_mroute.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/netinet/ip_mroute.c
diff -u src/sys/netinet/ip_mroute.c:1.157 src/sys/netinet/ip_mroute.c:1.158
--- src/sys/netinet/ip_mroute.c:1.157	Wed Apr 11 06:26:00 2018
+++ src/sys/netinet/ip_mroute.c	Mon May  7 19:34:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_mroute.c,v 1.157 2018/04/11 06:26:00 maxv Exp $	*/
+/*	$NetBSD: ip_mroute.c,v 1.158 2018/05/07 19:34:03 maxv Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.157 2018/04/11 06:26:00 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.158 2018/05/07 19:34:03 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3070,6 +3070,13 @@ pim_input(struct mbuf *m, ...)
 			return;
 		}
 
+		/* verify the inner packet doesn't have options */
+		if (encap_ip->ip_hl != (sizeof(struct ip) >> 2)) {
+			pimstat.pims_rcv_badregisters++;
+			m_freem(m);
+			return;
+		}
+
 		/* verify the inner packet is destined to a mcast group */
 		if (!IN_MULTICAST(encap_ip->ip_dst.s_addr)) {
 			pimstat.pims_rcv_badregisters++;



CVS commit: src/sys/dev/i2c

2018-05-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May  7 15:03:19 UTC 2018

Modified Files:
src/sys/dev/i2c: gttwsi_core.c gttwsivar.h

Log Message:
Don't sleep with IPL_VM lock held.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/gttwsi_core.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/i2c/gttwsivar.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/i2c/gttwsi_core.c
diff -u src/sys/dev/i2c/gttwsi_core.c:1.4 src/sys/dev/i2c/gttwsi_core.c:1.5
--- src/sys/dev/i2c/gttwsi_core.c:1.4	Thu May  3 02:08:52 2018
+++ src/sys/dev/i2c/gttwsi_core.c	Mon May  7 15:03:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: gttwsi_core.c,v 1.4 2018/05/03 02:08:52 jmcneill Exp $	*/
+/*	$NetBSD: gttwsi_core.c,v 1.5 2018/05/07 15:03:19 jmcneill Exp $	*/
 /*
  * Copyright (c) 2008 Eiji Kawauchi.
  * All rights reserved.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.4 2018/05/03 02:08:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.5 2018/05/07 15:03:19 jmcneill Exp $");
 #include "locators.h"
 
 #include 
@@ -195,7 +195,7 @@ gttwsi_intr(void *arg)
 	if (val & CONTROL_IFLG) {
 		gttwsi_write_4(sc, TWSI_CONTROL, val & ~CONTROL_INTEN);
 		mutex_enter(>sc_mtx);
-		cv_signal(>sc_cv);
+		cv_broadcast(>sc_cv);
 		mutex_exit(>sc_mtx);
 
 		return 1;	/* handled */
@@ -210,6 +210,11 @@ gttwsi_acquire_bus(void *arg, int flags)
 	struct gttwsi_softc *sc = arg;
 
 	mutex_enter(>sc_buslock);
+	while (sc->sc_inuse)
+		cv_wait(>sc_cv, >sc_buslock);
+	sc->sc_inuse = true;
+	mutex_exit(>sc_buslock);
+
 	return 0;
 }
 
@@ -219,6 +224,9 @@ gttwsi_release_bus(void *arg, int flags)
 {
 	struct gttwsi_softc *sc = arg;
 
+	mutex_enter(>sc_buslock);
+	sc->sc_inuse = false;
+	cv_broadcast(>sc_cv);
 	mutex_exit(>sc_buslock);
 }
 
@@ -228,7 +236,7 @@ gttwsi_send_start(void *v, int flags)
 	struct gttwsi_softc *sc = v;
 	int expect;
 
-	KASSERT(mutex_owned(>sc_buslock));
+	KASSERT(sc->sc_inuse);
 
 	if (sc->sc_started)
 		expect = STAT_RSCT;
@@ -245,7 +253,7 @@ gttwsi_send_stop(void *v, int flags)
 	int retry = TWSI_RETRY_COUNT;
 	uint32_t control;
 
-	KASSERT(mutex_owned(>sc_buslock));
+	KASSERT(sc->sc_inuse);
 
 	sc->sc_started = false;
 
@@ -272,7 +280,7 @@ gttwsi_initiate_xfer(void *v, i2c_addr_t
 	uint32_t data, expect;
 	int error, read;
 
-	KASSERT(mutex_owned(>sc_buslock));
+	KASSERT(sc->sc_inuse);
 
 	gttwsi_send_start(v, flags);
 
@@ -318,7 +326,7 @@ gttwsi_read_byte(void *v, uint8_t *valp,
 	struct gttwsi_softc *sc = v;
 	int error;
 
-	KASSERT(mutex_owned(>sc_buslock));
+	KASSERT(sc->sc_inuse);
 
 	if (flags & I2C_F_LAST)
 		error = gttwsi_wait(sc, 0, STAT_MRRD_ANT, flags);
@@ -337,7 +345,7 @@ gttwsi_write_byte(void *v, uint8_t val, 
 	struct gttwsi_softc *sc = v;
 	int error;
 
-	KASSERT(mutex_owned(>sc_buslock));
+	KASSERT(sc->sc_inuse);
 
 	gttwsi_write_4(sc, TWSI_DATA, val);
 	error = gttwsi_wait(sc, 0, STAT_MTDB_AR, flags);
@@ -353,7 +361,7 @@ gttwsi_wait(struct gttwsi_softc *sc, uin
 	uint32_t status;
 	int timo, error = 0;
 
-	KASSERT(mutex_owned(>sc_buslock));
+	KASSERT(sc->sc_inuse);
 
 	DELAY(5);
 	if (!(flags & I2C_F_POLL))

Index: src/sys/dev/i2c/gttwsivar.h
diff -u src/sys/dev/i2c/gttwsivar.h:1.3 src/sys/dev/i2c/gttwsivar.h:1.4
--- src/sys/dev/i2c/gttwsivar.h:1.3	Sun Oct 29 14:59:05 2017
+++ src/sys/dev/i2c/gttwsivar.h	Mon May  7 15:03:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: gttwsivar.h,v 1.3 2017/10/29 14:59:05 jmcneill Exp $	*/
+/*	$NetBSD: gttwsivar.h,v 1.4 2018/05/07 15:03:19 jmcneill Exp $	*/
 /*
  * Copyright (c) 2008 Eiji Kawauchi.
  * All rights reserved.
@@ -86,6 +86,7 @@ struct gttwsi_softc {
 	struct i2c_controller sc_i2c;
 	kmutex_t sc_buslock;
 	kmutex_t sc_mtx;
+	bool sc_inuse;
 	kcondvar_t sc_cv;
 
 	bool sc_iflg_rwc;



CVS commit: [netbsd-8] src/doc

2018-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May  7 13:28:35 UTC 2018

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

Log Message:
Ticket #782


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.194 -r1.1.2.195 src/doc/CHANGES-8.0

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

Modified files:

Index: src/doc/CHANGES-8.0
diff -u src/doc/CHANGES-8.0:1.1.2.194 src/doc/CHANGES-8.0:1.1.2.195
--- src/doc/CHANGES-8.0:1.1.2.194	Mon May  7 05:09:40 2018
+++ src/doc/CHANGES-8.0	Mon May  7 13:28:35 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.194 2018/05/07 05:09:40 snj Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.195 2018/05/07 13:28:35 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -1,3 +1,10 @@ usr.sbin/sysinst/partman.c			1.20-1.21
 	PR install/53220.
 	[kre, ticket #801]
 
+sys/dev/usb/if_axe.c1.85-1.89
+
+	Fix unintialized variable, merge duplicate code.
+	Use the proper station nodeid read command.
+	[nonaka, ticket #782]
+
+



CVS commit: [netbsd-8] src/sys/dev/usb

2018-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon May  7 13:26:03 UTC 2018

Modified Files:
src/sys/dev/usb [netbsd-8]: if_axe.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #782):

sys/dev/usb/if_axe.c: revision 1.85-1.89

propagate pullup-782 for NetBSD-8 to HEAD (gcc uninitialized)

It was not gcc's fault for correctly detecting an uninitialized variable.

Fix the uninitialized variable issues by error checking things.
downgrade error to debug.

merge duplicated code, back to logging error.

use the proper station nodeid read command.


To generate a diff of this commit:
cvs rdiff -u -r1.82.6.2 -r1.82.6.3 src/sys/dev/usb/if_axe.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/usb/if_axe.c
diff -u src/sys/dev/usb/if_axe.c:1.82.6.2 src/sys/dev/usb/if_axe.c:1.82.6.3
--- src/sys/dev/usb/if_axe.c:1.82.6.2	Wed Jan 31 18:01:55 2018
+++ src/sys/dev/usb/if_axe.c	Mon May  7 13:26:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axe.c,v 1.82.6.2 2018/01/31 18:01:55 martin Exp $	*/
+/*	$NetBSD: if_axe.c,v 1.82.6.3 2018/05/07 13:26:03 martin Exp $	*/
 /*	$OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.2 2018/01/31 18:01:55 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.3 2018/05/07 13:26:03 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -303,7 +303,7 @@ axe_cmd(struct axe_softc *sc, int cmd, i
 	KASSERT(mutex_owned(>axe_mii_lock));
 
 	if (sc->axe_dying)
-		return 0;
+		return -1;
 
 	DPRINTFN(20, "cmd %#jx index %#jx val %#jx", cmd, index, val, 0);
 
@@ -337,7 +337,7 @@ axe_miibus_readreg_locked(device_t dev, 
 
 	axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
 
-	err = axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, (void *));
+	err = axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, );
 	axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
 	if (err) {
 		aprint_error_dev(sc->axe_dev, "read PHY failed\n");
@@ -389,7 +389,7 @@ axe_miibus_writereg_locked(device_t dev,
 	val = htole16(aval);
 
 	axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
-	err = axe_cmd(sc, AXE_CMD_MII_WRITE_REG, reg, phy, (void *));
+	err = axe_cmd(sc, AXE_CMD_MII_WRITE_REG, reg, phy, );
 	axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
 
 	if (err) {
@@ -477,7 +477,11 @@ axe_setmulti(struct axe_softc *sc)
 		return;
 
 	axe_lock_mii(sc);
-	axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, (void *));
+	if (axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, )) {
+		axe_unlock_mii(sc);
+		aprint_error_dev(sc->axe_dev, "can't read rxmode");
+		return;
+	}
 	rxmode = le16toh(rxmode);
 
 	rxmode &=
@@ -507,7 +511,7 @@ axe_setmulti(struct axe_softc *sc)
 	ifp->if_flags &= ~IFF_ALLMULTI;
 	rxmode |= AXE_RXCMD_MULTICAST;
 
-	axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, (void *));
+	axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, hashtbl);
 	axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
 	axe_unlock_mii(sc);
 	return;
@@ -519,6 +523,30 @@ axe_setmulti(struct axe_softc *sc)
 	axe_unlock_mii(sc);
 }
 
+static void
+axe_ax_init(struct axe_softc *sc)
+{
+	int cmd = AXE_178_CMD_READ_NODEID;
+
+	if (sc->axe_flags & AX178) {
+		axe_ax88178_init(sc);
+	} else if (sc->axe_flags & AX772) {
+		axe_ax88772_init(sc);
+	} else if (sc->axe_flags & AX772A) {
+		axe_ax88772a_init(sc);
+	} else if (sc->axe_flags & AX772B) {
+		axe_ax88772b_init(sc);
+		return;
+	} else {
+		cmd = AXE_172_CMD_READ_NODEID;
+	}
+
+	if (axe_cmd(sc, cmd, 0, 0, sc->axe_enaddr)) {
+		aprint_error_dev(sc->axe_dev,
+		"failed to read ethernet address\n");
+	}
+}
+
 
 static void
 axe_reset(struct axe_softc *sc)
@@ -542,15 +570,8 @@ axe_reset(struct axe_softc *sc)
 #else
 	axe_lock_mii(sc);
 
-	if (sc->axe_flags & AX178) {
-		axe_ax88178_init(sc);
-	} else if (sc->axe_flags & AX772) {
-		axe_ax88772_init(sc);
-	} else if (sc->axe_flags & AX772A) {
-		axe_ax88772a_init(sc);
-	} else if (sc->axe_flags & AX772B) {
-		axe_ax88772b_init(sc);
-	}
+	axe_ax_init(sc);
+
 	axe_unlock_mii(sc);
 #endif
 }
@@ -594,7 +615,8 @@ axe_ax88178_init(struct axe_softc *sc)
 
 	axe_cmd(sc, AXE_CMD_SROM_WR_ENABLE, 0, 0, NULL);
 	/* XXX magic */
-	axe_cmd(sc, AXE_CMD_SROM_READ, 0, 0x0017, );
+	if (axe_cmd(sc, AXE_CMD_SROM_READ, 0, 0x0017, ) != 0)
+		eeprom = 0x;
 	axe_cmd(sc, AXE_CMD_SROM_WR_DISABLE, 0, 0, NULL);
 
 	eeprom = le16toh(eeprom);
@@ -752,8 +774,7 @@ axe_ax88772_phywake(struct axe_softc *sc
 	if (sc->axe_phyno == AXE_772_PHY_NO_EPHY) {
 		/* Manually select internal(embedded) PHY - MAC mode. */
 		axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0,
-		AXE_SW_PHY_SELECT_EMBEDDED,
-		NULL);
+		AXE_SW_PHY_SELECT_EMBEDDED, NULL);
 		usbd_delay_ms(sc->axe_udev, hztoms(hz / 32));
 	} else {
 		/*
@@ -815,7 +836,12 @@ axe_ax88772b_init(struct axe_softc *sc)
 	 * Save PHY power saving configuration(high byte) and
 	 * clear EEPROM checksum value(low byte).
 	 */
-	axe_cmd(sc, 

CVS commit: src/sys/dev/fdt

2018-05-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon May  7 12:58:58 UTC 2018

Modified Files:
src/sys/dev/fdt: pwm_backlight.c

Log Message:
Build fix


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/pwm_backlight.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/fdt/pwm_backlight.c
diff -u src/sys/dev/fdt/pwm_backlight.c:1.2 src/sys/dev/fdt/pwm_backlight.c:1.3
--- src/sys/dev/fdt/pwm_backlight.c:1.2	Sun May  6 10:45:32 2018
+++ src/sys/dev/fdt/pwm_backlight.c	Mon May  7 12:58:58 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: pwm_backlight.c,v 1.2 2018/05/06 10:45:32 jmcneill Exp $ */
+/* $NetBSD: pwm_backlight.c,v 1.3 2018/05/07 12:58:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.2 2018/05/06 10:45:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.3 2018/05/07 12:58:58 jmcneill Exp $");
 
 #include 
 #include 
@@ -223,7 +223,7 @@ pwm_backlight_sysctl_init(struct pwm_bac
 
 	error = sysctl_createv(, 0, , NULL,
 	0, CTLTYPE_STRING, "levels", NULL,
-	NULL, 0, sc->sc_levelstr, NULL,
+	NULL, 0, sc->sc_levelstr, 0,
 	CTL_CREATE, CTL_EOL);
 	if (error)
 		goto failed;



CVS commit: src/share/man/man9

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 10:53:45 UTC 2018

Modified Files:
src/share/man/man9: mbuf.9

Log Message:
Clean up, improve a bit, and document m_remove_pkthdr.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/share/man/man9/mbuf.9

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

Modified files:

Index: src/share/man/man9/mbuf.9
diff -u src/share/man/man9/mbuf.9:1.63 src/share/man/man9/mbuf.9:1.64
--- src/share/man/man9/mbuf.9:1.63	Sat Apr 28 08:34:45 2018
+++ src/share/man/man9/mbuf.9	Mon May  7 10:53:45 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mbuf.9,v 1.63 2018/04/28 08:34:45 maxv Exp $
+.\"	$NetBSD: mbuf.9,v 1.64 2018/05/07 10:53:45 maxv Exp $
 .\"
 .\" Copyright (c) 1997 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -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 28, 2018
+.Dd May 7, 2018
 .Dt MBUF 9
 .Os
 .Sh NAME
@@ -59,6 +59,7 @@
 .Nm MCLGET ,
 .Nm M_COPY_PKTHDR ,
 .Nm M_MOVE_PKTHDR ,
+.Nm m_remove_pkthdr ,
 .Nm M_ALIGN ,
 .Nm MH_ALIGN ,
 .Nm M_LEADINGSPACE ,
@@ -123,6 +124,8 @@
 .Ft void
 .Fn M_MOVE_PKTHDR "struct mbuf *to" "struct mbuf *from"
 .Ft void
+.Fn m_remove_pkthdr "struct mbuf *m"
+.Ft void
 .Fn M_ALIGN "struct mbuf *m" "int len"
 .Ft void
 .Fn MH_ALIGN "struct mbuf *m" "int len"
@@ -145,7 +148,7 @@ consists of a header and a data area.
 It is of a fixed size,
 .Dv MSIZE
 .Pq defined in Aq Pa machine/param.h ,
-which includes overhead.
+which includes the size of the header.
 The header contains a pointer to the next
 .Nm
 in the
@@ -206,10 +209,6 @@ the record:
 sent/received as link-level broadcast
 .It Dv M_MCAST
 sent/received as link-level multicast
-.It Dv M_LINK0 ,
-.It Dv M_LINK1 ,
-.It Dv M_LINK2
-three link-level specific flags.
 .El
 .Pp
 An
@@ -219,7 +218,7 @@ may add a single
 of
 .Dv MCLBYTES
 bytes
-.Pq also defined in Aq Pa machine/param.h ,
+.Pq defined in Aq Pa machine/param.h ,
 which has no additional overhead
 and is used instead of the internal data area; this is done when at least
 .Dv MINCLSIZE
@@ -227,9 +226,10 @@ bytes of data must be stored.
 .Pp
 When the
 .Dv M_EXT
-flag is raised for an mbuf,
+flag is set on an mbuf,
 the external storage area could be shared among multiple mbufs.
-Be careful when you attempt to overwrite the data content of the mbuf.
+Therefore, care must be taken when overwriting the data content of an
+mbuf, because its external storage could be considered as read-only.
 .Bl -tag -width compact
 .It Fn m_get "int how" "int type"
 Allocates an mbuf and initializes it to contain internal data.
@@ -540,21 +540,18 @@ Returns a pointer to the data contained 
 .Fa m ,
 type-casted to the specified data type
 .Fa datatype .
-Implemented as a macro.
 .It Fn MGET "struct mbuf *m" "int how" "int type"
 Allocates mbuf
 .Fa m
 and initializes it to contain internal data.
 See
 .Fn m_get .
-Implemented as a macro.
 .It Fn MGETHDR "struct mbuf *m" "int how" "int type"
 Allocates mbuf
 .Fa m
 and initializes it to contain a packet header.
 See
 .Fn m_gethdr .
-Implemented as a macro.
 .It Fn MEXTMALLOC "struct mbuf *m" "int len" "int how"
 Allocates external storage of size
 .Fa len
@@ -568,7 +565,6 @@ from caller.
 The flag
 .Dv M_EXT
 is set upon success.
-Implemented as a macro.
 .It Fn MEXTADD "struct mbuf *m" "void *buf" "int size" "int type" "void (*free)(struct mbuf *, void *, size_t, void *)" "void *arg"
 Adds pre-allocated external storage
 .Fa buf
@@ -594,7 +590,6 @@ is a possible argument to the free routi
 The flag
 .Dv M_EXT
 is set upon success.
-Implemented as a macro.
 If a free routine is specified, it will be called when the mbuf is freed.
 In the case of former, the first argument for a free routine is the mbuf
 .Fa m
@@ -612,7 +607,6 @@ from caller.
 The flag
 .Dv M_EXT
 is set upon success.
-Implemented as a macro.
 .It Fn M_COPY_PKTHDR "struct mbuf *to" "struct mbuf *from"
 Copies the mbuf pkthdr from mbuf
 .Fa from
@@ -624,7 +618,6 @@ must have the type flag
 set, and
 .Fa to
 must be empty.
-Implemented as a macro.
 .It Fn M_MOVE_PKTHDR "struct mbuf *to" "struct mbuf *from"
 Moves the mbuf pkthdr from mbuf
 .Fa from
@@ -641,6 +634,14 @@ The flag
 in mbuf
 .Fa from
 will be cleared.
+.It Fn m_remove_pkthdr "struct mbuf *m"
+Removes the mbuf pkthdr from mbuf
+.Fa m .
+.Fa m
+must have the flag
+.Dv M_PKTHDR
+set.
+This flag will be cleared.
 .It Fn M_ALIGN "struct mbuf *m" "int len"
 Sets the data pointer of a newly allocated mbuf
 .Fa m
@@ -651,7 +652,6 @@ bytes from the end of the mbuf data area
 bytes of data written to the mbuf
 .Fa m ,
 starting at the data pointer, will be aligned to the end of the data area.
-Implemented as a macro.
 .It Fn MH_ALIGN "struct mbuf *m" "int len"
 Sets the data pointer of a newly allocated packetheader mbuf
 .Fa m
@@ -662,21 +662,18 @@ bytes from the end of the mbuf 

CVS commit: src/sys/netinet6

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 10:21:08 UTC 2018

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

Log Message:
Remove misleading comments.


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/sys/netinet6/icmp6.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/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.236 src/sys/netinet6/icmp6.c:1.237
--- src/sys/netinet6/icmp6.c:1.236	Tue May  1 07:21:39 2018
+++ src/sys/netinet6/icmp6.c	Mon May  7 10:21:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.236 2018/05/01 07:21:39 maxv Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.237 2018/05/07 10:21:08 maxv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.236 2018/05/01 07:21:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.237 2018/05/07 10:21:08 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -766,7 +766,7 @@ _icmp6_input(struct mbuf *m, int off, in
 			memset(p, 0, 4);
 			memcpy(p + 4, hostname, maxhlen); /* meaningless TTL */
 
-			M_COPY_PKTHDR(n, m); /* just for rcvif */
+			M_COPY_PKTHDR(n, m);
 			n->m_pkthdr.len = n->m_len = sizeof(struct ip6_hdr) +
 sizeof(struct icmp6_hdr) + 4 + maxhlen;
 			nicmp6->icmp6_type = ICMP6_WRUREPLY;
@@ -1407,7 +1407,7 @@ ni6_input(struct mbuf *m, int off)
 	if (n == NULL) {
 		goto bad;
 	}
-	M_MOVE_PKTHDR(n, m); /* just for rcvif */
+	M_MOVE_PKTHDR(n, m);
 	if (replylen > MHLEN) {
 		if (replylen > MCLBYTES) {
 			/*



CVS commit: src/sys/kern

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 09:57:37 UTC 2018

Modified Files:
src/sys/kern: uipc_mbuf.c

Log Message:
Copy some KASSERTs from m_move_pkthdr into m_copy_pkthdr, and reorder the
latter to reduce the diff with the former.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/kern/uipc_mbuf.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/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.214 src/sys/kern/uipc_mbuf.c:1.215
--- src/sys/kern/uipc_mbuf.c:1.214	Thu May  3 07:46:17 2018
+++ src/sys/kern/uipc_mbuf.c	Mon May  7 09:57:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.214 2018/05/03 07:46:17 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.215 2018/05/07 09:57:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.214 2018/05/03 07:46:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.215 2018/05/07 09:57:37 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -1546,19 +1546,21 @@ m_remove_pkthdr(struct mbuf *m)
 void
 m_copy_pkthdr(struct mbuf *to, struct mbuf *from)
 {
+	KASSERT((to->m_flags & M_EXT) == 0);
+	KASSERT((to->m_flags & M_PKTHDR) == 0 || m_tag_first(to) == NULL);
 	KASSERT((from->m_flags & M_PKTHDR) != 0);
 
 	to->m_pkthdr = from->m_pkthdr;
 	to->m_flags = from->m_flags & M_COPYFLAGS;
+	to->m_data = to->m_pktdat;
+
 	SLIST_INIT(>m_pkthdr.tags);
 	m_tag_copy_chain(to, from);
-	to->m_data = to->m_pktdat;
 }
 
 void
 m_move_pkthdr(struct mbuf *to, struct mbuf *from)
 {
-
 	KASSERT((to->m_flags & M_EXT) == 0);
 	KASSERT((to->m_flags & M_PKTHDR) == 0 || m_tag_first(to) == NULL);
 	KASSERT((from->m_flags & M_PKTHDR) != 0);



CVS commit: src/sys/net

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 09:51:03 UTC 2018

Modified Files:
src/sys/net: if_ieee1394subr.c if_l2tp.c

Log Message:
Use m_remove_pkthdr.

ok knakahara@ (for L2TP)


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/net/if_ieee1394subr.c
cvs rdiff -u -r1.25 -r1.26 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_ieee1394subr.c
diff -u src/sys/net/if_ieee1394subr.c:1.60 src/sys/net/if_ieee1394subr.c:1.61
--- src/sys/net/if_ieee1394subr.c:1.60	Thu Apr 26 19:56:55 2018
+++ src/sys/net/if_ieee1394subr.c	Mon May  7 09:51:02 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ieee1394subr.c,v 1.60 2018/04/26 19:56:55 maxv Exp $	*/
+/*	$NetBSD: if_ieee1394subr.c,v 1.61 2018/05/07 09:51:02 maxv Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.60 2018/04/26 19:56:55 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.61 2018/05/07 09:51:02 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -442,8 +442,7 @@ ieee1394_reass(struct ifnet *ifp, struct
 	len = m0->m_pkthdr.len;
 	id = dgl | (src << 16);
 	if (ftype & IEEE1394_FT_SUBSEQ) {
-		m_tag_delete_chain(m0, NULL);
-		m0->m_flags &= ~M_PKTHDR;
+		m_remove_pkthdr(m0);
 		etype = 0;
 		off = ntohs(ifh->ifh_etype_off);
 	} else {

Index: src/sys/net/if_l2tp.c
diff -u src/sys/net/if_l2tp.c:1.25 src/sys/net/if_l2tp.c:1.26
--- src/sys/net/if_l2tp.c:1.25	Tue May  1 07:21:39 2018
+++ src/sys/net/if_l2tp.c	Mon May  7 09:51:02 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.c,v 1.25 2018/05/01 07:21:39 maxv Exp $	*/
+/*	$NetBSD: if_l2tp.c,v 1.26 2018/05/07 09:51:02 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.25 2018/05/01 07:21:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.26 2018/05/07 09:51:02 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -534,8 +534,7 @@ l2tp_input(struct mbuf *m, struct ifnet 
 			 * Already copied mtag with M_COPY_PKTHDR.
 			 * but don't delete mtag in case cut off M_PKTHDR flag
 			 */
-			m_tag_delete_chain(m, NULL);
-			m->m_flags &= ~M_PKTHDR;
+			m_remove_pkthdr(m);
 			m_head->m_next = m;
 		}
 



CVS commit: src/sys/dev/marvell

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 09:41:10 UTC 2018

Modified Files:
src/sys/dev/marvell: mvxpbm.c

Log Message:
Fix double-free, m_tag_delete_chain is already called by m_free.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/marvell/mvxpbm.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/marvell/mvxpbm.c
diff -u src/sys/dev/marvell/mvxpbm.c:1.1 src/sys/dev/marvell/mvxpbm.c:1.2
--- src/sys/dev/marvell/mvxpbm.c:1.1	Wed Jun  3 03:55:47 2015
+++ src/sys/dev/marvell/mvxpbm.c	Mon May  7 09:41:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mvxpbm.c,v 1.1 2015/06/03 03:55:47 hsuenaga Exp $	*/
+/*	$NetBSD: mvxpbm.c,v 1.2 2018/05/07 09:41:10 maxv Exp $	*/
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
  * All rights reserved.
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mvxpbm.c,v 1.1 2015/06/03 03:55:47 hsuenaga Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvxpbm.c,v 1.2 2018/05/07 09:41:10 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -322,8 +322,7 @@ mvxpbm_free_mbuf(struct mbuf *m, void *b
 	KASSERT(arg != NULL);
 
 	DPRINTFN(3, "free packet %p\n", m);
-	if (m->m_flags & M_PKTHDR)
-		m_tag_delete_chain((m), NULL);
+
 	chunk->m = NULL;
 	s = splvm();
 	pool_cache_put(mb_cache, m);



CVS commit: src/sys/netipsec

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 09:33:51 UTC 2018

Modified Files:
src/sys/netipsec: ipsec_output.c xform_ipip.c

Log Message:
Remove a dummy reference to XF_IP4, explain briefly why we don't use
ipe4_xformsw, and remove unused includes.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/netipsec/ipsec_output.c
cvs rdiff -u -r1.73 -r1.74 src/sys/netipsec/xform_ipip.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/netipsec/ipsec_output.c
diff -u src/sys/netipsec/ipsec_output.c:1.77 src/sys/netipsec/ipsec_output.c:1.78
--- src/sys/netipsec/ipsec_output.c:1.77	Mon May  7 09:25:04 2018
+++ src/sys/netipsec/ipsec_output.c	Mon May  7 09:33:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_output.c,v 1.77 2018/05/07 09:25:04 maxv Exp $	*/
+/*	$NetBSD: ipsec_output.c,v 1.78 2018/05/07 09:33:51 maxv Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.77 2018/05/07 09:25:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.78 2018/05/07 09:33:51 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -534,10 +534,6 @@ noneed:
 	/* Do the appropriate encapsulation, if necessary */
 	if (isr->saidx.mode == IPSEC_MODE_TUNNEL || /* Tunnel requ'd */
 	dst->sa.sa_family != AF_INET ||	/* PF mismatch */
-#if 0
-	(sav->flags & SADB_X_SAFLAGS_TUNNEL) || /* Tunnel requ'd */
-	sav->tdb_xform->xf_type == XF_IP4 ||/* ditto */
-#endif
 	(dst->sa.sa_family == AF_INET &&	/* Proxy */
 	 dst->sin.sin_addr.s_addr != INADDR_ANY &&
 	 dst->sin.sin_addr.s_addr != ip->ip_dst.s_addr)) {

Index: src/sys/netipsec/xform_ipip.c
diff -u src/sys/netipsec/xform_ipip.c:1.73 src/sys/netipsec/xform_ipip.c:1.74
--- src/sys/netipsec/xform_ipip.c:1.73	Mon May  7 09:25:04 2018
+++ src/sys/netipsec/xform_ipip.c	Mon May  7 09:33:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ipip.c,v 1.73 2018/05/07 09:25:04 maxv Exp $	*/
+/*	$NetBSD: xform_ipip.c,v 1.74 2018/05/07 09:33:51 maxv Exp $	*/
 /*	$FreeBSD: xform_ipip.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ipip.c,v 1.25 2002/06/10 18:04:55 itojun Exp $ */
 
@@ -39,26 +39,27 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.73 2018/05/07 09:25:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.74 2018/05/07 09:33:51 maxv Exp $");
 
-/*
- * IP-inside-IP processing
- */
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
 #endif
 
+/*
+ * IP-inside-IP processing.
+ *
+ * The input point is encapsw{4,6}, called via the encap callback. The
+ * output point is ipip_output, called directly. XF_IP4 has no more
+ * meaning here, ipe4_xformsw is dummy.
+ */
+
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
-#include 
 
 #include 
-#include 
-#include 
 
 #include 
 #include 



CVS commit: src/sys/netipsec

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 09:25:04 UTC 2018

Modified Files:
src/sys/netipsec: ipsec_output.c xform.h xform_ipip.c

Log Message:
Remove now unused 'isr', 'skip' and 'protoff' arguments from ipip_output.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/netipsec/ipsec_output.c
cvs rdiff -u -r1.18 -r1.19 src/sys/netipsec/xform.h
cvs rdiff -u -r1.72 -r1.73 src/sys/netipsec/xform_ipip.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/netipsec/ipsec_output.c
diff -u src/sys/netipsec/ipsec_output.c:1.76 src/sys/netipsec/ipsec_output.c:1.77
--- src/sys/netipsec/ipsec_output.c:1.76	Mon May  7 09:16:46 2018
+++ src/sys/netipsec/ipsec_output.c	Mon May  7 09:25:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_output.c,v 1.76 2018/05/07 09:16:46 maxv Exp $	*/
+/*	$NetBSD: ipsec_output.c,v 1.77 2018/05/07 09:25:04 maxv Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.76 2018/05/07 09:16:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.77 2018/05/07 09:25:04 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -550,7 +550,7 @@ noneed:
 		ip->ip_sum = in_cksum(m, ip->ip_hl << 2);
 
 		/* Encapsulate the packet */
-		error = ipip_output(m, isr, sav, , 0, 0);
+		error = ipip_output(m, sav, );
 		if (mp == NULL && !error) {
 			/* Should never happen. */
 			IPSECLOG(LOG_DEBUG,
@@ -763,7 +763,7 @@ ipsec6_process_packet(struct mbuf *m, co
 		ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6));
 
 		/* Encapsulate the packet */
-		error = ipip_output(m, isr, sav, , 0, 0);
+		error = ipip_output(m, sav, );
 		if (mp == NULL && !error) {
 			/* Should never happen. */
 			IPSECLOG(LOG_DEBUG,

Index: src/sys/netipsec/xform.h
diff -u src/sys/netipsec/xform.h:1.18 src/sys/netipsec/xform.h:1.19
--- src/sys/netipsec/xform.h:1.18	Mon May  7 09:16:46 2018
+++ src/sys/netipsec/xform.h	Mon May  7 09:25:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform.h,v 1.18 2018/05/07 09:16:46 maxv Exp $	*/
+/*	$NetBSD: xform.h,v 1.19 2018/05/07 09:25:04 maxv Exp $	*/
 /*	$FreeBSD: xform.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ipsp.h,v 1.119 2002/03/14 01:27:11 millert Exp $	*/
 /*
@@ -90,8 +90,7 @@ int xform_init(struct secasvar *sav, int
 struct cryptoini;
 
 /* XF_IP4 */
-int ipip_output(struct mbuf *, const struct ipsecrequest *, struct secasvar *,
-struct mbuf **, int, int);
+int ipip_output(struct mbuf *, struct secasvar *, struct mbuf **);
 
 /* XF_AH */
 int ah_init0(struct secasvar *, const struct xformsw *, struct cryptoini *);

Index: src/sys/netipsec/xform_ipip.c
diff -u src/sys/netipsec/xform_ipip.c:1.72 src/sys/netipsec/xform_ipip.c:1.73
--- src/sys/netipsec/xform_ipip.c:1.72	Mon May  7 09:16:46 2018
+++ src/sys/netipsec/xform_ipip.c	Mon May  7 09:25:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ipip.c,v 1.72 2018/05/07 09:16:46 maxv Exp $	*/
+/*	$NetBSD: xform_ipip.c,v 1.73 2018/05/07 09:25:04 maxv Exp $	*/
 /*	$FreeBSD: xform_ipip.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ipip.c,v 1.25 2002/06/10 18:04:55 itojun Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.72 2018/05/07 09:16:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.73 2018/05/07 09:25:04 maxv Exp $");
 
 /*
  * IP-inside-IP processing
@@ -316,8 +316,7 @@ _ipip_input(struct mbuf *m, int iphlen)
 }
 
 int
-ipip_output(struct mbuf *m, const struct ipsecrequest *isr,
-struct secasvar *sav, struct mbuf **mp, int skip, int protoff)
+ipip_output(struct mbuf *m, struct secasvar *sav, struct mbuf **mp)
 {
 	char buf[IPSEC_ADDRSTRLEN];
 	uint8_t tp, otos;



CVS commit: src/sys/netipsec

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 09:16:46 UTC 2018

Modified Files:
src/sys/netipsec: ipsec_output.c xform.h xform_ah.c xform_esp.c
xform_ipcomp.c xform_ipip.c xform_tcp.c

Log Message:
Remove unused 'mp' argument from all the xf_output functions. Also clean
up xform.h a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/netipsec/ipsec_output.c
cvs rdiff -u -r1.17 -r1.18 src/sys/netipsec/xform.h
cvs rdiff -u -r1.97 -r1.98 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.85 -r1.86 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.64 -r1.65 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.71 -r1.72 src/sys/netipsec/xform_ipip.c
cvs rdiff -u -r1.18 -r1.19 src/sys/netipsec/xform_tcp.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/netipsec/ipsec_output.c
diff -u src/sys/netipsec/ipsec_output.c:1.75 src/sys/netipsec/ipsec_output.c:1.76
--- src/sys/netipsec/ipsec_output.c:1.75	Tue May  1 05:42:26 2018
+++ src/sys/netipsec/ipsec_output.c	Mon May  7 09:16:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec_output.c,v 1.75 2018/05/01 05:42:26 maxv Exp $	*/
+/*	$NetBSD: ipsec_output.c,v 1.76 2018/05/07 09:16:46 maxv Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.75 2018/05/01 05:42:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_output.c,v 1.76 2018/05/07 09:16:46 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -604,7 +604,7 @@ noneed:
 			i = sizeof(struct ip6_hdr);
 			off = offsetof(struct ip6_hdr, ip6_nxt);
 		}
-		error = (*sav->tdb_xform->xf_output)(m, isr, sav, NULL, i, off);
+		error = (*sav->tdb_xform->xf_output)(m, isr, sav, i, off);
 	} else {
 		error = ipsec_process_done(m, isr, sav);
 	}
@@ -794,7 +794,7 @@ ipsec6_process_packet(struct mbuf *m, co
 		if (error)
 			goto unrefsav;
 	}
-	error = (*sav->tdb_xform->xf_output)(m, isr, sav, NULL, i, off);
+	error = (*sav->tdb_xform->xf_output)(m, isr, sav, i, off);
 	KEY_SA_UNREF();
 	splx(s);
 	return error;

Index: src/sys/netipsec/xform.h
diff -u src/sys/netipsec/xform.h:1.17 src/sys/netipsec/xform.h:1.18
--- src/sys/netipsec/xform.h:1.17	Mon May  7 09:08:06 2018
+++ src/sys/netipsec/xform.h	Mon May  7 09:16:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform.h,v 1.17 2018/05/07 09:08:06 maxv Exp $	*/
+/*	$NetBSD: xform.h,v 1.18 2018/05/07 09:16:46 maxv Exp $	*/
 /*	$FreeBSD: xform.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ipsp.h,v 1.119 2002/03/14 01:27:11 millert Exp $	*/
 /*
@@ -64,30 +64,28 @@ struct tdb_crypto {
 struct ipescrequest;
 
 struct xformsw {
-	u_short	xf_type;		/* xform ID */
+	u_short xf_type;
 #define	XF_IP4		1	/* IP inside IP */
 #define	XF_AH		2	/* AH */
 #define	XF_ESP		3	/* ESP */
 #define	XF_TCPSIGNATURE	5	/* TCP MD5 Signature option, RFC 2358 */
 #define	XF_IPCOMP	6	/* IPCOMP */
-	u_short	xf_flags;
+	u_short xf_flags;
 #define	XFT_AUTH	0x0001
 #define	XFT_CONF	0x0100
 #define	XFT_COMP	0x1000
-	const char	*xf_name;		/* human-readable name */
-	int	(*xf_init)(struct secasvar*, const struct xformsw*);/* setup */
-	int	(*xf_zeroize)(struct secasvar*);		/* cleanup */
-	int	(*xf_input)(struct mbuf*, struct secasvar*, /* input */
-			int, int);
-	int	(*xf_output)(struct mbuf*,	   		/* output */
-			const struct ipsecrequest *, struct secasvar *,
-			struct mbuf **, int, int);
-	struct xformsw *xf_next;		/* list of registered xforms */
+	const char *xf_name;
+	int (*xf_init)(struct secasvar *, const struct xformsw *);
+	int (*xf_zeroize)(struct secasvar *);
+	int (*xf_input)(struct mbuf *, struct secasvar *, int, int);
+	int (*xf_output)(struct mbuf *, const struct ipsecrequest *,
+	struct secasvar *, int, int);
+	struct xformsw *xf_next;	/* list of registered xforms */
 };
 
 #ifdef _KERNEL
-extern void xform_register(struct xformsw*);
-extern int xform_init(struct secasvar *sav, int xftype);
+void xform_register(struct xformsw *);
+int xform_init(struct secasvar *sav, int);
 
 struct cryptoini;
 
@@ -97,16 +95,16 @@ int ipip_output(struct mbuf *, const str
 
 /* XF_AH */
 int ah_init0(struct secasvar *, const struct xformsw *, struct cryptoini *);
-int ah_zeroize(struct secasvar *sav);
-const struct auth_hash *ah_algorithm_lookup(int alg);
+int ah_zeroize(struct secasvar *);
+const struct auth_hash *ah_algorithm_lookup(int);
 size_t ah_hdrsiz(const struct secasvar *);
 
 /* XF_ESP */
-const struct enc_xform *esp_algorithm_lookup(int alg);
-size_t esp_hdrsiz(const struct secasvar *sav);
+const struct enc_xform *esp_algorithm_lookup(int);
+size_t esp_hdrsiz(const struct secasvar *);
 
 /* XF_COMP */
-const struct comp_algo *ipcomp_algorithm_lookup(int alg);
+const struct comp_algo *ipcomp_algorithm_lookup(int);
 
 #endif /* _KERNEL */
 #endif /* !_NETIPSEC_XFORM_H_ */

Index: src/sys/netipsec/xform_ah.c
diff -u 

CVS commit: src/sys/netipsec

2018-05-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon May  7 09:08:06 UTC 2018

Modified Files:
src/sys/netipsec: xform.h xform_ipip.c

Log Message:
Clarify IPIP: ipe4_xformsw is not allowed to call ipip_output, so replace
the pointer by ipe4_output, which just panics. Group the ipe4_* functions
together. Localify other functions.

ok ozaki-r@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/netipsec/xform.h
cvs rdiff -u -r1.70 -r1.71 src/sys/netipsec/xform_ipip.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/netipsec/xform.h
diff -u src/sys/netipsec/xform.h:1.16 src/sys/netipsec/xform.h:1.17
--- src/sys/netipsec/xform.h:1.16	Tue May  1 08:08:46 2018
+++ src/sys/netipsec/xform.h	Mon May  7 09:08:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform.h,v 1.16 2018/05/01 08:08:46 maxv Exp $	*/
+/*	$NetBSD: xform.h,v 1.17 2018/05/07 09:08:06 maxv Exp $	*/
 /*	$FreeBSD: xform.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ipsp.h,v 1.119 2002/03/14 01:27:11 millert Exp $	*/
 /*
@@ -92,8 +92,6 @@ extern int xform_init(struct secasvar *s
 struct cryptoini;
 
 /* XF_IP4 */
-int ip4_input6(struct mbuf **m, int *offp, int proto, void *);
-void ip4_input(struct mbuf *m, int, int, void *);
 int ipip_output(struct mbuf *, const struct ipsecrequest *, struct secasvar *,
 struct mbuf **, int, int);
 

Index: src/sys/netipsec/xform_ipip.c
diff -u src/sys/netipsec/xform_ipip.c:1.70 src/sys/netipsec/xform_ipip.c:1.71
--- src/sys/netipsec/xform_ipip.c:1.70	Sun Apr 29 14:35:35 2018
+++ src/sys/netipsec/xform_ipip.c	Mon May  7 09:08:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ipip.c,v 1.70 2018/04/29 14:35:35 maxv Exp $	*/
+/*	$NetBSD: xform_ipip.c,v 1.71 2018/05/07 09:08:06 maxv Exp $	*/
 /*	$FreeBSD: xform_ipip.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ipip.c,v 1.25 2002/06/10 18:04:55 itojun Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.70 2018/04/29 14:35:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ipip.c,v 1.71 2018/05/07 09:08:06 maxv Exp $");
 
 /*
  * IP-inside-IP processing
@@ -90,12 +90,10 @@ __KERNEL_RCSID(0, "$NetBSD: xform_ipip.c
 int ipip_spoofcheck = 1;
 percpu_t *ipipstat_percpu;
 
-void ipe4_attach(void);
-
 static void _ipip_input(struct mbuf *, int);
 
 #ifdef INET6
-int
+static int
 ip4_input6(struct mbuf **m, int *offp, int proto, void *eparg __unused)
 {
 	_ipip_input(*m, *offp);
@@ -104,7 +102,7 @@ ip4_input6(struct mbuf **m, int *offp, i
 #endif
 
 #ifdef INET
-void
+static void
 ip4_input(struct mbuf *m, int off, int proto, void *eparg __unused)
 {
 	_ipip_input(m, off);
@@ -517,6 +515,40 @@ bad:
 	return error;
 }
 
+#ifdef INET
+static struct encapsw ipe4_encapsw = {
+	.encapsw4 = {
+		.pr_input = ip4_input,
+		.pr_ctlinput = NULL,
+	}
+};
+#endif
+#ifdef INET6
+static struct encapsw ipe4_encapsw6 = {
+	.encapsw6 = {
+		.pr_input = ip4_input6,
+		.pr_ctlinput = NULL,
+	}
+};
+#endif
+
+/*
+ * Check the encapsulated packet to see if we want it
+ */
+static int
+ipe4_encapcheck(struct mbuf *m, int off, int proto, void *arg)
+{
+	/*
+	 * Only take packets coming from IPSEC tunnels; the rest
+	 * must be handled by the gif tunnel code.  Note that we
+	 * also return a minimum priority when we want the packet
+	 * so any explicit gif tunnels take precedence.
+	 */
+	return ((m->m_flags & M_IPSEC) != 0 ? 1 : 0);
+}
+
+/* -- */
+
 static int
 ipe4_init(struct secasvar *sav, const struct xformsw *xsp)
 {
@@ -541,6 +573,13 @@ ipe4_input(struct mbuf *m, struct secasv
 	return EOPNOTSUPP;
 }
 
+static int
+ipe4_output(struct mbuf *m, const struct ipsecrequest *isr,
+struct secasvar *sav, struct mbuf **mp, int skip, int protoff)
+{
+	panic("%s: should not have been called", __func__);
+}
+
 static struct xformsw ipe4_xformsw = {
 	.xf_type	= XF_IP4,
 	.xf_flags	= 0,
@@ -548,41 +587,11 @@ static struct xformsw ipe4_xformsw = {
 	.xf_init	= ipe4_init,
 	.xf_zeroize	= ipe4_zeroize,
 	.xf_input	= ipe4_input,
-	.xf_output	= ipip_output,
+	.xf_output	= ipe4_output,
 	.xf_next	= NULL,
 };
 
-#ifdef INET
-static struct encapsw ipe4_encapsw = {
-	.encapsw4 = {
-		.pr_input = ip4_input,
-		.pr_ctlinput = NULL,
-	}
-};
-#endif
-#ifdef INET6
-static struct encapsw ipe4_encapsw6 = {
-	.encapsw6 = {
-		.pr_input = ip4_input6,
-		.pr_ctlinput = NULL,
-	}
-};
-#endif
-
-/*
- * Check the encapsulated packet to see if we want it
- */
-static int
-ipe4_encapcheck(struct mbuf *m, int off, int proto, void *arg)
-{
-	/*
-	 * Only take packets coming from IPSEC tunnels; the rest
-	 * must be handled by the gif tunnel code.  Note that we
-	 * also return a minimum priority when we want the packet
-	 * so any explicit gif tunnels take precedence.
-	 */
-	return ((m->m_flags & M_IPSEC) != 0 ? 1 : 0);
-}
+/*