CVS commit: src/sys/netipsec

2018-05-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May 31 05:52:09 UTC 2018

Modified Files:
src/sys/netipsec: xform_esp.c

Log Message:
style


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/netipsec/xform_esp.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_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.94 src/sys/netipsec/xform_esp.c:1.95
--- src/sys/netipsec/xform_esp.c:1.94	Wed May 30 17:17:11 2018
+++ src/sys/netipsec/xform_esp.c	Thu May 31 05:52:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.94 2018/05/30 17:17:11 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.95 2018/05/31 05:52:09 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.94 2018/05/30 17:17:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.95 2018/05/31 05:52:09 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -243,7 +243,7 @@ esp_init(struct secasvar *sav, const str
 			DPRINTF(("%s: invalid key length %u, must be either of "
 "20, 28 or 36\n", __func__, keylen));
 			return EINVAL;
-}
+		}
 
 		memset(, 0, sizeof(cria));
 		cria.cri_alg = sav->tdb_authalgxform->type;
@@ -313,7 +313,7 @@ esp_input(struct mbuf *m, struct secasva
 
 	KASSERT(sav != NULL);
 	KASSERT(sav->tdb_encalgxform != NULL);
-	KASSERTMSG((skip&3) == 0 && (m->m_pkthdr.len&3) == 0,
+	KASSERTMSG((skip & 3) == 0 && (m->m_pkthdr.len & 3) == 0,
 	"misaligned packet, skip %u pkt len %u",
 	skip, m->m_pkthdr.len);
 
@@ -369,7 +369,7 @@ esp_input(struct mbuf *m, struct secasva
 	}
 
 	/* Update the counters */
-	ESP_STATADD(ESP_STAT_IBYTES, m->m_pkthdr.len - skip - hlen - alen);
+	ESP_STATADD(ESP_STAT_IBYTES, plen);
 
 	/* Get crypto descriptors */
 	crp = crypto_getreq(esph ? 2 : 1);
@@ -489,15 +489,15 @@ out:
 }
 
 #ifdef INET6
-#define	IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff) do {		 \
-	if (saidx->dst.sa.sa_family == AF_INET6) {			 \
-		error = ipsec6_common_input_cb(m, sav, skip, protoff);	 \
-	} else {			 \
-		error = ipsec4_common_input_cb(m, sav, skip, protoff);	 \
-	} \
+#define	IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff) do {		\
+	if (saidx->dst.sa.sa_family == AF_INET6) {			\
+		error = ipsec6_common_input_cb(m, sav, skip, protoff);	\
+	} else {			\
+		error = ipsec4_common_input_cb(m, sav, skip, protoff);	\
+	}\
 } while (0)
 #else
-#define	IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff)			 \
+#define	IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff)			\
 	(error = ipsec4_common_input_cb(m, sav, skip, protoff))
 #endif
 
@@ -709,15 +709,13 @@ esp_output(struct mbuf *m, const struct 
 	espx = sav->tdb_encalgxform;
 	KASSERT(espx != NULL);
 
+	/* Determine the ESP header length */
 	if (sav->flags & SADB_X_EXT_OLD)
 		hlen = sizeof(struct esp) + sav->ivlen;
 	else
 		hlen = sizeof(struct newesp) + sav->ivlen;
-
-	if (esph)
-		alen = esph->authsize;
-	else
-		alen = 0;
+	/* Authenticator hash size */
+	alen = esph ? esph->authsize : 0;
 
 	/*
 	 * NB: The null encoding transform has a blocksize of 4



CVS commit: src

2018-05-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May 31 05:27:46 UTC 2018

Modified Files:
src/distrib/sets: mkvars.mk
src/distrib/sets/lists/base: mi
src/external/atheros: Makefile
src/external/broadcom: Makefile
src/external/intel-fw-eula: Makefile
src/external/intel-fw-public: Makefile
src/external/realtek: Makefile
src/share/mk: bsd.README bsd.own.mk
src/sys/dev/microcode/ral: Makefile
src/sys/dev/microcode/rum: Makefile
src/sys/dev/microcode/run: Makefile
src/sys/dev/microcode/zyd: Makefile

Log Message:
introduce MKFIRMWARE that controls where (most) of the contents
of /libdata/firmware and /usr/libdata/firmware are not installed
if set to "no".  from the bsd.README:

MKFIRMWARE  If "no", install the /libdata/firmware directory,
which is necessary for several drivers: athn(4), bwfm(4),
ipw(4), iwi(4), iwm(4), iwn(4), otus(4), rtwn(4), urtwn(4),
wpi(4), ral(4), rum(4), run(4), zyd(4), bcm43xx(4), and
the Tegra 124 SoC.
Default: yes on amd64, cobalt, evbarm evbmips, evbppc, hpcarm,
hppa, i386, mac68k, macppc, sandpoint, and sparc64, no 
elsewhere.

convert MKRADEONFIRMWARE and MKTEGRAFIRMWARE into FOO.arch lists,
and move their defaults above the general defaults setting.

saves about 12MB in a normal installation for other platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/distrib/sets/mkvars.mk
cvs rdiff -u -r1.1176 -r1.1177 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.2 -r1.3 src/external/atheros/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/broadcom/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-eula/Makefile
cvs rdiff -u -r1.11 -r1.12 src/external/intel-fw-public/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/realtek/Makefile
cvs rdiff -u -r1.371 -r1.372 src/share/mk/bsd.README
cvs rdiff -u -r1.1061 -r1.1062 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/microcode/ral/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/microcode/rum/Makefile
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/microcode/run/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/microcode/zyd/Makefile

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/mkvars.mk
diff -u src/distrib/sets/mkvars.mk:1.34 src/distrib/sets/mkvars.mk:1.35
--- src/distrib/sets/mkvars.mk:1.34	Thu Feb  8 03:27:50 2018
+++ src/distrib/sets/mkvars.mk	Thu May 31 05:27:45 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mkvars.mk,v 1.34 2018/02/08 03:27:50 christos Exp $
+# $NetBSD: mkvars.mk,v 1.35 2018/05/31 05:27:45 mrg Exp $
 
 MKEXTRAVARS= \
 	MACHINE \
@@ -21,6 +21,7 @@ MKEXTRAVARS= \
 	MKCOMPATMODULES \
 	MKDTC \
 	MKDYNAMICROOT \
+	MKFIRMWARE \
 	MKMANPAGES \
 	MKSLJIT \
 	MKSOFTFLOAT \

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1176 src/distrib/sets/lists/base/mi:1.1177
--- src/distrib/sets/lists/base/mi:1.1176	Mon May 28 13:22:34 2018
+++ src/distrib/sets/lists/base/mi	Thu May 31 05:27:45 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1176 2018/05/28 13:22:34 christos Exp $
+# $NetBSD: mi,v 1.1177 2018/05/31 05:27:45 mrg Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -135,122 +135,122 @@
 ./libdata	base-sys-root
 ./libdata/firmwarebase-firmware-root
 ./libdata/firmware/if_athn			base-firmware-root
-./libdata/firmware/if_athn/athn-ar7010		base-firmware-root
-./libdata/firmware/if_athn/athn-ar7010-11	base-firmware-root
-./libdata/firmware/if_athn/athn-ar9271		base-firmware-root
-./libdata/firmware/if_athn/athn-license		base-firmware-root
+./libdata/firmware/if_athn/athn-ar7010		base-firmware-root	firmware
+./libdata/firmware/if_athn/athn-ar7010-11	base-firmware-root	firmware
+./libdata/firmware/if_athn/athn-ar9271		base-firmware-root	firmware
+./libdata/firmware/if_athn/athn-license		base-firmware-root	firmware
 ./libdata/firmware/if_bwfm			base-firmware-root
-./libdata/firmware/if_bwfm/LICENCE.broadcom_bcm43xx	base-firmware-root
-./libdata/firmware/if_bwfm/brcmfmac43143.bin	base-firmware-root
-./libdata/firmware/if_bwfm/brcmfmac43236b.bin	base-firmware-root
-./libdata/firmware/if_bwfm/brcmfmac43242a.bin	base-firmware-root
-./libdata/firmware/if_bwfm/brcmfmac43569.bin	base-firmware-root
-./libdata/firmware/if_bwfm/brcmfmac4350-pcie.bin	base-firmware-root
-./libdata/firmware/if_bwfm/brcmfmac4350c2-pcie.bin	base-firmware-root
-./libdata/firmware/if_bwfm/brcmfmac43602-pcie.bin	base-firmware-root
+./libdata/firmware/if_bwfm/LICENCE.broadcom_bcm43xx	base-firmware-root	firmware
+./libdata/firmware/if_bwfm/brcmfmac43143.bin	base-firmware-root	firmware
+./libdata/firmware/if_bwfm/brcmfmac43236b.bin	base-firmware-root	firmware
+./libdata/firmware/if_bwfm/brcmfmac43242a.bin	base-firmware-root	firmware

CVS commit: src/sys/arch/x86/include

2018-05-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu May 31 03:29:01 UTC 2018

Modified Files:
src/sys/arch/x86/include: specialreg.h

Log Message:
 Fix the bit location of SSBD in the macro for snprintb.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/x86/include/specialreg.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/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.125 src/sys/arch/x86/include/specialreg.h:1.126
--- src/sys/arch/x86/include/specialreg.h:1.125	Wed May 23 07:24:37 2018
+++ src/sys/arch/x86/include/specialreg.h	Thu May 31 03:29:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.125 2018/05/23 07:24:37 maxv Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.126 2018/05/31 03:29:01 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -405,9 +405,10 @@
 #define CPUID_SEF_ARCH_CAP	__BIT(29) /* IA32_ARCH_CAPABILITIES */
 #define CPUID_SEF_SSBD		__BIT(31) /* Speculative Store Bypass Disable */
 
-#define CPUID_SEF_FLAGS2	\
-	"\20" "\3" "AVX512_4VNNIW" "\4" "AVX512_4FMAPS" \
-	"\33" "IBRS" "\34" "STIBP" "\36" "ARCH_CAP" "\38" "SSBD"
+#define CPUID_SEF_FLAGS2	"\20" \
+"\3" "AVX512_4VNNIW" "\4" "AVX512_4FMAPS" \
+	"\33" "IBRS"	"\34" "STIBP"	\
+			"\36" "ARCH_CAP"		"\40" "SSBD"
 
 /*
  * CPUID Processor extended state Enumeration Fn000d



CVS commit: src/sys/dev/pci

2018-05-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu May 31 02:50:14 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
- Add some Intel 82965 devices.
- Change Intel 0x2a06 from IDE to IDER


To generate a diff of this commit:
cvs rdiff -u -r1.1337 -r1.1338 src/sys/dev/pci/pcidevs

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/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1337 src/sys/dev/pci/pcidevs:1.1338
--- src/sys/dev/pci/pcidevs:1.1337	Mon May 28 02:27:32 2018
+++ src/sys/dev/pci/pcidevs	Thu May 31 02:50:14 2018
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1337 2018/05/28 02:27:32 msaitoh Exp $
+$NetBSD: pcidevs,v 1.1338 2018/05/31 02:50:14 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -4032,10 +4032,16 @@ product INTEL 80862A01		0x2a01  80862A01
 product INTEL 82965PM_IGD	0x2a02	82965PM Integrated Graphics Device
 product INTEL 82965PM_IGD_1	0x2a03	82965PM Integrated Graphics Device
 product INTEL 82965PM_MEI	0x2a04	82965PM MEI Controller
-product INTEL 82965PM_IDE	0x2a06	82965PM IDE Interface
+product INTEL 82965PM_MEI_2	0x2a05	82965PM MEI Controller
+product INTEL 82965PM_IDE	0x2a06	82965PM IDER Interface
 product INTEL 82965PM_KT	0x2a07	82965PM/GM KT
 product INTEL 82965GME_HB	0x2a10	82965GME Host Bridge
+product INTEL 82965GME_PCIE	0x2a11	82965GME PCIe
 product INTEL 82965GME_IGD	0x2a12	82965GME Integrated Graphics Device
+product INTEL 82965GME_IGD_2	0x2a13	82965GME Integrated Graphics Device
+product INTEL 82965GME_MEI	0x2a14	82965GME MEI Controller
+product INTEL 82965GME_MEI_2	0x2a15	82965GME MEI Controller
+product INTEL 82965GME_IDER	0x2a16	82965PM IDER Interface
 product INTEL 82965GME_KT	0x2a17	82965GME KT
 product INTEL 82GM45_HB		0x2a40	82GM45 Host Bridge
 product INTEL 82GM45_PCIE	0x2a41	82GM45 PCIe



CVS commit: src/sys/dev/pci

2018-05-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu May 31 02:50:38 UTC 2018

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1328 -r1.1329 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1327 -r1.1328 src/sys/dev/pci/pcidevs_data.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/pcidevs.h
diff -u src/sys/dev/pci/pcidevs.h:1.1328 src/sys/dev/pci/pcidevs.h:1.1329
--- src/sys/dev/pci/pcidevs.h:1.1328	Mon May 28 02:28:05 2018
+++ src/sys/dev/pci/pcidevs.h	Thu May 31 02:50:37 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1328 2018/05/28 02:28:05 msaitoh Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1329 2018/05/31 02:50:37 msaitoh Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1337 2018/05/28 02:27:32 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1338 2018/05/31 02:50:14 msaitoh Exp
  */
 
 /*
@@ -4039,10 +4039,16 @@
 #define	PCI_PRODUCT_INTEL_82965PM_IGD	0x2a02		/* 82965PM Integrated Graphics Device */
 #define	PCI_PRODUCT_INTEL_82965PM_IGD_1	0x2a03		/* 82965PM Integrated Graphics Device */
 #define	PCI_PRODUCT_INTEL_82965PM_MEI	0x2a04		/* 82965PM MEI Controller */
-#define	PCI_PRODUCT_INTEL_82965PM_IDE	0x2a06		/* 82965PM IDE Interface */
+#define	PCI_PRODUCT_INTEL_82965PM_MEI_2	0x2a05		/* 82965PM MEI Controller */
+#define	PCI_PRODUCT_INTEL_82965PM_IDE	0x2a06		/* 82965PM IDER Interface */
 #define	PCI_PRODUCT_INTEL_82965PM_KT	0x2a07		/* 82965PM/GM KT */
 #define	PCI_PRODUCT_INTEL_82965GME_HB	0x2a10		/* 82965GME Host Bridge */
+#define	PCI_PRODUCT_INTEL_82965GME_PCIE	0x2a11		/* 82965GME PCIe */
 #define	PCI_PRODUCT_INTEL_82965GME_IGD	0x2a12		/* 82965GME Integrated Graphics Device */
+#define	PCI_PRODUCT_INTEL_82965GME_IGD_2	0x2a13		/* 82965GME Integrated Graphics Device */
+#define	PCI_PRODUCT_INTEL_82965GME_MEI	0x2a14		/* 82965GME MEI Controller */
+#define	PCI_PRODUCT_INTEL_82965GME_MEI_2	0x2a15		/* 82965GME MEI Controller */
+#define	PCI_PRODUCT_INTEL_82965GME_IDER	0x2a16		/* 82965PM IDER Interface */
 #define	PCI_PRODUCT_INTEL_82965GME_KT	0x2a17		/* 82965GME KT */
 #define	PCI_PRODUCT_INTEL_82GM45_HB	0x2a40		/* 82GM45 Host Bridge */
 #define	PCI_PRODUCT_INTEL_82GM45_PCIE	0x2a41		/* 82GM45 PCIe */

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1327 src/sys/dev/pci/pcidevs_data.h:1.1328
--- src/sys/dev/pci/pcidevs_data.h:1.1327	Mon May 28 02:28:05 2018
+++ src/sys/dev/pci/pcidevs_data.h	Thu May 31 02:50:37 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1327 2018/05/28 02:28:05 msaitoh Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1328 2018/05/31 02:50:37 msaitoh Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1337 2018/05/28 02:27:32 msaitoh Exp
+ *	NetBSD: pcidevs,v 1.1338 2018/05/31 02:50:14 msaitoh Exp
  */
 
 /*
@@ -6798,32 +6798,44 @@ static const uint16_t pci_products[] = {
 	22701, 692, 1716, 2427, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_MEI, 
 	22701, 21293, 6341, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_MEI_2, 
+	22701, 21293, 6341, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_IDE, 
-	22701, 6512, 3027, 0,
+	22701, 22718, 3027, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965PM_KT, 
-	22718, 21244, 0,
+	22723, 21244, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_HB, 
-	22729, 6839, 6449, 0,
+	22734, 6839, 6449, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_PCIE, 
+	22734, 18304, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_IGD, 
-	22729, 692, 1716, 2427, 0,
+	22734, 692, 1716, 2427, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_IGD_2, 
+	22734, 692, 1716, 2427, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_MEI, 
+	22734, 21293, 6341, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_MEI_2, 
+	22734, 21293, 6341, 0,
+	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_IDER, 
+	22701, 22718, 3027, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82965GME_KT, 
-	22729, 21244, 0,
+	22734, 21244, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_HB, 
-	22738, 6839, 6449, 0,
+	22743, 6839, 6449, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_PCIE, 
-	22738, 18304, 0,
+	22743, 18304, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_IGD, 
-	22738, 692, 1716, 2427, 0,
+	22743, 692, 1716, 2427, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_IGD_1, 
-	22738, 692, 1716, 2427, 0,
+	22743, 692, 1716, 2427, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_MEI_1, 
-	22738, 21293, 0,
+	22743, 21293, 0,
 	PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82GM45_MEI_2, 
-	22738, 21293, 0,
+	22743, 21293, 0,
 	PCI_VENDOR_INTEL, 

CVS commit: src/sys/net

2018-05-30 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu May 31 02:10:23 UTC 2018

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

Log Message:
Relax a lock check in if_mcast_op unless NET_MPSAFE

It seems that there remain some paths that don't satisfy the constraint that is
required only if NET_MPSAFE.  So don't check it by default.

One known path is nd6_rtrequest => in6_addmulti => if_mcast_op, which is not
easy to address.


To generate a diff of this commit:
cvs rdiff -u -r1.424 -r1.425 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.424 src/sys/net/if.c:1.425
--- src/sys/net/if.c:1.424	Thu May 24 05:27:29 2018
+++ src/sys/net/if.c	Thu May 31 02:10:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.424 2018/05/24 05:27:29 msaitoh Exp $	*/
+/*	$NetBSD: if.c,v 1.425 2018/05/31 02:10:23 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.424 2018/05/24 05:27:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.425 2018/05/31 02:10:23 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -3595,10 +3595,13 @@ if_mcast_op(ifnet_t *ifp, const unsigned
 	int rc;
 	struct ifreq ifr;
 
+	/* There remain some paths that don't hold IFNET_LOCK yet */
+#ifdef NET_MPSAFE
 	/* CARP and MROUTING still don't deal with the lock yet */
 #if (!defined(NCARP) || (NCARP == 0)) && !defined(MROUTING)
 	KASSERT(IFNET_LOCKED(ifp));
 #endif
+#endif
 	if (ifp->if_mcastop != NULL)
 		rc = (*ifp->if_mcastop)(ifp, cmd, sa);
 	else {



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

2018-05-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May 31 00:25:38 UTC 2018

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

Log Message:
Fix build with MKCATPAGES=yes

zpool-features.8 -> zpool-features.0


To generate a diff of this commit:
cvs rdiff -u -r1.1592 -r1.1593 src/distrib/sets/lists/man/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/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1592 src/distrib/sets/lists/man/mi:1.1593
--- src/distrib/sets/lists/man/mi:1.1592	Mon May 28 21:05:00 2018
+++ src/distrib/sets/lists/man/mi	Thu May 31 00:25:38 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1592 2018/05/28 21:05:00 chs Exp $
+# $NetBSD: mi,v 1.1593 2018/05/31 00:25:38 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2317,7 +2317,7 @@
 ./usr/share/man/cat7/symlink.0			man-reference-catman	.cat
 ./usr/share/man/cat7/sysctl.0			man-reference-catman	.cat
 ./usr/share/man/cat7/tests.0			man-reference-catman	.cat
-./usr/share/man/cat7/zpool-features.8		man-zfs-catman		zfs,.cat
+./usr/share/man/cat7/zpool-features.0		man-zfs-catman		zfs,.cat
 ./usr/share/man/cat8/MAKEDEV.0			man-sysutil-catman	.cat
 ./usr/share/man/cat8/MAKEDEV.local.0		man-sysutil-catman	.cat
 ./usr/share/man/cat8/ac.0			man-sysutil-catman	.cat



CVS commit: src/sys/kern

2018-05-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May 30 23:54:03 UTC 2018

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

Log Message:
Simplify comparison of two processes

No need to check p_pid to compare whether two processes are the same.

No functional change intended.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/kern/sys_ptrace_common.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/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.43 src/sys/kern/sys_ptrace_common.c:1.44
--- src/sys/kern/sys_ptrace_common.c:1.43	Tue May 29 23:34:18 2018
+++ src/sys/kern/sys_ptrace_common.c	Wed May 30 23:54:03 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.43 2018/05/29 23:34:18 kamil Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.44 2018/05/30 23:54:03 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.43 2018/05/29 23:34:18 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.44 2018/05/30 23:54:03 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -403,7 +403,7 @@ ptrace_allowed(struct lwp *l, int req, s
 		 * You can't attach to a process if:
 		 *	(1) it's the process that's doing the attaching,
 		 */
-		if (t->p_pid == p->p_pid)
+		if (t == p)
 			return EINVAL;
 
 		/*



CVS commit: src/share/man/man7

2018-05-30 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed May 30 23:41:44 UTC 2018

Modified Files:
src/share/man/man7: signal.7

Log Message:
Avoid widowed signal numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/share/man/man7/signal.7

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/man7/signal.7
diff -u src/share/man/man7/signal.7:1.24 src/share/man/man7/signal.7:1.25
--- src/share/man/man7/signal.7:1.24	Wed May 30 23:24:13 2018
+++ src/share/man/man7/signal.7	Wed May 30 23:41:44 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: signal.7,v 1.24 2018/05/30 23:24:13 uwe Exp $
+.\"	$NetBSD: signal.7,v 1.25 2018/05/30 23:41:44 uwe Exp $
 .\"
 .\" Copyright (c) 1999, 2016 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -167,7 +167,7 @@ such as
 as a cue to reload configuration.
 The number for
 .Dv SIGHUP
-is 1, which is quite well known.
+is\~1, which is quite well known.
 .\" 
 .It Dv SIGINT No (Interrupt)
 This signal is generated by the
@@ -177,7 +177,7 @@ when the user presses the interrupt char
 The default action is to terminate the process.
 The number for
 .Dv SIGINT
-is 2.
+is\~2.
 .\" 
 .It Dv SIGQUIT No (Quit)
 This signal is generated by the
@@ -187,7 +187,7 @@ when the user presses the quit character
 The default action is to terminate the process and dump core.
 The number for
 .Dv SIGQUIT
-is 3.
+is\~3.
 .\" 
 .It Dv SIGILL No (Illegal instruction)
 This signal is generated synchronously by the kernel when the process
@@ -198,7 +198,7 @@ Note: the results of executing an illega
 is blocked or ignored are formally unspecified.
 The number for
 .Dv SIGILL
-is 4.
+is\~4.
 .\" 
 .It Dv SIGTRAP No (Trace/BPT trap)
 This signal is used when a process is being traced
@@ -211,7 +211,7 @@ debuggee.
 The default action is to terminate the process and dump core.
 The number for
 .Dv SIGTRAP
-is 5.
+is\~5.
 .\" 
 .It Dv SIGABRT No (Abort trap)
 This signal is generated when the
@@ -220,7 +220,7 @@ standard library function is called.
 The default action is to terminate the process and dump core.
 The number for
 .Dv SIGABRT
-is 6.
+is\~6.
 This number was also formerly used for
 .Dv SIGIOT ,
 which is no longer defined,
@@ -235,7 +235,7 @@ emulated.
 The default action is to terminate the process and dump core.
 The number for
 .Dv SIGEMT
-is 7.
+is\~7.
 .\" 
 .It Dv SIGFPE No (Floating point exception)
 This signal is generated when an invalid floating point operation is
@@ -243,7 +243,7 @@ detected by hardware or by a soft-float 
 The default action is to terminate the process and dump core.
 The number for
 .Dv SIGFPE
-is 8.
+is\~8.
 .\" 
 .It Dv SIGKILL No (Killed)
 This signal cannot be caught or ignored.
@@ -257,7 +257,7 @@ exiting, it is usually best (as a user o
 until a process has failed to respond to other signals.
 The number for
 .Dv SIGKILL
-is 9, which is extremely well known.
+is\~9, which is extremely well known.
 .\" 
 .It Dv SIGBUS No (Bus error)
 This signal is generated synchronously by the kernel when the process
@@ -273,7 +273,7 @@ Note: the results of performing such inv
 is blocked or ignored are formally unspecified.
 The number for
 .Dv SIGBUS
-is 10.
+is\~10.
 .\" 
 .It Dv SIGSEGV No (Segmentation fault)
 This signal is generated synchronously by the kernel when the process
@@ -294,7 +294,7 @@ Note: the results of an invalid memory a
 is blocked or ignored are formally unspecified.
 The number for
 .Dv SIGSEGV
-is 11, which is very well known.
+is\~11, which is very well known.
 .\" 
 .It Dv SIGSYS No (Bad system call)
 This signal is generated by the kernel, in addition to failing with
@@ -304,7 +304,7 @@ when a system call is made using an inva
 The default action is to terminate the process and dump core.
 The number for
 .Dv SIGSYS
-is 12.
+is\~12.
 .\" 
 .It Dv SIGPIPE No (Broken pipe)
 This signal is generated by the kernel, in addition to failing with
@@ -316,7 +316,7 @@ has no readers.
 The default action is to terminate the process.
 The number for
 .Dv SIGPIPE
-is 13.
+is\~13.
 .\" 
 .It Dv SIGALRM No (Alarm clock)
 This signal is generated by the kernel when a real-time timer expires.
@@ -328,7 +328,7 @@ and
 The default action is to terminate the process.
 The number for
 .Dv SIGALRM
-is 14.
+is\~14.
 .\" 
 .It Dv SIGTERM No (Terminated)
 This signal is the default signal sent by
@@ -341,7 +341,7 @@ procedure.
 The default action is to terminate the process.
 The number for
 .Dv SIGTERM
-is 15.
+is\~15.
 .\" 
 .It Dv SIGURG No (Urgent I/O condition)
 This signal is generated when an ``urgent condition'' exists on a
@@ -352,7 +352,7 @@ out-of-band data has arrived.
 The default action is to do nothing.
 The number for
 .Dv SIGURG
-is 16.
+is\~16.
 .\" 
 .It 

CVS commit: src/share/man/man7

2018-05-30 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed May 30 23:24:13 UTC 2018

Modified Files:
src/share/man/man7: signal.7

Log Message:
Shorten pleonastic "by the tty driver tty(4)".


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/share/man/man7/signal.7

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/man7/signal.7
diff -u src/share/man/man7/signal.7:1.23 src/share/man/man7/signal.7:1.24
--- src/share/man/man7/signal.7:1.23	Mon May 28 15:48:23 2018
+++ src/share/man/man7/signal.7	Wed May 30 23:24:13 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: signal.7,v 1.23 2018/05/28 15:48:23 wiz Exp $
+.\"	$NetBSD: signal.7,v 1.24 2018/05/30 23:24:13 uwe Exp $
 .\"
 .\" Copyright (c) 1999, 2016 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -155,8 +155,9 @@ Detailed descriptions of these signals f
 .Bl -tag -width "aaa"
 .\" 
 .It Dv SIGHUP No (Hangup)
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 to indicate a hangup condition on a process's controlling terminal:
 the user has disconnected.
 Accordingly, the default action is to terminate the process.
@@ -169,8 +170,9 @@ The number for
 is 1, which is quite well known.
 .\" 
 .It Dv SIGINT No (Interrupt)
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 when the user presses the interrupt character, normally control-C.
 The default action is to terminate the process.
 The number for
@@ -178,8 +180,9 @@ The number for
 is 2.
 .\" 
 .It Dv SIGQUIT No (Quit)
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 when the user presses the quit character, normally control-backspace.
 The default action is to terminate the process and dump core.
 The number for
@@ -369,8 +372,9 @@ The number for
 is 17.
 .\" 
 .It Dv SIGTSTP No (Suspended)
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 when the user presses the stop character, normally control-Z.
 The default action is to stop the process.
 The number for
@@ -417,8 +421,9 @@ in old System V versions and today many 
 spellings.
 .\" 
 .It Dv SIGTTIN No (Stopped (tty input))
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 when a process that is not in the foreground of its controlling
 terminal attempts to read from this terminal.
 The default action is to stop the process.
@@ -427,8 +432,9 @@ The number for
 is 21.
 .\" 
 .It Dv SIGTTOU No (Stopped (tty output))
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 when a process that is not in the foreground of its controlling
 terminal attempts to write to this terminal, if the terminal is
 configured accordingly, which is not the default.
@@ -515,8 +521,9 @@ The number for
 is 27.
 .\" 
 .It Dv SIGWINCH No (Window size changed)
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 when the stored window size of the process's controlling terminal has
 changed.
 The default action is to do nothing.
@@ -525,8 +532,9 @@ The number for
 is 28.
 .\" 
 .It Dv SIGINFO No (Information request)
-This signal is generated by the tty driver
+This signal is generated by the
 .Xr tty 4
+driver
 when the user presses the status request character, normally
 control-T.
 The default action is to do nothing.



CVS commit: src/external

2018-05-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May 30 20:54:08 UTC 2018

Modified Files:
src/external/atheros/athn: Makefile
src/external/atheros/otus: Makefile
src/external/broadcom/bcm43xx: Makefile
src/external/broadcom/bwfm: Makefile
src/external/intel-fw-eula/ipw2100: Makefile
src/external/intel-fw-eula/ipw2200: Makefile
src/external/intel-fw-public/ipw3945: Makefile
src/external/intel-fw-public/iwl100: Makefile
src/external/intel-fw-public/iwl1000: Makefile
src/external/intel-fw-public/iwl105: Makefile
src/external/intel-fw-public/iwl135: Makefile
src/external/intel-fw-public/iwl2000: Makefile
src/external/intel-fw-public/iwl2030: Makefile
src/external/intel-fw-public/iwl3160: Makefile
src/external/intel-fw-public/iwl3168: Makefile
src/external/intel-fw-public/iwl4965: Makefile
src/external/intel-fw-public/iwl5000: Makefile
src/external/intel-fw-public/iwl5150: Makefile
src/external/intel-fw-public/iwl6000: Makefile
src/external/intel-fw-public/iwl6005: Makefile
src/external/intel-fw-public/iwl6030: Makefile
src/external/intel-fw-public/iwl6050: Makefile
src/external/intel-fw-public/iwl7260: Makefile
src/external/intel-fw-public/iwl7265: Makefile
src/external/intel-fw-public/iwl8000: Makefile
src/external/intel-fw-public/iwl8265: Makefile
src/external/nvidia-firmware/tegra/tegra124: Makefile
src/external/nvidia-firmware/tegra/tegra210: Makefile
src/external/realtek/rtwn: Makefile
src/external/realtek/urtwn: Makefile

Log Message:
use FIRMWAREDIR instead of hard coded /libdata/firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/atheros/athn/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/atheros/otus/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/broadcom/bcm43xx/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/broadcom/bwfm/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-eula/ipw2100/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-eula/ipw2200/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/intel-fw-public/ipw3945/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl100/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl1000/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl105/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl135/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl2000/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl2030/Makefile
cvs rdiff -u -r1.4 -r1.5 src/external/intel-fw-public/iwl3160/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl3168/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/intel-fw-public/iwl4965/Makefile
cvs rdiff -u -r1.3 -r1.4 src/external/intel-fw-public/iwl5000/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl5150/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl6000/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl6005/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl6030/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl6050/Makefile
cvs rdiff -u -r1.4 -r1.5 src/external/intel-fw-public/iwl7260/Makefile
cvs rdiff -u -r1.5 -r1.6 src/external/intel-fw-public/iwl7265/Makefile
cvs rdiff -u -r1.2 -r1.3 src/external/intel-fw-public/iwl8000/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/intel-fw-public/iwl8265/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/nvidia-firmware/tegra/tegra124/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/nvidia-firmware/tegra/tegra210/Makefile
cvs rdiff -u -r1.1 -r1.2 src/external/realtek/rtwn/Makefile
cvs rdiff -u -r1.3 -r1.4 src/external/realtek/urtwn/Makefile

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

Modified files:

Index: src/external/atheros/athn/Makefile
diff -u src/external/atheros/athn/Makefile:1.1 src/external/atheros/athn/Makefile:1.2
--- src/external/atheros/athn/Makefile:1.1	Sat Mar 30 02:47:56 2013
+++ src/external/atheros/athn/Makefile	Wed May 30 20:54:06 2018
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.1 2013/03/30 02:47:56 christos Exp $
+# $NetBSD: Makefile,v 1.2 2018/05/30 20:54:06 mrg Exp $
 
 NOMAN=	# define
 
 FILES= dist/athn-ar7010 dist/athn-ar7010-11 dist/athn-ar9271 dist/athn-license
-FILESDIR=	/libdata/firmware/if_athn
+FILESDIR=	${FIRMWAREDIR}/if_athn
 
 .include 

Index: src/external/atheros/otus/Makefile
diff -u src/external/atheros/otus/Makefile:1.1 src/external/atheros/otus/Makefile:1.2
--- src/external/atheros/otus/Makefile:1.1	Wed Nov  3 18:52:45 2010
+++ src/external/atheros/otus/Makefile	Wed May 30 20:54:06 2018
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.1 2010/11/03 18:52:45 christos Exp $
+# $NetBSD: Makefile,v 1.2 2018/05/30 20:54:06 mrg Exp $
 
 

CVS commit: src/sys/netipsec

2018-05-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 30 18:02:41 UTC 2018

Modified Files:
src/sys/netipsec: xform_ah.c

Log Message:
Correctly handle the padding for IPv6-AH, as specified by RFC4302. Seen in
a FreeBSD bug report, by Jason Mader.

The RFC specifies that under IPv6 the complete AH header must be 64bit-
aligned, and under IPv4 32bit-aligned. That's a rule we've never respected.
The other BSDs and MacOS never have either.

So respect it now.

This makes it possible to set up IPv6-AH between Linux and NetBSD, and also
probably between Windows and NetBSD.

Until now all the tests I made were between two *BSD hosts, and everything
worked "correctly" since both hosts were speaking the same non-standard
AHv6, so they could understand each other.

Tested with Fedora<->NetBSD, hmac-sha2-384.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/netipsec/xform_ah.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_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.104 src/sys/netipsec/xform_ah.c:1.105
--- src/sys/netipsec/xform_ah.c:1.104	Wed May 30 17:17:11 2018
+++ src/sys/netipsec/xform_ah.c	Wed May 30 18:02:40 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.104 2018/05/30 17:17:11 maxv Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.105 2018/05/30 18:02:40 maxv Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.104 2018/05/30 17:17:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.105 2018/05/30 18:02:40 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -167,11 +167,21 @@ ah_hdrsiz(const struct secasvar *sav)
 	size_t size;
 
 	if (sav != NULL) {
-		int authsize;
+		int authsize, rplen, align;
+
 		KASSERT(sav->tdb_authalgxform != NULL);
 		/*XXX not right for null algorithm--does it matter??*/
+
+		/* RFC4302: use the correct alignment. */
+		align = sizeof(uint32_t);
+#ifdef INET6
+		if (sav->sah->saidx.dst.sa.sa_family == AF_INET6) {
+			align = sizeof(uint64_t);
+		}
+#endif
+		rplen = HDRSIZE(sav);
 		authsize = AUTHSIZE(sav);
-		size = roundup(authsize, sizeof(uint32_t)) + HDRSIZE(sav);
+		size = roundup(rplen + authsize, align);
 	} else {
 		/* default guess */
 		size = sizeof(struct ah) + sizeof(uint32_t) + ah_max_authsize;
@@ -520,7 +530,7 @@ ah_input(struct mbuf *m, struct secasvar
 	const struct auth_hash *ahx;
 	struct tdb_crypto *tc = NULL;
 	struct newah *ah;
-	int hl, rplen, authsize, error, stat = AH_STAT_HDROPS;
+	int hl, rplen, authsize, ahsize, error, stat = AH_STAT_HDROPS;
 	struct cryptodesc *crda;
 	struct cryptop *crp = NULL;
 	bool pool_used;
@@ -553,25 +563,26 @@ ah_input(struct mbuf *m, struct secasvar
 	}
 
 	/* Verify AH header length. */
-	hl = ah->ah_len * sizeof(uint32_t);
+	hl = sizeof(struct ah) + (ah->ah_len * sizeof(uint32_t));
 	ahx = sav->tdb_authalgxform;
 	authsize = AUTHSIZE(sav);
-	if (hl != authsize + rplen - sizeof(struct ah)) {
+	ahsize = ah_hdrsiz(sav);
+	if (hl != ahsize) {
 		char buf[IPSEC_ADDRSTRLEN];
 		DPRINTF(("%s: bad authenticator length %u (expecting %lu)"
 			" for packet in SA %s/%08lx\n", __func__,
-			hl, (u_long) (authsize + rplen - sizeof(struct ah)),
+			hl, (u_long)ahsize,
 			ipsec_address(>sah->saidx.dst, buf, sizeof(buf)),
 			(u_long) ntohl(sav->spi)));
 		stat = AH_STAT_BADAUTHL;
 		error = EACCES;
 		goto bad;
 	}
-	if (skip + authsize + rplen > m->m_pkthdr.len) {
+	if (skip + ahsize > m->m_pkthdr.len) {
 		char buf[IPSEC_ADDRSTRLEN];
 		DPRINTF(("%s: bad mbuf length %u (expecting >= %lu)"
 			" for packet in SA %s/%08lx\n", __func__,
-			m->m_pkthdr.len, (u_long)(skip + authsize + rplen),
+			m->m_pkthdr.len, (u_long)(skip + ahsize),
 			ipsec_address(>sah->saidx.dst, buf, sizeof(buf)),
 			(u_long) ntohl(sav->spi)));
 		stat = AH_STAT_BADAUTHL;
@@ -720,7 +731,7 @@ static int
 ah_input_cb(struct cryptop *crp)
 {
 	char buf[IPSEC_ADDRSTRLEN];
-	int rplen, error, skip, protoff;
+	int rplen, ahsize, error, skip, protoff;
 	unsigned char calc[AH_ALEN_MAX];
 	struct mbuf *m;
 	struct tdb_crypto *tc;
@@ -751,6 +762,7 @@ ah_input_cb(struct cryptop *crp)
 	/* Figure out header size. */
 	rplen = HDRSIZE(sav);
 	authsize = AUTHSIZE(sav);
+	ahsize = ah_hdrsiz(sav);
 
 	size = sizeof(*tc) + skip + rplen + authsize;
 	if (__predict_true(size <= ah_pool_item_size))
@@ -844,7 +856,7 @@ ah_input_cb(struct cryptop *crp)
 	/*
 	 * Remove the AH header and authenticator from the mbuf.
 	 */
-	error = m_striphdr(m, skip, rplen + authsize);
+	error = m_striphdr(m, skip, ahsize);
 	if (error) {
 		DPRINTF(("%s: mangled mbuf chain for SA %s/%08lx\n", __func__,
 		ipsec_address(>dst, buf, sizeof(buf)),
@@ -891,7 +903,7 @@ ah_output(struct mbuf *m, const struct i
 	struct mbuf *mi;
 	struct cryptop *crp;
 	

CVS commit: src/tests

2018-05-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May 30 17:48:13 UTC 2018

Modified Files:
src/tests/kernel: h_segv.c
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
Add a comment for the workaround in trigger_bus()

Explain PROT_READ|PROT_WRITE.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/kernel/h_segv.c
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/sys/t_ptrace_wait.h

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/h_segv.c
diff -u src/tests/kernel/h_segv.c:1.6 src/tests/kernel/h_segv.c:1.7
--- src/tests/kernel/h_segv.c:1.6	Wed May 30 17:31:34 2018
+++ src/tests/kernel/h_segv.c	Wed May 30 17:48:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_segv.c,v 1.6 2018/05/30 17:31:34 kamil Exp $	*/
+/*	$NetBSD: h_segv.c,v 1.7 2018/05/30 17:48:13 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: h_segv.c,v 1.6 2018/05/30 17:31:34 kamil Exp $");
+__RCSID("$NetBSD: h_segv.c,v 1.7 2018/05/30 17:48:13 kamil Exp $");
 
 #include 
 #include 
@@ -119,7 +119,12 @@ trigger_bus(void)
 	if (fp == NULL)
 		err(EXIT_FAILURE, "tmpfile");
 
-	/* Map an empty file with mmap(2) to a pointer. */
+	/*
+	 * Map an empty file with mmap(2) to a pointer.
+	 *
+	 * PROT_READ handles read-modify-write sequences emitted for
+	 * certain combinations of CPUs and compilers (e.g. Alpha AXP).
+	 */
 	p = mmap(0, 1, PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
 	if (p == MAP_FAILED)
 		err(EXIT_FAILURE, "mmap");

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.10 src/tests/lib/libc/sys/t_ptrace_wait.h:1.11
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.10	Wed May 30 17:31:34 2018
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Wed May 30 17:48:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.10 2018/05/30 17:31:34 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.11 2018/05/30 17:48:13 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -574,7 +574,12 @@ trigger_bus(void)
 	fp = tmpfile();
 	FORKEE_ASSERT_NEQ((uintptr_t)fp, (uintptr_t)NULL);
 
-	/* Map an empty file with mmap(2) to a pointer. */
+	/*
+	 * Map an empty file with mmap(2) to a pointer.
+	 *
+	 * PROT_READ handles read-modify-write sequences emitted for
+	 * certain combinations of CPUs and compilers (e.g. Alpha AXP).
+	 */
 	p = mmap(0, 1, PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
 	FORKEE_ASSERT_NEQ((uintptr_t)p, (uintptr_t)MAP_FAILED);
 



CVS commit: src/tests

2018-05-30 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed May 30 17:31:34 UTC 2018

Modified Files:
src/tests/kernel: h_segv.c
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
Make the trigger_bus() test compatible with more CPUs (at least ALPHA)

If we write a byte character into a pointer, a compiler can emit a
read-modify-write operation, especially when a CPU cannot access directly
a character wide address.

In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will
emit unexpected trap.

There are two possible workarounds for this issue:
 - write register wide memory without rmw sequence,
 - mark the region with additional protection PROT_READ

Both work for NetBSD/alpha.

Go for the latter as perhaps more safe for dump compilers emitting rmw
sequences.

Investigated by 


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/kernel/h_segv.c
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/sys/t_ptrace_wait.h

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/h_segv.c
diff -u src/tests/kernel/h_segv.c:1.5 src/tests/kernel/h_segv.c:1.6
--- src/tests/kernel/h_segv.c:1.5	Sun May 27 17:04:45 2018
+++ src/tests/kernel/h_segv.c	Wed May 30 17:31:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_segv.c,v 1.5 2018/05/27 17:04:45 kamil Exp $	*/
+/*	$NetBSD: h_segv.c,v 1.6 2018/05/30 17:31:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: h_segv.c,v 1.5 2018/05/27 17:04:45 kamil Exp $");
+__RCSID("$NetBSD: h_segv.c,v 1.6 2018/05/30 17:31:34 kamil Exp $");
 
 #include 
 #include 
@@ -120,7 +120,7 @@ trigger_bus(void)
 		err(EXIT_FAILURE, "tmpfile");
 
 	/* Map an empty file with mmap(2) to a pointer. */
-	p = mmap(0, 1, PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
+	p = mmap(0, 1, PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
 	if (p == MAP_FAILED)
 		err(EXIT_FAILURE, "mmap");
 

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.9 src/tests/lib/libc/sys/t_ptrace_wait.h:1.10
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.9	Sun May 27 17:16:39 2018
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Wed May 30 17:31:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.9 2018/05/27 17:16:39 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.10 2018/05/30 17:31:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -575,7 +575,7 @@ trigger_bus(void)
 	FORKEE_ASSERT_NEQ((uintptr_t)fp, (uintptr_t)NULL);
 
 	/* Map an empty file with mmap(2) to a pointer. */
-	p = mmap(0, 1, PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
+	p = mmap(0, 1, PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
 	FORKEE_ASSERT_NEQ((uintptr_t)p, (uintptr_t)MAP_FAILED);
 
 	/* Invalid memory access causes CPU trap, translated to SIGBUS */



CVS commit: src/sys/netipsec

2018-05-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 30 17:17:11 UTC 2018

Modified Files:
src/sys/netipsec: xform.h xform_ah.c xform_esp.c

Log Message:
Introduce ah_authsiz, which computes the length of the ICV only. Use it in
esp_hdrsiz, and clarify.

Until now we were using ah_hdrsiz, and were relying on the fact that the
size of the AH header happens to be equal to that of the ESP trailer.

Now the size of the ESP trailer is added manually. This also fixes one
branch in esp_hdrsiz: we always append an ESP trailer, so it must always
be taken into account, and not just when an ICV is here.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/netipsec/xform.h
cvs rdiff -u -r1.103 -r1.104 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.93 -r1.94 src/sys/netipsec/xform_esp.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.19 src/sys/netipsec/xform.h:1.20
--- src/sys/netipsec/xform.h:1.19	Mon May  7 09:25:04 2018
+++ src/sys/netipsec/xform.h	Wed May 30 17:17:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform.h,v 1.19 2018/05/07 09:25:04 maxv Exp $	*/
+/*	$NetBSD: xform.h,v 1.20 2018/05/30 17:17:11 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 $	*/
 /*
@@ -96,6 +96,7 @@ int ipip_output(struct mbuf *, struct se
 int ah_init0(struct secasvar *, const struct xformsw *, struct cryptoini *);
 int ah_zeroize(struct secasvar *);
 const struct auth_hash *ah_algorithm_lookup(int);
+size_t ah_authsiz(const struct secasvar *);
 size_t ah_hdrsiz(const struct secasvar *);
 
 /* XF_ESP */

Index: src/sys/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.103 src/sys/netipsec/xform_ah.c:1.104
--- src/sys/netipsec/xform_ah.c:1.103	Tue May 29 16:50:38 2018
+++ src/sys/netipsec/xform_ah.c	Wed May 30 17:17:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_ah.c,v 1.103 2018/05/29 16:50:38 maxv Exp $	*/
+/*	$NetBSD: xform_ah.c,v 1.104 2018/05/30 17:17:11 maxv Exp $	*/
 /*	$FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.103 2018/05/29 16:50:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.104 2018/05/30 17:17:11 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -149,6 +149,19 @@ ah_algorithm_lookup(int alg)
 }
 
 size_t
+ah_authsiz(const struct secasvar *sav)
+{
+	size_t size;
+
+	if (sav == NULL) {
+		return ah_max_authsize;
+	}
+
+	size = AUTHSIZE(sav);
+	return roundup(size, sizeof(uint32_t));
+}
+
+size_t
 ah_hdrsiz(const struct secasvar *sav)
 {
 	size_t size;

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.93 src/sys/netipsec/xform_esp.c:1.94
--- src/sys/netipsec/xform_esp.c:1.93	Wed May 30 16:49:38 2018
+++ src/sys/netipsec/xform_esp.c	Wed May 30 17:17:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.93 2018/05/30 16:49:38 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.94 2018/05/30 17:17:11 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.93 2018/05/30 16:49:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.94 2018/05/30 17:17:11 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -141,25 +141,34 @@ esp_hdrsiz(const struct secasvar *sav)
 	if (sav != NULL) {
 		/*XXX not right for null algorithm--does it matter??*/
 		KASSERT(sav->tdb_encalgxform != NULL);
+
+		/*
+		 *   base header size
+		 * + iv length for CBC mode
+		 * + max pad length
+		 * + sizeof(esp trailer)
+		 * + icv length (if any).
+		 */
 		if (sav->flags & SADB_X_EXT_OLD)
 			size = sizeof(struct esp);
 		else
 			size = sizeof(struct newesp);
-		size += sav->tdb_encalgxform->ivsize + 9;
+		size += sav->tdb_encalgxform->ivsize + 9 +
+		sizeof(struct esptail);
+
 		/*XXX need alg check???*/
 		if (sav->tdb_authalgxform != NULL && sav->replay)
-			size += ah_hdrsiz(sav);
+			size += ah_authsiz(sav);
 	} else {
 		/*
 		 *   base header size
 		 * + max iv length for CBC mode
 		 * + max pad length
-		 * + sizeof(pad length field)
-		 * + sizeof(next header field)
+		 * + sizeof(esp trailer)
 		 * + max icv supported.
 		 */
 		size = sizeof(struct newesp) + esp_max_ivlen + 9 +
-		ah_hdrsiz(NULL);
+		sizeof(struct esptail) + ah_authsiz(NULL);
 	}
 	return size;
 }



CVS commit: src/sys/netipsec

2018-05-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 30 16:49:38 UTC 2018

Modified Files:
src/sys/netipsec: xform_esp.c

Log Message:
Apply the previous change in esp_input too, same as esp_output.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/netipsec/xform_esp.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_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.92 src/sys/netipsec/xform_esp.c:1.93
--- src/sys/netipsec/xform_esp.c:1.92	Wed May 30 16:43:29 2018
+++ src/sys/netipsec/xform_esp.c	Wed May 30 16:49:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.92 2018/05/30 16:43:29 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.93 2018/05/30 16:49:38 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.92 2018/05/30 16:43:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.93 2018/05/30 16:49:38 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -317,6 +317,7 @@ esp_input(struct mbuf *m, struct secasva
 
 	esph = sav->tdb_authalgxform;
 	espx = sav->tdb_encalgxform;
+	KASSERT(espx != NULL);
 
 	/* Determine the ESP header length */
 	if (sav->flags & SADB_X_EXT_OLD)
@@ -362,7 +363,7 @@ esp_input(struct mbuf *m, struct secasva
 	ESP_STATADD(ESP_STAT_IBYTES, m->m_pkthdr.len - skip - hlen - alen);
 
 	/* Get crypto descriptors */
-	crp = crypto_getreq(esph && espx ? 2 : 1);
+	crp = crypto_getreq(esph ? 2 : 1);
 	if (crp == NULL) {
 		DPRINTF(("%s: failed to acquire crypto descriptors\n",
 		__func__));
@@ -396,15 +397,15 @@ esp_input(struct mbuf *m, struct secasva
 
 		/* Authentication descriptor */
 		crda->crd_skip = skip;
-		if (espx && espx->type == CRYPTO_AES_GCM_16)
+		if (espx->type == CRYPTO_AES_GCM_16)
 			crda->crd_len = hlen - sav->ivlen;
 		else
 			crda->crd_len = m->m_pkthdr.len - (skip + alen);
 		crda->crd_inject = m->m_pkthdr.len - alen;
 
 		crda->crd_alg = esph->type;
-		if (espx && (espx->type == CRYPTO_AES_GCM_16 ||
-			 espx->type == CRYPTO_AES_GMAC)) {
+		if (espx->type == CRYPTO_AES_GCM_16 ||
+		espx->type == CRYPTO_AES_GMAC) {
 			crda->crd_key = _KEYBUF(sav->key_enc);
 			crda->crd_klen = _KEYBITS(sav->key_enc);
 		} else {
@@ -454,20 +455,17 @@ esp_input(struct mbuf *m, struct secasva
 	tc->tc_sav = sav;
 
 	/* Decryption descriptor */
-	if (espx) {
-		KASSERTMSG(crde != NULL, "null esp crypto descriptor");
-		crde->crd_skip = skip + hlen;
-		if (espx->type == CRYPTO_AES_GMAC)
-			crde->crd_len = 0;
-		else
-			crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen);
-		crde->crd_inject = skip + hlen - sav->ivlen;
-
-		crde->crd_alg = espx->type;
-		crde->crd_key = _KEYBUF(sav->key_enc);
-		crde->crd_klen = _KEYBITS(sav->key_enc);
-		/* XXX Rounds ? */
-	}
+	KASSERTMSG(crde != NULL, "null esp crypto descriptor");
+	crde->crd_skip = skip + hlen;
+	if (espx->type == CRYPTO_AES_GMAC)
+		crde->crd_len = 0;
+	else
+		crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen);
+	crde->crd_inject = skip + hlen - sav->ivlen;
+	crde->crd_alg = espx->type;
+	crde->crd_key = _KEYBUF(sav->key_enc);
+	crde->crd_klen = _KEYBITS(sav->key_enc);
+	/* XXX Rounds ? */
 
 	return crypto_dispatch(crp);
 



CVS commit: src/sys/netipsec

2018-05-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 30 16:43:29 UTC 2018

Modified Files:
src/sys/netipsec: xform_esp.c

Log Message:
Remove dead code, 'espx' is never NULL and dereferenced earlier, so no need
to NULL-check all the time.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/netipsec/xform_esp.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_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.91 src/sys/netipsec/xform_esp.c:1.92
--- src/sys/netipsec/xform_esp.c:1.91	Wed May 30 16:32:26 2018
+++ src/sys/netipsec/xform_esp.c	Wed May 30 16:43:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.91 2018/05/30 16:32:26 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.92 2018/05/30 16:43:29 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.91 2018/05/30 16:32:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.92 2018/05/30 16:43:29 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -695,8 +695,7 @@ esp_output(struct mbuf *m, const struct 
 	uint8_t prot;
 	int error, maxpacketsize;
 	struct esptail *esptail;
-
-	struct cryptodesc *crde = NULL, *crda = NULL;
+	struct cryptodesc *crde, *crda;
 	struct cryptop *crp;
 
 	esph = sav->tdb_authalgxform;
@@ -844,7 +843,7 @@ esp_output(struct mbuf *m, const struct 
 	m_copyback(m, protoff, sizeof(uint8_t), );
 
 	/* Get crypto descriptors. */
-	crp = crypto_getreq(esph && espx ? 2 : 1);
+	crp = crypto_getreq(esph ? 2 : 1);
 	if (crp == NULL) {
 		DPRINTF(("%s: failed to acquire crypto descriptors\n",
 		__func__));
@@ -853,26 +852,22 @@ esp_output(struct mbuf *m, const struct 
 		goto bad;
 	}
 
-	if (espx) {
-		crde = crp->crp_desc;
-		crda = crde->crd_next;
-
-		/* Encryption descriptor. */
-		crde->crd_skip = skip + hlen;
-		if (espx->type == CRYPTO_AES_GMAC)
-			crde->crd_len = 0;
-		else
-			crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen);
-		crde->crd_flags = CRD_F_ENCRYPT;
-		crde->crd_inject = skip + hlen - sav->ivlen;
-
-		/* Encryption operation. */
-		crde->crd_alg = espx->type;
-		crde->crd_key = _KEYBUF(sav->key_enc);
-		crde->crd_klen = _KEYBITS(sav->key_enc);
-		/* XXX Rounds ? */
-	} else
-		crda = crp->crp_desc;
+	/* Get the descriptors. */
+	crde = crp->crp_desc;
+	crda = crde->crd_next;
+
+	/* Encryption descriptor. */
+	crde->crd_skip = skip + hlen;
+	if (espx->type == CRYPTO_AES_GMAC)
+		crde->crd_len = 0;
+	else
+		crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen);
+	crde->crd_flags = CRD_F_ENCRYPT;
+	crde->crd_inject = skip + hlen - sav->ivlen;
+	crde->crd_alg = espx->type;
+	crde->crd_key = _KEYBUF(sav->key_enc);
+	crde->crd_klen = _KEYBITS(sav->key_enc);
+	/* XXX Rounds ? */
 
 	/* IPsec-specific opaque crypto info. */
 	tc = pool_cache_get(esp_tdb_crypto_pool_cache, PR_NOWAIT);
@@ -922,7 +917,7 @@ esp_output(struct mbuf *m, const struct 
 	if (esph) {
 		/* Authentication descriptor. */
 		crda->crd_skip = skip;
-		if (espx && espx->type == CRYPTO_AES_GCM_16)
+		if (espx->type == CRYPTO_AES_GCM_16)
 			crda->crd_len = hlen - sav->ivlen;
 		else
 			crda->crd_len = m->m_pkthdr.len - (skip + alen);
@@ -930,8 +925,8 @@ esp_output(struct mbuf *m, const struct 
 
 		/* Authentication operation. */
 		crda->crd_alg = esph->type;
-		if (espx && (espx->type == CRYPTO_AES_GCM_16 ||
-			 espx->type == CRYPTO_AES_GMAC)) {
+		if (espx->type == CRYPTO_AES_GCM_16 ||
+		espx->type == CRYPTO_AES_GMAC) {
 			crda->crd_key = _KEYBUF(sav->key_enc);
 			crda->crd_klen = _KEYBITS(sav->key_enc);
 		} else {



CVS commit: src/sys/netipsec

2018-05-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 30 16:32:26 UTC 2018

Modified Files:
src/sys/netipsec: xform_esp.c

Log Message:
Simplify the padding computation. Until now 'padlen' contained the ESP
Trailer (two bytes), and we were doing minus two all the time.

Declare 'tlen', which contains padlen+ESP_Trailer+ICV, and use 'struct
esptail' instead of hardcoding the construction of the trailer. 'padlen'
now indicates only the length of the padding, so no need to do -2.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/netipsec/xform_esp.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_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.90 src/sys/netipsec/xform_esp.c:1.91
--- src/sys/netipsec/xform_esp.c:1.90	Wed May 30 16:15:19 2018
+++ src/sys/netipsec/xform_esp.c	Wed May 30 16:32:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.90 2018/05/30 16:15:19 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.91 2018/05/30 16:32:26 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.90 2018/05/30 16:15:19 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.91 2018/05/30 16:32:26 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -687,13 +687,14 @@ esp_output(struct mbuf *m, const struct 
 	char buf[IPSEC_ADDRSTRLEN];
 	const struct enc_xform *espx;
 	const struct auth_hash *esph;
-	int hlen, rlen, padlen, blks, alen, i, roff;
+	int hlen, rlen, tlen, padlen, blks, alen, i, roff;
 	struct mbuf *mo = NULL;
 	struct tdb_crypto *tc;
 	struct secasindex *saidx;
 	unsigned char *tail;
 	uint8_t prot;
 	int error, maxpacketsize;
+	struct esptail *esptail;
 
 	struct cryptodesc *crde = NULL, *crda = NULL;
 	struct cryptop *crp;
@@ -721,8 +722,11 @@ esp_output(struct mbuf *m, const struct 
 	/* Raw payload length. */
 	rlen = m->m_pkthdr.len - skip;
 
-	/* XXX clamp padding length a la KAME??? */
-	padlen = ((blks - ((rlen + 2) % blks)) % blks) + 2;
+	/* Encryption padding. */
+	padlen = ((blks - ((rlen + sizeof(struct esptail)) % blks)) % blks);
+
+	/* Length of what we append (tail). */
+	tlen = padlen + sizeof(struct esptail) + alen;
 
 	ESP_STATINC(ESP_STAT_OUTPUT);
 
@@ -748,12 +752,12 @@ esp_output(struct mbuf *m, const struct 
 		error = EPFNOSUPPORT;
 		goto bad;
 	}
-	if (skip + hlen + rlen + padlen + alen > maxpacketsize) {
+	if (skip + hlen + rlen + tlen > maxpacketsize) {
 		DPRINTF(("%s: packet in SA %s/%08lx got too big (len %u, "
 		"max len %u)\n", __func__,
 		ipsec_address(>dst, buf, sizeof(buf)),
 		(u_long) ntohl(sav->spi),
-		skip + hlen + rlen + padlen + alen, maxpacketsize));
+		skip + hlen + rlen + tlen, maxpacketsize));
 		ESP_STATINC(ESP_STAT_TOOBIG);
 		error = EMSGSIZE;
 		goto bad;
@@ -803,7 +807,7 @@ esp_output(struct mbuf *m, const struct 
 	/*
 	 * Grow the mbuf, we will append data at the tail.
 	 */
-	tail = m_pad(m, padlen + alen);
+	tail = m_pad(m, tlen);
 	if (tail == NULL) {
 		DPRINTF(("%s: m_pad failed for SA %s/%08lx\n", __func__,
 		ipsec_address(>dst, buf, sizeof(buf)),
@@ -818,21 +822,22 @@ esp_output(struct mbuf *m, const struct 
 	 */
 	switch (sav->flags & SADB_X_EXT_PMASK) {
 	case SADB_X_EXT_PSEQ:
-		for (i = 0; i < padlen - 2; i++)
+		for (i = 0; i < padlen; i++)
 			tail[i] = i + 1;
 		break;
 	case SADB_X_EXT_PRAND:
-		(void)cprng_fast(tail, padlen - 2);
+		(void)cprng_fast(tail, padlen);
 		break;
 	case SADB_X_EXT_PZERO:
 	default:
-		memset(tail, 0, padlen - 2);
+		memset(tail, 0, padlen);
 		break;
 	}
 
-	/* Fix padding length and Next Protocol in padding itself. */
-	tail[padlen - 2] = padlen - 2;
-	m_copydata(m, protoff, sizeof(uint8_t), tail + padlen - 1);
+	/* Build the ESP Trailer. */
+	esptail = (struct esptail *)[padlen];
+	esptail->esp_padlen = padlen;
+	m_copydata(m, protoff, sizeof(uint8_t), >esp_nxt);
 
 	/* Fix Next Protocol in IPv4/IPv6 header. */
 	prot = IPPROTO_ESP;



CVS commit: src/sys/netipsec

2018-05-30 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed May 30 16:15:19 UTC 2018

Modified Files:
src/sys/netipsec: xform_esp.c

Log Message:
Rename padding -> padlen, pad -> tail, and clarify.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/netipsec/xform_esp.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_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.89 src/sys/netipsec/xform_esp.c:1.90
--- src/sys/netipsec/xform_esp.c:1.89	Fri May 18 19:02:49 2018
+++ src/sys/netipsec/xform_esp.c	Wed May 30 16:15:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xform_esp.c,v 1.89 2018/05/18 19:02:49 maxv Exp $	*/
+/*	$NetBSD: xform_esp.c,v 1.90 2018/05/30 16:15:19 maxv Exp $	*/
 /*	$FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $	*/
 /*	$OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.89 2018/05/18 19:02:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.90 2018/05/30 16:15:19 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -687,11 +687,11 @@ esp_output(struct mbuf *m, const struct 
 	char buf[IPSEC_ADDRSTRLEN];
 	const struct enc_xform *espx;
 	const struct auth_hash *esph;
-	int hlen, rlen, padding, blks, alen, i, roff;
+	int hlen, rlen, padlen, blks, alen, i, roff;
 	struct mbuf *mo = NULL;
 	struct tdb_crypto *tc;
 	struct secasindex *saidx;
-	unsigned char *pad;
+	unsigned char *tail;
 	uint8_t prot;
 	int error, maxpacketsize;
 
@@ -699,28 +699,30 @@ esp_output(struct mbuf *m, const struct 
 	struct cryptop *crp;
 
 	esph = sav->tdb_authalgxform;
-	KASSERT(sav->tdb_encalgxform != NULL);
 	espx = sav->tdb_encalgxform;
+	KASSERT(espx != NULL);
 
 	if (sav->flags & SADB_X_EXT_OLD)
 		hlen = sizeof(struct esp) + sav->ivlen;
 	else
 		hlen = sizeof(struct newesp) + sav->ivlen;
 
-	rlen = m->m_pkthdr.len - skip;	/* Raw payload length. */
+	if (esph)
+		alen = esph->authsize;
+	else
+		alen = 0;
+
 	/*
 	 * NB: The null encoding transform has a blocksize of 4
 	 * so that headers are properly aligned.
 	 */
 	blks = espx->blocksize;		/* IV blocksize */
 
-	/* XXX clamp padding length a la KAME??? */
-	padding = ((blks - ((rlen + 2) % blks)) % blks) + 2;
+	/* Raw payload length. */
+	rlen = m->m_pkthdr.len - skip;
 
-	if (esph)
-		alen = esph->authsize;
-	else
-		alen = 0;
+	/* XXX clamp padding length a la KAME??? */
+	padlen = ((blks - ((rlen + 2) % blks)) % blks) + 2;
 
 	ESP_STATINC(ESP_STAT_OUTPUT);
 
@@ -746,12 +748,12 @@ esp_output(struct mbuf *m, const struct 
 		error = EPFNOSUPPORT;
 		goto bad;
 	}
-	if (skip + hlen + rlen + padding + alen > maxpacketsize) {
+	if (skip + hlen + rlen + padlen + alen > maxpacketsize) {
 		DPRINTF(("%s: packet in SA %s/%08lx got too big (len %u, "
 		"max len %u)\n", __func__,
 		ipsec_address(>dst, buf, sizeof(buf)),
 		(u_long) ntohl(sav->spi),
-		skip + hlen + rlen + padding + alen, maxpacketsize));
+		skip + hlen + rlen + padlen + alen, maxpacketsize));
 		ESP_STATINC(ESP_STAT_TOOBIG);
 		error = EMSGSIZE;
 		goto bad;
@@ -799,15 +801,14 @@ esp_output(struct mbuf *m, const struct 
 	}
 
 	/*
-	 * Add padding -- better to do it ourselves than use the crypto engine,
-	 * although if/when we support compression, we'd have to do that.
+	 * Grow the mbuf, we will append data at the tail.
 	 */
-	pad = m_pad(m, padding + alen);
-	if (pad == NULL) {
+	tail = m_pad(m, padlen + alen);
+	if (tail == NULL) {
 		DPRINTF(("%s: m_pad failed for SA %s/%08lx\n", __func__,
 		ipsec_address(>dst, buf, sizeof(buf)),
 		(u_long) ntohl(sav->spi)));
-		m = NULL;		/* NB: free'd by m_pad */
+		m = NULL;
 		error = ENOBUFS;
 		goto bad;
 	}
@@ -817,21 +818,21 @@ esp_output(struct mbuf *m, const struct 
 	 */
 	switch (sav->flags & SADB_X_EXT_PMASK) {
 	case SADB_X_EXT_PSEQ:
-		for (i = 0; i < padding - 2; i++)
-			pad[i] = i+1;
+		for (i = 0; i < padlen - 2; i++)
+			tail[i] = i + 1;
 		break;
 	case SADB_X_EXT_PRAND:
-		(void)cprng_fast(pad, padding - 2);
+		(void)cprng_fast(tail, padlen - 2);
 		break;
 	case SADB_X_EXT_PZERO:
 	default:
-		memset(pad, 0, padding - 2);
+		memset(tail, 0, padlen - 2);
 		break;
 	}
 
 	/* Fix padding length and Next Protocol in padding itself. */
-	pad[padding - 2] = padding - 2;
-	m_copydata(m, protoff, sizeof(uint8_t), pad + padding - 1);
+	tail[padlen - 2] = padlen - 2;
+	m_copydata(m, protoff, sizeof(uint8_t), tail + padlen - 1);
 
 	/* Fix Next Protocol in IPv4/IPv6 header. */
 	prot = IPPROTO_ESP;



CVS commit: src/sys/dev/pckbport

2018-05-30 Thread Ryo ONODERA
Module Name:src
Committed By:   ryoon
Date:   Wed May 30 13:20:39 UTC 2018

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
Remove double and trailing whitespaces


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/pckbport/synaptics.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/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.37 src/sys/dev/pckbport/synaptics.c:1.38
--- src/sys/dev/pckbport/synaptics.c:1.37	Tue May 29 11:38:24 2018
+++ src/sys/dev/pckbport/synaptics.c	Wed May 30 13:20:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.37 2018/05/29 11:38:24 ryoon Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.38 2018/05/30 13:20:39 ryoon Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.37 2018/05/29 11:38:24 ryoon Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.38 2018/05/30 13:20:39 ryoon Exp $");
 
 #include 
 #include 
@@ -451,7 +451,7 @@ pms_synaptics_enable(void *vsc)
 	enable_modes =
 	   SYNAPTICS_MODE_ABSOLUTE | SYNAPTICS_MODE_W | SYNAPTICS_MODE_RATE;
 
-	if (sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE) 
+	if (sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE)
 		enable_modes |= SYNAPTICS_MODE_EXTENDED_W;
 
 	/*
@@ -823,7 +823,7 @@ pms_sysctl_synaptics_verify(SYSCTLFN_ARG
 			return (EINVAL);
 	} else
 	if (node.sysctl_num == synaptics_button_boundary_nodenum) {
-		if (t < 0 || t < SYNAPTICS_EDGE_BOTTOM || 
+		if (t < 0 || t < SYNAPTICS_EDGE_BOTTOM ||
 		t > SYNAPTICS_EDGE_TOP)
 			return (EINVAL);
 	} else
@@ -862,7 +862,7 @@ pms_synaptics_parse(struct pms_softc *ps
 	   ((psc->packet[0] & 0x04) >> 1) +
 	   ((psc->packet[3] & 0x04) >> 2);
 	sp.sp_finger = 0;
-	if (sp.sp_w ==  SYNAPTICS_WIDTH_EXTENDED_W) {
+	if (sp.sp_w == SYNAPTICS_WIDTH_EXTENDED_W) {
 		ew_mode = psc->packet[5] >> 4;
 		switch (ew_mode)
 		{
@@ -936,7 +936,7 @@ pms_synaptics_parse(struct pms_softc *ps
 		new_buttons = 0;
 		if(sc->flags & SYN_FLAG_HAS_ONE_BUTTON_CLICKPAD) {
 			/* This is not correctly specified. Read this button press
-		 	* from L/U bit.  Emulate 3 buttons by checking the 
+		 	* from L/U bit.  Emulate 3 buttons by checking the
 		 	* coordinates of the click and returning the appropriate
 		 	* button code.  Outside the button region default to a
 		 	* left click.



CVS commit: src/sys/dev/pci/ixgbe

2018-05-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 30 09:17:17 UTC 2018

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

Log Message:
 Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.157 src/sys/dev/pci/ixgbe/ixgbe.c:1.158
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.157	Wed May 30 08:35:26 2018
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed May 30 09:17:17 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.157 2018/05/30 08:35:26 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.158 2018/05/30 09:17:17 msaitoh Exp $ */
 
 /**
 
@@ -242,6 +242,7 @@ static int  ixgbe_sysctl_rdt_handler
 static int  ixgbe_sysctl_tdt_handler(SYSCTLFN_PROTO);
 static int  ixgbe_sysctl_tdh_handler(SYSCTLFN_PROTO);
 static int  ixgbe_sysctl_eee_state(SYSCTLFN_PROTO);
+static int	ixgbe_sysctl_debug(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_wol_enable(SYSCTLFN_PROTO);
 static int	ixgbe_sysctl_wufc(SYSCTLFN_PROTO);
 
@@ -3213,6 +3214,12 @@ ixgbe_add_device_sysctls(struct adapter 
 	}
 
 	if (sysctl_createv(log, 0, , ,
+	CTLFLAG_READWRITE, CTLTYPE_INT,
+	"debug", SYSCTL_DESCR("Debug Info"),
+	ixgbe_sysctl_debug, 0, (void *)adapter, 0, CTL_CREATE, CTL_EOL) != 0)
+		aprint_error_dev(dev, "could not create sysctl\n");
+
+	if (sysctl_createv(log, 0, , ,
 	CTLFLAG_READONLY, CTLTYPE_INT,
 	"num_rx_desc", SYSCTL_DESCR("Number of rx descriptors"),
 	NULL, 0, >num_rx_desc, 0, CTL_CREATE, CTL_EOL) != 0)
@@ -5696,6 +5703,115 @@ ixgbe_sysctl_eee_state(SYSCTLFN_ARGS)
 	return (error);
 } /* ixgbe_sysctl_eee_state */
 
+#define PRINTQS(adapter, regname)	\
+	do {\
+		struct ixgbe_hw	*_hw = &(adapter)->hw;			\
+		int _i;			\
+	\
+		printf("%s: %s", device_xname((adapter)->dev), #regname); \
+		for (_i = 0; _i < (adapter)->num_queues; _i++) {	\
+			printf((_i == 0) ? "\t" : " ");			\
+			printf("%08x", IXGBE_READ_REG(_hw,		\
+IXGBE_##regname(_i)));			\
+		}			\
+		printf("\n");		\
+	} while (0)
+
+/
+ * ixgbe_print_debug_info
+ *
+ *   Called only when em_display_debug_stats is enabled.
+ *   Provides a way to take a look at important statistics
+ *   maintained by the driver and hardware.
+ /
+static void
+ixgbe_print_debug_info(struct adapter *adapter)
+{
+device_tdev = adapter->dev;
+struct ixgbe_hw *hw = >hw;
+	int table_size;
+	int i;
+
+	switch (adapter->hw.mac.type) {
+	case ixgbe_mac_X550:
+	case ixgbe_mac_X550EM_x:
+	case ixgbe_mac_X550EM_a:
+		table_size = 128;
+		break;
+	default:
+		table_size = 32;
+		break;
+	}
+	
+	device_printf(dev, "[E]RETA:\n");
+	for (i = 0; i < table_size; i++) {
+		if (i < 32)
+			printf("%02x: %08x\n", i, IXGBE_READ_REG(hw,
+IXGBE_RETA(i)));
+		else
+			printf("%02x: %08x\n", i, IXGBE_READ_REG(hw,
+IXGBE_ERETA(i - 32)));
+	}
+
+	device_printf(dev, "queue:");
+	for (i = 0; i < adapter->num_queues; i++) {
+		printf((i == 0) ? "\t" : " ");
+		printf("%8d", i);
+	}
+	printf("\n");
+	PRINTQS(adapter, RDBAL);
+	PRINTQS(adapter, RDBAH);
+	PRINTQS(adapter, RDLEN);
+	PRINTQS(adapter, SRRCTL);
+	PRINTQS(adapter, RDH);
+	PRINTQS(adapter, RDT);
+	PRINTQS(adapter, RXDCTL);
+
+	device_printf(dev, "RQSMR:");
+	for (i = 0; i < adapter->num_queues / 4; i++) {
+		printf((i == 0) ? "\t" : " ");
+		printf("%08x", IXGBE_READ_REG(hw, IXGBE_RQSMR(i)));
+	}
+	printf("\n");
+
+	device_printf(dev, "disabled_count:");
+	for (i = 0; i < adapter->num_queues; i++) {
+		printf((i == 0) ? "\t" : " ");
+		printf("%8d", adapter->queues[i].disabled_count);
+	}
+	printf("\n");
+	
+	device_printf(dev, "EIMS:\t%08x\n", IXGBE_READ_REG(hw, IXGBE_EIMS));
+	if (hw->mac.type != ixgbe_mac_82598EB) {
+		device_printf(dev, "EIMS_EX(0):\t%08x\n",
+			  IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0)));
+		device_printf(dev, "EIMS_EX(1):\t%08x\n",
+			  IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1)));
+	}
+} /* ixgbe_print_debug_info */
+
+/
+ * ixgbe_sysctl_debug
+ /
+static int
+ixgbe_sysctl_debug(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	struct adapter *adapter = (struct adapter *)node.sysctl_data;
+	interror, result = 0;
+
+	node.sysctl_data = 
+	error = sysctl_lookup(SYSCTLFN_CALL());
+
+	if (error || newp == NULL)
+		return error;
+
+	if (result == 1)
+		ixgbe_print_debug_info(adapter);
+
+	return 0;
+} /* ixgbe_sysctl_debug */
+
 

CVS commit: src/sys/dev/pci/ixgbe

2018-05-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 30 08:35:27 UTC 2018

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixv.c

Log Message:
 Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.

 This change itself doesn't fix PR#53294.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.101 -r1.102 src/sys/dev/pci/ixgbe/ixv.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/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.156 src/sys/dev/pci/ixgbe/ixgbe.c:1.157
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.156	Fri May 25 04:40:27 2018
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed May 30 08:35:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.156 2018/05/25 04:40:27 ozaki-r Exp $ */
+/* $NetBSD: ixgbe.c,v 1.157 2018/05/30 08:35:26 msaitoh Exp $ */
 
 /**
 
@@ -3794,6 +3794,7 @@ ixgbe_init_locked(struct adapter *adapte
 	struct ifnet   *ifp = adapter->ifp;
 	device_t 	dev = adapter->dev;
 	struct ixgbe_hw *hw = >hw;
+	struct ix_queue *que;
 	struct tx_ring  *txr;
 	struct rx_ring  *rxr;
 	u32		txdctl, mhadd;
@@ -3809,6 +3810,8 @@ ixgbe_init_locked(struct adapter *adapte
 	hw->adapter_stopped = FALSE;
 	ixgbe_stop_adapter(hw);
 callout_stop(>timer);
+	for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++)
+		que->disabled_count = 0;
 
 	/* XXX I moved this here from the SIOCSIFMTU case in ixgbe_ioctl(). */
 	adapter->max_frame_size =

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.101 src/sys/dev/pci/ixgbe/ixv.c:1.102
--- src/sys/dev/pci/ixgbe/ixv.c:1.101	Fri May 25 04:40:27 2018
+++ src/sys/dev/pci/ixgbe/ixv.c	Wed May 30 08:35:26 2018
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.101 2018/05/25 04:40:27 ozaki-r Exp $*/
+/*$NetBSD: ixv.c,v 1.102 2018/05/30 08:35:26 msaitoh Exp $*/
 
 /**
 
@@ -719,7 +719,7 @@ ixv_init_locked(struct adapter *adapter)
 	struct ifnet	*ifp = adapter->ifp;
 	device_t 	dev = adapter->dev;
 	struct ixgbe_hw *hw = >hw;
-	struct ix_queue	*que = adapter->queues;
+	struct ix_queue	*que;
 	int error = 0;
 	uint32_t mask;
 	int i;
@@ -729,6 +729,8 @@ ixv_init_locked(struct adapter *adapter)
 	hw->adapter_stopped = FALSE;
 	hw->mac.ops.stop_adapter(hw);
 	callout_stop(>timer);
+	for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++)
+		que->disabled_count = 0;
 
 	/* reprogram the RAR[0] in case user changed it. */
 	hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
@@ -798,7 +800,7 @@ ixv_init_locked(struct adapter *adapter)
 
 	/* Set up auto-mask */
 	mask = (1 << adapter->vector);
-	for (i = 0; i < adapter->num_queues; i++, que++)
+	for (i = 0, que = adapter->queues; i < adapter->num_queues; i++, que++)
 		mask |= (1 << que->msix);
 	IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, mask);