CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jan 19 07:58:25 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_crypto_wep.c

Log Message:
Style, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/net80211/ieee80211_crypto_wep.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/net80211/ieee80211_crypto_wep.c
diff -u src/sys/net80211/ieee80211_crypto_wep.c:1.10 src/sys/net80211/ieee80211_crypto_wep.c:1.11
--- src/sys/net80211/ieee80211_crypto_wep.c:1.10	Wed Jan 17 17:41:38 2018
+++ src/sys/net80211/ieee80211_crypto_wep.c	Fri Jan 19 07:58:25 2018
@@ -1,4 +1,6 @@
-/*-
+/*	$NetBSD: ieee80211_crypto_wep.c,v 1.11 2018/01/19 07:58:25 maxv Exp $	*/
+
+/*
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
  *
@@ -34,15 +36,15 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_wep.c,v 1.7 2005/06/10 16:11:24 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_wep.c,v 1.10 2018/01/17 17:41:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_wep.c,v 1.11 2018/01/19 07:58:25 maxv Exp $");
 #endif
 
 /*
  * IEEE 802.11 WEP crypto support.
  */
 #include 
-#include  
-#include
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -93,8 +95,7 @@ wep_attach(struct ieee80211com *ic, stru
 {
 	struct wep_ctx *ctx;
 
-	ctx = malloc(sizeof(struct wep_ctx),
-		M_DEVBUF, M_NOWAIT | M_ZERO);
+	ctx = malloc(sizeof(struct wep_ctx), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (ctx == NULL) {
 		ic->ic_stats.is_crypto_nomem++;
 		return NULL;
@@ -190,8 +191,7 @@ wep_encap(struct ieee80211_key *k, struc
  * Add MIC to the frame as needed.
  */
 static int
-wep_enmic(struct ieee80211_key *k, struct mbuf *m,
-int force)
+wep_enmic(struct ieee80211_key *k, struct mbuf *m, int force)
 {
 
 	return 1;
@@ -315,7 +315,10 @@ wep_encrypt(struct ieee80211_key *key, s
 
 	ctx->wc_ic->ic_stats.is_crypto_wep++;
 
-	/* NB: this assumes the header was pulled up */
+	/*
+	 * NB: this assumes the header was pulled up; it was done in
+	 * ieee80211_crypto_encap().
+	 */
 	memcpy(rc4key, mtod(m, u_int8_t *) + hdrlen, IEEE80211_WEP_IVLEN);
 	memcpy(rc4key + IEEE80211_WEP_IVLEN, key->wk_key, key->wk_keylen);
 
@@ -449,8 +452,10 @@ wep_decrypt(struct ieee80211_key *key, s
 	}
 	crc = ~crc;
 
-	/* Encrypt little-endian CRC32 and verify that it matches with
-	 * received ICV */
+	/*
+	 * Encrypt little-endian CRC32 and verify that it matches with
+	 * received ICV
+	 */
 	icv[0] = crc;
 	icv[1] = crc >> 8;
 	icv[2] = crc >> 16;



CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jan 19 07:57:50 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_crypto_tkip.c

Log Message:
Style, and check the return value of m_append.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/net80211/ieee80211_crypto_tkip.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/net80211/ieee80211_crypto_tkip.c
diff -u src/sys/net80211/ieee80211_crypto_tkip.c:1.13 src/sys/net80211/ieee80211_crypto_tkip.c:1.14
--- src/sys/net80211/ieee80211_crypto_tkip.c:1.13	Wed Jan 17 17:41:38 2018
+++ src/sys/net80211/ieee80211_crypto_tkip.c	Fri Jan 19 07:57:50 2018
@@ -1,4 +1,6 @@
-/*-
+/*	$NetBSD: ieee80211_crypto_tkip.c,v 1.14 2018/01/19 07:57:50 maxv Exp $	*/
+
+/*
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
  *
@@ -34,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_tkip.c,v 1.10 2005/08/08 18:46:35 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_tkip.c,v 1.13 2018/01/17 17:41:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_tkip.c,v 1.14 2018/01/19 07:57:50 maxv Exp $");
 #endif
 
 /*
@@ -45,8 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_cr
  * its license is included below.
  */
 #include 
-#include  
-#include
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -328,7 +330,7 @@ tkip_demic(struct ieee80211_key *k, stru
 
 		ic->ic_stats.is_crypto_tkipdemic++;
 
-		michael_mic(ctx, k->wk_rxmic, 
+		michael_mic(ctx, k->wk_rxmic,
 			m, hdrlen, m->m_pkthdr.len - (hdrlen + tkip.ic_miclen),
 			mic);
 		m_copydata(m, m->m_pkthdr.len - tkip.ic_miclen,
@@ -885,17 +887,21 @@ tkip_encrypt(struct tkip_ctx *ctx, struc
 		ctx->tx_phase1_done = 1;
 	}
 	tkip_mixing_phase2(ctx->tx_rc4key, key->wk_key, ctx->tx_ttak,
-		(u16) key->wk_keytsc);
+		(u16)key->wk_keytsc);
 
 	wep_encrypt(ctx->tx_rc4key,
 		m, hdrlen + tkip.ic_header,
 		m->m_pkthdr.len - (hdrlen + tkip.ic_header),
 		icv);
-	(void) m_append(m, IEEE80211_WEP_CRCLEN, icv);	/* XXX check return */
+
+	if (!m_append(m, IEEE80211_WEP_CRCLEN, icv)) {
+		return 0;
+	}
 
 	key->wk_keytsc++;
 	if ((u16)(key->wk_keytsc) == 0)
 		ctx->tx_phase1_done = 0;
+
 	return 1;
 }
 
@@ -922,9 +928,8 @@ tkip_decrypt(struct tkip_ctx *ctx, struc
 	tkip_mixing_phase2(ctx->rx_rc4key, key->wk_key, ctx->rx_ttak, iv16);
 
 	/* NB: m is unstripped; deduct headers + ICV to get payload */
-	if (wep_decrypt(ctx->rx_rc4key,
-		m, hdrlen + tkip.ic_header,
-	m->m_pkthdr.len - (hdrlen + tkip.ic_header + tkip.ic_trailer))) {
+	if (wep_decrypt(ctx->rx_rc4key, m, hdrlen + tkip.ic_header,
+	m->m_pkthdr.len - (hdrlen + tkip.ic_header + tkip.ic_trailer))) {
 		if (iv32 != (u32)(key->wk_keyrsc >> 16)) {
 			/* Previously cached Phase1 result was already lost, so
 			 * it needs to be recalculated for the next packet. */
@@ -936,6 +941,7 @@ tkip_decrypt(struct tkip_ctx *ctx, struc
 		ctx->tc_ic->ic_stats.is_rx_tkipicv++;
 		return 0;
 	}
+
 	return 1;
 }
 



CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jan 19 07:54:34 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_crypto_ccmp.c

Log Message:
Style, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/net80211/ieee80211_crypto_ccmp.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/net80211/ieee80211_crypto_ccmp.c
diff -u src/sys/net80211/ieee80211_crypto_ccmp.c:1.12 src/sys/net80211/ieee80211_crypto_ccmp.c:1.13
--- src/sys/net80211/ieee80211_crypto_ccmp.c:1.12	Wed Jan 17 17:41:38 2018
+++ src/sys/net80211/ieee80211_crypto_ccmp.c	Fri Jan 19 07:54:34 2018
@@ -1,4 +1,6 @@
-/*-
+/*	$NetBSD: ieee80211_crypto_ccmp.c,v 1.13 2018/01/19 07:54:34 maxv Exp $	*/
+
+/*
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
  *
@@ -34,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_ccmp.c,v 1.7 2005/07/11 03:06:23 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_ccmp.c,v 1.12 2018/01/17 17:41:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_ccmp.c,v 1.13 2018/01/19 07:54:34 maxv Exp $");
 #endif
 
 /*
@@ -46,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_cr
  */
 #include 
 #include 
-#include  
+#include 
 #include 
 #include 
 
@@ -64,7 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_cr
 
 struct ccmp_ctx {
 	struct ieee80211com *cc_ic;	/* for diagnostics */
-	rijndael_ctx	 cc_aes;
+	rijndael_ctx cc_aes;
 };
 
 static	void *ccmp_attach(struct ieee80211com *, struct ieee80211_key *);
@@ -102,8 +104,7 @@ ccmp_attach(struct ieee80211com *ic, str
 {
 	struct ccmp_ctx *ctx;
 
-	ctx = malloc(sizeof(struct ccmp_ctx),
-		M_DEVBUF, M_NOWAIT | M_ZERO);
+	ctx = malloc(sizeof(struct ccmp_ctx), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (ctx == NULL) {
 		ic->ic_stats.is_crypto_nomem++;
 		return NULL;
@@ -258,8 +259,7 @@ ccmp_decap(struct ieee80211_key *k, stru
  * Verify and strip MIC from the frame.
  */
 static int
-ccmp_demic(struct ieee80211_key *k, struct mbuf *m,
-int force)
+ccmp_demic(struct ieee80211_key *k, struct mbuf *m, int force)
 {
 	return 1;
 }
@@ -419,6 +419,7 @@ ccmp_encrypt(struct ieee80211_key *key, 
 	for (;;) {
 		if (space > data_len)
 			space = data_len;
+
 		/*
 		 * Do full blocks.
 		 */
@@ -430,6 +431,7 @@ ccmp_encrypt(struct ieee80211_key *key, 
 		}
 		if (data_len <= 0)		/* no more data */
 			break;
+
 		m = m->m_next;
 		if (m == NULL) {		/* last buffer */
 			if (space != 0) {
@@ -472,7 +474,7 @@ ccmp_encrypt(struct ieee80211_key *key, 
 }
 /*
  * This mbuf's contents are insufficient,
- * take 'em all and prepare to advance to
+ * take them all and prepare to advance to
  * the next mbuf.
  */
 xor_block(b+sp, pos_next, n->m_len);
@@ -501,6 +503,7 @@ ccmp_encrypt(struct ieee80211_key *key, 
 if (m == NULL)
 	goto done;
 			}
+
 			/*
 			 * Do bookkeeping.  m now points to the last mbuf
 			 * we grabbed data from.  We know we consumed a
@@ -521,6 +524,7 @@ ccmp_encrypt(struct ieee80211_key *key, 
 			space = m->m_len;
 		}
 	}
+
 done:
 	/* tack on MIC */
 	xor_block(b, s0, ccmp.ic_trailer);
@@ -540,7 +544,8 @@ done:
 } while (0)
 
 static int
-ccmp_decrypt(struct ieee80211_key *key, u_int64_t pn, struct mbuf *m, int hdrlen)
+ccmp_decrypt(struct ieee80211_key *key, u_int64_t pn, struct mbuf *m,
+int hdrlen)
 {
 	struct ccmp_ctx *ctx = key->wk_private;
 	struct ieee80211_frame *wh;
@@ -574,12 +579,14 @@ ccmp_decrypt(struct ieee80211_key *key, 
 		}
 		if (data_len <= 0)		/* no more data */
 			break;
+
 		m = m->m_next;
 		if (m == NULL) {		/* last buffer */
 			if (space != 0)		/* short last block */
 CCMP_DECRYPT(i, b, b0, pos, a, space);
 			break;
 		}
+
 		if (space != 0) {
 			uint8_t *pos_next;
 			u_int space_next;
@@ -614,6 +621,7 @@ ccmp_decrypt(struct ieee80211_key *key, 
 			space = m->m_len;
 		}
 	}
+
 	if (memcmp(mic, a, ccmp.ic_trailer) != 0) {
 		IEEE80211_DPRINTF(ctx->cc_ic, IEEE80211_MSG_CRYPTO,
 			"[%s] AES-CCM decrypt failed; MIC mismatch\n",
@@ -621,6 +629,7 @@ ccmp_decrypt(struct ieee80211_key *key, 
 		ctx->cc_ic->ic_stats.is_rx_ccmpmic++;
 		return 0;
 	}
+
 	return 1;
 }
 #undef CCMP_DECRYPT



CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jan 19 07:53:46 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_crypto_none.c

Log Message:
Style, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/net80211/ieee80211_crypto_none.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/net80211/ieee80211_crypto_none.c
diff -u src/sys/net80211/ieee80211_crypto_none.c:1.7 src/sys/net80211/ieee80211_crypto_none.c:1.8
--- src/sys/net80211/ieee80211_crypto_none.c:1.7	Thu Nov 16 01:33:40 2006
+++ src/sys/net80211/ieee80211_crypto_none.c	Fri Jan 19 07:53:46 2018
@@ -1,4 +1,6 @@
-/*-
+/*	$NetBSD: ieee80211_crypto_none.c,v 1.8 2018/01/19 07:53:46 maxv Exp $	*/
+
+/*
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
  *
@@ -34,15 +36,15 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_none.c,v 1.5 2005/06/10 16:11:24 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_none.c,v 1.7 2006/11/16 01:33:40 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_none.c,v 1.8 2018/01/19 07:53:46 maxv Exp $");
 #endif
 
 /*
  * IEEE 802.11 NULL crypto support.
  */
 #include 
-#include  
-#include
+#include 
+#include 
 
 #include 
 



CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jan 19 07:52:37 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_crypto.c

Log Message:
Style, and make sure that there is a header+trailer included in the
packet. The crypto functions can touch the trailer, but they don't check
whether it's there in the first place.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/net80211/ieee80211_crypto.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/net80211/ieee80211_crypto.c
diff -u src/sys/net80211/ieee80211_crypto.c:1.20 src/sys/net80211/ieee80211_crypto.c:1.21
--- src/sys/net80211/ieee80211_crypto.c:1.20	Wed Jan 17 17:41:38 2018
+++ src/sys/net80211/ieee80211_crypto.c	Fri Jan 19 07:52:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_crypto.c,v 1.20 2018/01/17 17:41:38 maxv Exp $	*/
+/*	$NetBSD: ieee80211_crypto.c,v 1.21 2018/01/19 07:52:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2001 Atsushi Onoe
@@ -37,7 +37,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto.c,v 1.12 2005/08/08 18:46:35 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto.c,v 1.20 2018/01/17 17:41:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto.c,v 1.21 2018/01/19 07:52:37 maxv Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_cr
  * IEEE 802.11 generic crypto support.
  */
 #include 
-#include
+#include 
 
 #include 
 #include 
@@ -72,7 +72,7 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_cr
 static const struct ieee80211_cipher *ciphers[IEEE80211_CIPHER_MAX];
 
 #ifdef INET
-#include  
+#include 
 #include 
 #endif
 
@@ -136,7 +136,7 @@ cipher_detach(struct ieee80211_key *key)
 	key->wk_cipher->ic_detach(key);
 }
 
-/* 
+/*
  * Wrappers for driver key management methods.
  */
 static __inline int
@@ -605,7 +605,12 @@ ieee80211_crypto_decap(struct ieee80211c
 	struct mbuf *m = *mp;
 	u_int8_t keyid;
 
-	/* NB: this minimum size data frame could be bigger */
+	KASSERT((m->m_flags & M_PKTHDR) != 0);
+
+	/*
+	 * This minimum size data frame could be bigger. It is re-checked
+	 * below.
+	 */
 	if (m->m_pkthdr.len < IEEE80211_WEP_MINLEN) {
 		IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
 			"%s: WEP data frame too short, len %u\n",
@@ -646,5 +651,16 @@ ieee80211_crypto_decap(struct ieee80211c
 		return NULL;
 	}
 
+	/*
+	 * Ensure there is a header+trailer included.
+	 */
+	if (m->m_pkthdr.len < hdrlen + cip->ic_header + cip->ic_trailer) {
+		IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
+			"%s: WEP data frame too short, len %u\n",
+			__func__, m->m_pkthdr.len);
+		ic->ic_stats.is_rx_tooshort++;
+		return NULL;
+	}
+
 	return (cip->ic_decap(k, m, hdrlen) ? k : NULL);
 }



CVS commit: src/sys/netinet

2018-01-18 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Jan 19 07:53:01 UTC 2018

Modified Files:
src/sys/netinet: tcp_subr.c tcp_timer.c tcp_timer.h tcp_var.h

Log Message:
Run tcp_slowtimo in workqueue if NET_MPSAFE

If NET_MPSAFE is enabled, we have to avoid taking softnet_lock in softint as
much as possible to prevent any softint handlers including callout handlers
such as tcp_slowtimo from sticking on softnet_lock because it results in
undesired delays of executing subsequent softint handlers.

NFCI for !NET_MPSAFE


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.92 -r1.93 src/sys/netinet/tcp_timer.c
cvs rdiff -u -r1.28 -r1.29 src/sys/netinet/tcp_timer.h
cvs rdiff -u -r1.181 -r1.182 src/sys/netinet/tcp_var.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/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.271 src/sys/netinet/tcp_subr.c:1.272
--- src/sys/netinet/tcp_subr.c:1.271	Sat Jul 29 05:08:48 2017
+++ src/sys/netinet/tcp_subr.c	Fri Jan 19 07:53:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.271 2017/07/29 05:08:48 maxv Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.271 2017/07/29 05:08:48 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -382,8 +382,6 @@ struct mowner tcp_sock_rx_mowner = MOWNE
 struct mowner tcp_sock_tx_mowner = MOWNER_INIT("tcp", "sock tx");
 #endif
 
-callout_t tcp_slowtimo_ch;
-
 static int
 do_tcpinit(void)
 {
@@ -424,8 +422,7 @@ do_tcpinit(void)
 
 	vtw_earlyinit();
 
-	callout_init(_slowtimo_ch, CALLOUT_MPSAFE);
-	callout_reset(_slowtimo_ch, 1, tcp_slowtimo, NULL);
+	tcp_slowtimo_init();
 
 	return 0;
 }

Index: src/sys/netinet/tcp_timer.c
diff -u src/sys/netinet/tcp_timer.c:1.92 src/sys/netinet/tcp_timer.c:1.93
--- src/sys/netinet/tcp_timer.c:1.92	Fri Jul 28 19:16:41 2017
+++ src/sys/netinet/tcp_timer.c	Fri Jan 19 07:53:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_timer.c,v 1.92 2017/07/28 19:16:41 maxv Exp $	*/
+/*	$NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,11 +93,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.92 2017/07/28 19:16:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
 #include "opt_tcp_debug.h"
+#include "opt_net_mpsafe.h"
 #endif
 
 #include 
@@ -108,6 +109,8 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -149,6 +152,15 @@ u_int	tcp_keepcnt = 0;		/* max idle prob
 
 int	tcp_maxpersistidle = 0;		/* max idle time in persist */
 
+static callout_t	tcp_slowtimo_ch;
+#ifdef NET_MPSAFE
+static struct workqueue	*tcp_slowtimo_wq;
+static struct work	tcp_slowtimo_wk;
+#endif
+
+static void tcp_slowtimo_work(struct work *, void *);
+static void tcp_slowtimo(void *);
+
 /*
  * Time to delay the ACK.  This is initialized in tcp_init(), unless
  * its patched.
@@ -193,6 +205,21 @@ tcp_timer_init(void)
 		tcp_delack_ticks = TCP_DELACK_TICKS;
 }
 
+void
+tcp_slowtimo_init(void)
+{
+#ifdef NET_MPSAFE
+	int error;
+
+	error = workqueue_create(_slowtimo_wq, "tcp_slowtimo",
+	tcp_slowtimo_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE);
+	if (error != 0)
+		panic("%s: workqueue_create failed (%d)\n", __func__, error);
+#endif
+	callout_init(_slowtimo_ch, CALLOUT_MPSAFE);
+	callout_reset(_slowtimo_ch, 1, tcp_slowtimo, NULL);
+}
+
 /*
  * Callout to process delayed ACKs for a TCPCB.
  */
@@ -229,8 +256,8 @@ tcp_delack(void *arg)
  * Updates the timers in all active tcb's and
  * causes finite state machine actions if timers expire.
  */
-void
-tcp_slowtimo(void *arg)
+static void
+tcp_slowtimo_work(struct work *wk, void *arg)
 {
 
 	mutex_enter(softnet_lock);
@@ -241,6 +268,17 @@ tcp_slowtimo(void *arg)
 	callout_schedule(_slowtimo_ch, hz / PR_SLOWHZ);
 }
 
+static void
+tcp_slowtimo(void *arg)
+{
+
+#ifdef NET_MPSAFE
+	workqueue_enqueue(tcp_slowtimo_wq, _slowtimo_wk, NULL);
+#else
+	tcp_slowtimo_work(NULL, NULL);
+#endif
+}
+
 /*
  * Cancel all timers for TCP tp.
  */

Index: src/sys/netinet/tcp_timer.h
diff -u src/sys/netinet/tcp_timer.h:1.28 src/sys/netinet/tcp_timer.h:1.29
--- src/sys/netinet/tcp_timer.h:1.28	Tue May 24 18:37:52 2011
+++ src/sys/netinet/tcp_timer.h	Fri Jan 19 07:53:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_timer.h,v 1.28 2011/05/24 18:37:52 gdt Exp $	*/
+/*	$NetBSD: tcp_timer.h,v 1.29 2018/01/19 07:53:01 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2005 The NetBSD Foundation, Inc.
@@ -190,6 +190,7 @@ extern int tcp_ttl;			/* 

CVS commit: src/sys/net

2018-01-18 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Jan 19 05:19:29 UTC 2018

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

Log Message:
Release rt_so_mtx on updating a rtentry to avoid a deadlock with route_intr

The deadlock happened only if NET_MPSAFE on.


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/sys/net/rtsock.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/rtsock.c
diff -u src/sys/net/rtsock.c:1.236 src/sys/net/rtsock.c:1.237
--- src/sys/net/rtsock.c:1.236	Mon Dec 18 05:35:36 2017
+++ src/sys/net/rtsock.c	Fri Jan 19 05:19:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.236 2017/12/18 05:35:36 ozaki-r Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.237 2018/01/19 05:19:29 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.236 2017/12/18 05:35:36 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.237 2018/01/19 05:19:29 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -82,6 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -187,6 +188,9 @@ struct routecb {
 static struct rawcbhead rt_rawcb;
 #ifdef NET_MPSAFE
 static kmutex_t *rt_so_mtx;
+
+static bool rt_updating = false;
+static kcondvar_t rt_update_cv;
 #endif
 
 static void
@@ -1007,11 +1011,27 @@ COMPATNAME(route_output)(struct mbuf *m,
 
 		case RTM_CHANGE:
 #ifdef NET_MPSAFE
+			/*
+			 * Release rt_so_mtx to avoid a deadlock with route_intr
+			 * and also serialize updating routes to avoid another.
+			 */
+			while (rt_updating) {
+error = cv_wait_sig(_update_cv, rt_so_mtx);
+if (error != 0)
+	goto flush;
+			}
+			rt_updating = true;
+			mutex_exit(rt_so_mtx);
+
 			error = rt_update_prepare(rt);
 			if (error == 0) {
 error = route_output_change(rt, , rtm);
 rt_update_finish(rt);
 			}
+
+			mutex_enter(rt_so_mtx);
+			rt_updating = false;
+			cv_broadcast(_update_cv);
 #else
 			error = route_output_change(rt, , rtm);
 #endif
@@ -2110,6 +2130,8 @@ COMPATNAME(route_init)(void)
 #endif
 #ifdef NET_MPSAFE
 	rt_so_mtx = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
+
+	cv_init(_update_cv, "rtsock_cv");
 #endif
 
 	sysctl_net_route_setup(NULL);



CVS commit: src/sys/arch/evbmips/conf

2018-01-18 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Jan 18 23:17:09 UTC 2018

Modified Files:
src/sys/arch/evbmips/conf: LOONGSON

Log Message:
Use usbdevices. add midi needed to build umidi.
Remove now redundant USB entries.

So we will stop missing random USB drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/evbmips/conf/LOONGSON

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/evbmips/conf/LOONGSON
diff -u src/sys/arch/evbmips/conf/LOONGSON:1.35 src/sys/arch/evbmips/conf/LOONGSON:1.36
--- src/sys/arch/evbmips/conf/LOONGSON:1.35	Thu Sep 14 07:58:40 2017
+++ src/sys/arch/evbmips/conf/LOONGSON	Thu Jan 18 23:17:09 2018
@@ -1,4 +1,4 @@
-# $NetBSD: LOONGSON,v 1.35 2017/09/14 07:58:40 mrg Exp $
+# $NetBSD: LOONGSON,v 1.36 2018/01/18 23:17:09 maya Exp $
 #
 # LOONGSON machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/evbmips/conf/std.loongson
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"LOONGSON-$Revision: 1.35 $"
+#ident 		"LOONGSON-$Revision: 1.36 $"
 
 maxusers	16
 
@@ -176,11 +176,21 @@ stvii*		at iic? addr 0x40		# GDIUM's onb
 lynxfb0		at pci0 dev ? function ?	# SM712 on Yeeloong Notebook
 #genfb0		at pci0 dev ? function ?
 wsdisplay*	at wsemuldisplaydev?
+
 ehci*		at pci0 dev ? function ?
 #options 	EHCI_DEBUG
 ohci*		at pci0 dev ? function ?
 #options 	OHCI_DEBUG, USB_DEBUG, UHUB_DEBUG
 
+# USB
+usb*	at ehci?
+usb*	at ohci?
+
+include "dev/usb/usbdevices.config"
+midi*		at midibus?
+
+options		GDIUM_KEYBOARD_HACK	# support Fn key on Gdium
+
 gcscpcib*	at pci? dev ? function ?	# AMD CS5535/CS5536 PCI-ISA w/
 gpio*		at gcscpcib?			# timecounter, watchdog and GPIO
 isa0		at gcscpcib?
@@ -246,62 +256,6 @@ rgephy*	at mii? phy ?			# Realtek 8169S/
 rlphy*	at mii? phy ?			# Realtek 8139/8201L PHYs
 ukphy*	at mii? phy ?			# generic unknown PHYs
 
-# USB Hubs
-usb*	at ehci?
-usb*	at ohci?
-uhub*	at usb?
-uhub*	at uhub? port ?
-
-# USB HID device
-uhidev*	at uhub? port ? configuration ? interface ?
-
-# USB Mice
-ums*		at uhidev? reportid ?
-wsmouse*	at ums? mux 0
-
-# USB Keyboards
-ukbd*	at uhidev? reportid ?
-wskbd*	at ukbd? console ? mux 1
-options	GDIUM_KEYBOARD_HACK	# support Fn key on Gdium
-
-# USB Generic HID devices
-uhid*	at uhidev? reportid ?
-
-# USB serial adapter
-uftdi*	at uhub? port ? configuration ?
-
-# USB Printer
-ulpt*	at uhub? port ? configuration ? interface ?
-
-# USB Modem
-umodem*	at uhub? port ? configuration ?
-ucom*	at umodem?
-
-# Option N.V. Wireless WAN modems
-uhso*	at uhub? port ? configuration ?
-
-# USB Mass Storage
-umass*	at uhub? port ? configuration ? interface ?
-scsibus*	at umass? channel ?
-sd*		at scsibus? target ? lun ?	# SCSI disk drives
-cd*		at scsibus? target ? lun ?	# SCSI CD-ROM drives
-
-# FTDI FT8U100AX serial adapter
-uftdi*	at uhub? port ?
-ucom*	at uftdi? portno ?
-
-uplcom*	at uhub? port ?		# I/O DATA USB-RSAQ2 serial adapter
-ucom*	at uplcom? portno ?
-
-umct*	at uhub? port ?		# MCT USB-RS232 serial adapter
-ucom*	at umct? portno ?
-
-# Realtek RTL8187/RTL8187B 802.11b/g USB wireless adapter
-urtw*	at uhub? port ?
-
-# USB Generic driver
-ugen*	at uhub? port ?
-
 #
 # accept filters
 pseudo-device   accf_data		# "dataready" accept filter



CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jan 18 17:59:29 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_node.c

Log Message:
Style, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/net80211/ieee80211_node.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/net80211/ieee80211_node.c
diff -u src/sys/net80211/ieee80211_node.c:1.74 src/sys/net80211/ieee80211_node.c:1.75
--- src/sys/net80211/ieee80211_node.c:1.74	Tue Jan 16 18:53:32 2018
+++ src/sys/net80211/ieee80211_node.c	Thu Jan 18 17:59:29 2018
@@ -1,5 +1,6 @@
-/*	$NetBSD: ieee80211_node.c,v 1.74 2018/01/16 18:53:32 maxv Exp $	*/
-/*-
+/*	$NetBSD: ieee80211_node.c,v 1.75 2018/01/18 17:59:29 maxv Exp $	*/
+
+/*
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -36,7 +37,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.65 2005/08/13 17:50:21 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.74 2018/01/16 18:53:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.75 2018/01/18 17:59:29 maxv Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -300,8 +301,8 @@ ieee80211_reset_scan(struct ieee80211com
 void
 ieee80211_begin_scan(struct ieee80211com *ic, int reset)
 {
-
 	ic->ic_scan.nt_scangen++;
+
 	/*
 	 * In all but hostap mode scanning starts off in
 	 * an active mode before switching to passive.
@@ -315,6 +316,7 @@ ieee80211_begin_scan(struct ieee80211com
 		"begin %s scan in %s mode, scangen %u\n",
 		(ic->ic_flags & IEEE80211_F_ASCAN) ?  "active" : "passive",
 		ieee80211_phymode_name[ic->ic_curmode], ic->ic_scan.nt_scangen);
+
 	/*
 	 * Clear scan state and flush any previously seen AP's.
 	 */
@@ -365,6 +367,7 @@ ieee80211_next_scan(struct ieee80211com 
 			return 1;
 		}
 	} while (chan != ic->ic_curchan);
+
 	ieee80211_end_scan(ic);
 	return 0;
 }
@@ -455,12 +458,14 @@ ieee80211_create_ibss(struct ieee80211co
 		else
 			ni->ni_bssid[0] |= 0x02;	/* local bit for IBSS */
 	}
+
 	/*
 	 * Fix the channel and related attributes.
 	 */
 	ieee80211_set_chan(ic, ni, chan);
 	ic->ic_curchan = chan;
 	ic->ic_curmode = ieee80211_chan2mode(ic, chan);
+
 	/*
 	 * Do mode-specific rate setup.
 	 */
@@ -476,7 +481,7 @@ ieee80211_create_ibss(struct ieee80211co
 		ieee80211_set11gbasicrates(>ni_rates, IEEE80211_MODE_11B);
 	}
 
-	(void) ieee80211_sta_join(ic, ieee80211_ref_node(ni));
+	(void)ieee80211_sta_join(ic, ieee80211_ref_node(ni));
 }
 
 void
@@ -504,8 +509,8 @@ ieee80211_reset_bss(struct ieee80211com 
 static int
 ieee80211_match_bss(struct ieee80211com *ic, struct ieee80211_node *ni)
 {
-u_int8_t rate;
-int fail;
+	u_int8_t rate;
+	int fail;
 
 	fail = 0;
 	if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, ni->ni_chan)))
@@ -513,6 +518,7 @@ ieee80211_match_bss(struct ieee80211com 
 	if (ic->ic_des_chan != IEEE80211_CHAN_ANYC &&
 	ni->ni_chan != ic->ic_des_chan)
 		fail |= 0x01;
+
 	if (ic->ic_opmode == IEEE80211_M_IBSS) {
 		if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
 			fail |= 0x02;
@@ -520,6 +526,7 @@ ieee80211_match_bss(struct ieee80211com 
 		if ((ni->ni_capinfo & IEEE80211_CAPINFO_ESS) == 0)
 			fail |= 0x02;
 	}
+
 	if (ic->ic_flags & IEEE80211_F_PRIVACY) {
 		if ((ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0)
 			fail |= 0x04;
@@ -528,18 +535,23 @@ ieee80211_match_bss(struct ieee80211com 
 		if (ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY)
 			fail |= 0x04;
 	}
+
 	rate = ieee80211_fix_rate(ni, IEEE80211_R_DONEGO | IEEE80211_R_DOFRATE);
 	if (rate & IEEE80211_RATE_BASIC)
 		fail |= 0x08;
+
 	if (ic->ic_des_esslen != 0 &&
 	(ni->ni_esslen != ic->ic_des_esslen ||
 	 memcmp(ni->ni_essid, ic->ic_des_essid, ic->ic_des_esslen) != 0))
 		fail |= 0x10;
+
 	if ((ic->ic_flags & IEEE80211_F_DESBSSID) &&
 	!IEEE80211_ADDR_EQ(ic->ic_des_bssid, ni->ni_bssid))
 		fail |= 0x20;
+
 	if (ni->ni_fails >= STA_FAILS_MAX)
 		fail |= 0x40;
+
 #ifdef IEEE80211_DEBUG
 	if (ieee80211_msg_scan(ic)) {
 		printf(" %c %s",
@@ -565,6 +577,7 @@ ieee80211_match_bss(struct ieee80211com 
 		printf("%s\n", fail & 0x10 ? "!" : "");
 	}
 #endif
+
 	return fail;
 }
 
@@ -584,9 +597,8 @@ maxrate(const struct ieee80211_node *ni)
  * Used to select the best scan candidate for association in a BSS.
  */
 static int
-ieee80211_node_compare(struct ieee80211com *ic,
-		   const struct ieee80211_node *a,
-		   const struct ieee80211_node *b)
+ieee80211_node_compare(struct ieee80211com *ic, const struct ieee80211_node *a,
+const struct ieee80211_node *b)
 {
 	u_int8_t maxa, maxb;
 	u_int8_t rssia, rssib;
@@ -675,9 +687,10 @@ ieee80211_end_scan(struct ieee80211com *
 maxrssi[i] = rssi;
 		}
 		IEEE80211_NODE_UNLOCK(nt);
+
 		/* XXX select channel more intelligently */
 		bestchan = -1;
-		for (i = 0; i < IEEE80211_CHAN_MAX; i++)
+		

CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jan 18 17:57:49 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_netbsd.c

Log Message:
Style, and zero out 'ns' entirely, otherwise some bytes get leaked to
userland (eg ns_rsvd0).


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/net80211/ieee80211_netbsd.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/net80211/ieee80211_netbsd.c
diff -u src/sys/net80211/ieee80211_netbsd.c:1.29 src/sys/net80211/ieee80211_netbsd.c:1.30
--- src/sys/net80211/ieee80211_netbsd.c:1.29	Sat Jan 14 16:34:44 2017
+++ src/sys/net80211/ieee80211_netbsd.c	Thu Jan 18 17:57:49 2018
@@ -1,5 +1,6 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.29 2017/01/14 16:34:44 maya Exp $ */
-/*-
+/* $NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $ */
+
+/*
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
  *
@@ -30,7 +31,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
 #else
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.29 2017/01/14 16:34:44 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $");
 #endif
 
 /*
@@ -38,8 +39,8 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_ne
  */
 #include 
 #include 
-#include  
-#include
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -89,7 +90,7 @@ ieee80211_init0(void)
 		max_linkhdr = ALIGN(sizeof(struct ieee80211_qosframe_addr4));
 	}
 
-__link_set_foreach(ieee80211_setup, ieee80211_funcs) {
+	__link_set_foreach(ieee80211_setup, ieee80211_funcs) {
 		f = (void*)*ieee80211_setup;
 		(*f)();
 	}
@@ -112,22 +113,25 @@ ieee80211_sysctl_inact(SYSCTLFN_ARGS)
 	struct sysctlnode node;
 
 	node = *rnode;
-	/* sysctl_lookup copies the product from t.  Then, it
+
+	/*
+	 * sysctl_lookup copies the product from t.  Then, it
 	 * copies the new value onto t.
 	 */
 	t = *(int*)rnode->sysctl_data * IEEE80211_INACT_WAIT;
 	node.sysctl_data = 
 	error = sysctl_lookup(SYSCTLFN_CALL());
 	if (error || newp == NULL)
-		return (error);
+		return error;
 
-	/* The new value was in seconds.  Convert to inactivity-wait
+	/*
+	 * The new value was in seconds.  Convert to inactivity-wait
 	 * intervals.  There are IEEE80211_INACT_WAIT seconds per
 	 * interval.
 	 */
 	*(int*)rnode->sysctl_data = t / IEEE80211_INACT_WAIT;
 
-	return (0);
+	return 0;
 }
 
 static int
@@ -263,11 +267,11 @@ ieee80211_sysctl_detach(struct ieee80211
  *
  *	If there is any single 802.11 interface, ieee80211_node_walkfirst
  *	must not return NULL.
- */	
+ */
 static struct ieee80211_node *
 ieee80211_node_walkfirst(struct ieee80211_node_walk *nw, u_short if_index)
 {
-	(void)memset(nw, 0, sizeof(*nw));
+	memset(nw, 0, sizeof(*nw));
 
 	nw->nw_ifindex = if_index;
 
@@ -332,11 +336,13 @@ ieee80211_sysctl_fill_node(struct ieee80
 struct ieee80211_node_sysctl *ns, int ifindex,
 const struct ieee80211_channel *chan0, uint32_t flags)
 {
+	memset(ns, 0, sizeof(*ns));
+
 	ns->ns_ifindex = ifindex;
 	ns->ns_capinfo = ni->ni_capinfo;
 	ns->ns_flags = flags;
-	(void)memcpy(ns->ns_macaddr, ni->ni_macaddr, sizeof(ns->ns_macaddr));
-	(void)memcpy(ns->ns_bssid, ni->ni_bssid, sizeof(ns->ns_bssid));
+	memcpy(ns->ns_macaddr, ni->ni_macaddr, sizeof(ns->ns_macaddr));
+	memcpy(ns->ns_bssid, ni->ni_bssid, sizeof(ns->ns_bssid));
 	if (ni->ni_chan != IEEE80211_CHAN_ANYC) {
 		ns->ns_freq = ni->ni_chan->ic_freq;
 		ns->ns_chanflags = ni->ni_chan->ic_flags;
@@ -347,7 +353,7 @@ ieee80211_sysctl_fill_node(struct ieee80
 	}
 	ns->ns_rssi = ni->ni_rssi;
 	ns->ns_esslen = ni->ni_esslen;
-	(void)memcpy(ns->ns_essid, ni->ni_essid, sizeof(ns->ns_essid));
+	memcpy(ns->ns_essid, ni->ni_essid, sizeof(ns->ns_essid));
 	ns->ns_erp = ni->ni_erp;
 	ns->ns_associd = ni->ni_associd;
 	ns->ns_inact = ni->ni_inact * IEEE80211_INACT_WAIT;
@@ -355,7 +361,7 @@ ieee80211_sysctl_fill_node(struct ieee80
 	ns->ns_rates = ni->ni_rates;
 	ns->ns_txrate = ni->ni_txrate;
 	ns->ns_intval = ni->ni_intval;
-	(void)memcpy(ns->ns_tstamp, >ni_tstamp, sizeof(ns->ns_tstamp));
+	memcpy(ns->ns_tstamp, >ni_tstamp, sizeof(ns->ns_tstamp));
 	ns->ns_txseq = ni->ni_txseqs[0];
 	ns->ns_rxseq = ni->ni_rxseqs[0];
 	ns->ns_fhdwell = ni->ni_fhdwell;
@@ -485,7 +491,7 @@ ieee80211_sysctl_setup(void)
 	"debug", SYSCTL_DESCR("control debugging printfs"),
 	NULL, 0, _debug, 0, CTL_CREATE, CTL_EOL)) != 0)
 		goto err;
-#endif /* IEEE80211_DEBUG */
+#endif
 
 	ieee80211_rssadapt_sysctl_setup(_sysctllog);
 
@@ -524,7 +530,6 @@ ieee80211_drain_ifq(struct ifqueue *ifq)
 	}
 }
 
-
 void
 if_printf(struct ifnet *ifp, const char *fmt, ...)
 {
@@ -538,7 +543,6 @@ if_printf(struct ifnet *ifp, const char 
 	return;
 }
 
-
 /*
  * Allocate and setup a management frame of the specified
  * size.  We return the mbuf and a pointer to the start
@@ -561,6 

CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jan 18 16:23:43 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_output.c

Log Message:
Several changes:

 * Make the code more readable.

 * Add a panic in ieee80211_compute_duration(). I'm not sure there's
   a bug here - I don't have the hardware -, but looking at the code, it
   may be possible for 'paylen' to go negative. Obviously that's not the
   correct way to fix it, but at least we'll see if it happens.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/net80211/ieee80211_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/net80211/ieee80211_output.c
diff -u src/sys/net80211/ieee80211_output.c:1.60 src/sys/net80211/ieee80211_output.c:1.61
--- src/sys/net80211/ieee80211_output.c:1.60	Thu Jan 18 13:24:01 2018
+++ src/sys/net80211/ieee80211_output.c	Thu Jan 18 16:23:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_output.c,v 1.60 2018/01/18 13:24:01 maxv Exp $	*/
+/*	$NetBSD: ieee80211_output.c,v 1.61 2018/01/18 16:23:43 maxv Exp $	*/
 
 /*
  * Copyright (c) 2001 Atsushi Onoe
@@ -37,7 +37,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.60 2018/01/18 13:24:01 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.61 2018/01/18 16:23:43 maxv Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -404,6 +404,9 @@ done:
  * 802.11 data frame.  If room isn't already there, arrange for it.
  * Drivers and cipher modules assume we have done the necessary work
  * and fail rudely if they don't find the space they need.
+ *
+ * Basically, we are trying to make sure that the several M_PREPENDs
+ * called after this function do not fail.
  */
 static struct mbuf *
 ieee80211_mbuf_adjust(struct ieee80211com *ic, int hdrsize,
@@ -447,30 +450,30 @@ ieee80211_mbuf_adjust(struct ieee80211co
 		 * required (the latter are added when the driver calls
 		 * back to ieee80211_crypto_encap to do crypto encapsulation).
 		 */
-		/* NB: must be first 'cuz it clobbers m_data */
 		M_MOVE_PKTHDR(n, m);
-		n->m_len = 0;			/* NB: m_gethdr does not set */
+		n->m_len = 0;
 		n->m_data += needed_space;
+
 		/*
 		 * Pull up Ethernet header to create the expected layout.
 		 * We could use m_pullup but that's overkill (i.e. we don't
 		 * need the actual data) and it cannot fail so do it inline
 		 * for speed.
 		 */
-		/* NB: struct ether_header is known to be contiguous */
 		n->m_len += sizeof(struct ether_header);
 		m->m_len -= sizeof(struct ether_header);
 		m->m_data += sizeof(struct ether_header);
+
 		/*
 		 * Replace the head of the chain.
 		 */
 		n->m_next = m;
 		m = n;
 	} else {
-/*
+		/*
 		 * We will overwrite the ethernet header in the
- * 802.11 encapsulation stage.  Make sure that it
- * is writable.
+		 * 802.11 encapsulation stage.  Make sure that it
+		 * is writable.
 		 */
 		wlen = sizeof(struct ether_header);
 	}
@@ -479,13 +482,14 @@ ieee80211_mbuf_adjust(struct ieee80211co
 	 * If we're going to s/w encrypt the mbuf chain make sure it is
 	 * writable.
 	 */
-	if (key != NULL && (key->wk_flags & IEEE80211_KEY_SWCRYPT) != 0)
+	if (key != NULL && (key->wk_flags & IEEE80211_KEY_SWCRYPT) != 0) {
 		wlen = M_COPYALL;
-
+	}
 	if (wlen != 0 && m_makewritable(, 0, wlen, M_DONTWAIT) != 0) {
 		m_freem(m);
 		return NULL;
 	}
+
 	return m;
 #undef TO_BE_RECLAIMED
 }
@@ -843,11 +847,15 @@ ieee80211_compute_duration(const struct 
 
 	hdrlen = ieee80211_anyhdrsize((const void *)wh);
 
-/* Account for padding required by the driver. */
-	if (icflags & IEEE80211_F_DATAPAD)
+	/* Account for padding required by the driver. */
+	if (icflags & IEEE80211_F_DATAPAD) {
 		paylen = len - roundup(hdrlen, sizeof(u_int32_t));
-	else
+		if (paylen < 0) {
+			panic("%s: paylen < 0", __func__);
+		}
+	} else {
 		paylen = len - hdrlen;
+	}
 
 	overlen = IEEE80211_CRC_LEN;
 
@@ -914,7 +922,8 @@ ieee80211_fragment(struct ieee80211com *
 {
 	struct ieee80211_frame *wh, *whf;
 	struct mbuf *m, *prev, *next;
-	u_int totalhdrsize, fragno, fragsize, off, remainder, payload;
+	const u_int totalhdrsize = hdrsize + ciphdrsize;
+	u_int fragno, fragsize, off, remainder, payload;
 
 	IASSERT(m0->m_nextpkt == NULL, ("mbuf already chained?"));
 	IASSERT(m0->m_pkthdr.len > mtu,
@@ -923,7 +932,7 @@ ieee80211_fragment(struct ieee80211com *
 	wh = mtod(m0, struct ieee80211_frame *);
 	/* NB: mark the first frag; it will be propagated below */
 	wh->i_fc[1] |= IEEE80211_FC1_MORE_FRAG;
-	totalhdrsize = hdrsize + ciphdrsize;
+
 	fragno = 1;
 	off = mtu - ciphdrsize;
 	remainder = m0->m_pkthdr.len - off;
@@ -940,6 +949,7 @@ ieee80211_fragment(struct ieee80211com *
 			m = m_gethdr(M_DONTWAIT, MT_DATA);
 		if (m == NULL)
 			goto bad;
+
 		/* leave room to prepend any 

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

2018-01-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 18 14:18:23 UTC 2018

Modified Files:
src/sys/arch/arm/arm: syscall.c

Log Message:
Fix test for SMI_IMB{,range} that was broken in 1.46

>From Ramakrishna Rao Desetti


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/arm/arm/syscall.c

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

Modified files:

Index: src/sys/arch/arm/arm/syscall.c
diff -u src/sys/arch/arm/arm/syscall.c:1.62 src/sys/arch/arm/arm/syscall.c:1.63
--- src/sys/arch/arm/arm/syscall.c:1.62	Sun Jul  2 16:16:44 2017
+++ src/sys/arch/arm/arm/syscall.c	Thu Jan 18 14:18:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.62 2017/07/02 16:16:44 skrll Exp $	*/
+/*	$NetBSD: syscall.c,v 1.63 2018/01/18 14:18:23 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.62 2017/07/02 16:16:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.63 2018/01/18 14:18:23 skrll Exp $");
 
 #include 
 #include 
@@ -214,8 +214,9 @@ syscall(struct trapframe *tf, lwp_t *l, 
 	/* test new official and old unofficial NetBSD ranges */
 	if (__predict_false(os_mask != SWI_OS_NETBSD)
 	&& __predict_false(os_mask != 0)) {
-		if (os_mask == SWI_OS_ARM
-		&& (code == SWI_IMB || code == SWI_IMBrange)) {
+
+		const uint32_t swi = __SHIFTOUT(insn, __BITS(23,0));
+		if (swi == SWI_IMB || swi == SWI_IMBrange) {
 			userret(l);
 			return;
 		}



CVS commit: src/sys

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jan 18 13:31:21 UTC 2018

Modified Files:
src/sys/compat/netbsd32: netbsd32_module.c
src/sys/kern: sys_module.c

Log Message:
Don't return the address of the kernel modules if the user is not
privileged. Discussed on tech-kern@.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/compat/netbsd32/netbsd32_module.c
cvs rdiff -u -r1.22 -r1.23 src/sys/kern/sys_module.c

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

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_module.c
diff -u src/sys/compat/netbsd32/netbsd32_module.c:1.5 src/sys/compat/netbsd32/netbsd32_module.c:1.6
--- src/sys/compat/netbsd32/netbsd32_module.c:1.5	Thu Jun  1 02:45:08 2017
+++ src/sys/compat/netbsd32/netbsd32_module.c	Thu Jan 18 13:31:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_module.c,v 1.5 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: netbsd32_module.c,v 1.6 2018/01/18 13:31:21 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_module.c,v 1.5 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_module.c,v 1.6 2018/01/18 13:31:21 maxv Exp $");
 
 #include 
 #include 
@@ -52,6 +52,12 @@ modctl32_handle_stat(struct netbsd32_iov
 	size_t size;
 	size_t mslen;
 	int error;
+	bool stataddr;
+
+	/* If not privileged, don't expose kernel addresses. */
+	error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE,
+	0, (void *)(uintptr_t)MODCTL_STAT, NULL, NULL);
+	stataddr = (error == 0);
 
 	kernconfig_lock();
 	mslen = (module_count+module_builtinlist+1) * sizeof(modstat_t);
@@ -64,7 +70,7 @@ modctl32_handle_stat(struct netbsd32_iov
 			strlcpy(ms->ms_required, mi->mi_required,
 			sizeof(ms->ms_required));
 		}
-		if (mod->mod_kobj != NULL) {
+		if (mod->mod_kobj != NULL && stataddr) {
 			kobj_stat(mod->mod_kobj, , );
 			ms->ms_addr = addr;
 			ms->ms_size = size;
@@ -82,7 +88,7 @@ modctl32_handle_stat(struct netbsd32_iov
 			strlcpy(ms->ms_required, mi->mi_required,
 			sizeof(ms->ms_required));
 		}
-		if (mod->mod_kobj != NULL) {
+		if (mod->mod_kobj != NULL && stataddr) {
 			kobj_stat(mod->mod_kobj, , );
 			ms->ms_addr = addr;
 			ms->ms_size = size;

Index: src/sys/kern/sys_module.c
diff -u src/sys/kern/sys_module.c:1.22 src/sys/kern/sys_module.c:1.23
--- src/sys/kern/sys_module.c:1.22	Thu Jun  1 02:45:13 2017
+++ src/sys/kern/sys_module.c	Thu Jan 18 13:31:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_module.c,v 1.22 2017/06/01 02:45:13 chs Exp $	*/
+/*	$NetBSD: sys_module.c,v 1.23 2018/01/18 13:31:20 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.22 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_module.c,v 1.23 2018/01/18 13:31:20 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -120,6 +120,12 @@ handle_modctl_stat(struct iovec *iov, vo
 	size_t size;
 	size_t mslen;
 	int error;
+	bool stataddr;
+
+	/* If not privileged, don't expose kernel addresses. */
+	error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE,
+	0, (void *)(uintptr_t)MODCTL_STAT, NULL, NULL);
+	stataddr = (error == 0);
 
 	kernconfig_lock();
 	mslen = (module_count+module_builtinlist+1) * sizeof(modstat_t);
@@ -132,7 +138,7 @@ handle_modctl_stat(struct iovec *iov, vo
 			strlcpy(ms->ms_required, mi->mi_required,
 			sizeof(ms->ms_required));
 		}
-		if (mod->mod_kobj != NULL) {
+		if (mod->mod_kobj != NULL && stataddr) {
 			kobj_stat(mod->mod_kobj, , );
 			ms->ms_addr = addr;
 			ms->ms_size = size;
@@ -150,7 +156,7 @@ handle_modctl_stat(struct iovec *iov, vo
 			strlcpy(ms->ms_required, mi->mi_required,
 			sizeof(ms->ms_required));
 		}
-		if (mod->mod_kobj != NULL) {
+		if (mod->mod_kobj != NULL && stataddr) {
 			kobj_stat(mod->mod_kobj, , );
 			ms->ms_addr = addr;
 			ms->ms_size = size;



CVS commit: src/sys/net80211

2018-01-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jan 18 13:24:01 UTC 2018

Modified Files:
src/sys/net80211: ieee80211_output.c

Log Message:
Several changes:

 * Make the code more readable. In particular, declare variables as const
   along the way.

 * Explain what we're doing in ieee80211_send_mgmt(). The
   IEEE80211_FC0_SUBTYPE_PROBE_RESP case has some inconsistencies, but
   they are not inherently wrong so I'm not changing that.

 * When sending IEEE80211_FC0_SUBTYPE_REASSOC_RESP frames, make sure to
   zero out the 'association ID', otherwise two bytes are leaked.

 * Fix a possible memory leak in ieee80211_send_probereq().


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/net80211/ieee80211_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/net80211/ieee80211_output.c
diff -u src/sys/net80211/ieee80211_output.c:1.59 src/sys/net80211/ieee80211_output.c:1.60
--- src/sys/net80211/ieee80211_output.c:1.59	Tue Sep 26 07:42:06 2017
+++ src/sys/net80211/ieee80211_output.c	Thu Jan 18 13:24:01 2018
@@ -1,5 +1,6 @@
-/*	$NetBSD: ieee80211_output.c,v 1.59 2017/09/26 07:42:06 knakahara Exp $	*/
-/*-
+/*	$NetBSD: ieee80211_output.c,v 1.60 2018/01/18 13:24:01 maxv Exp $	*/
+
+/*
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -36,7 +37,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.59 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.60 2018/01/18 13:24:01 maxv Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -115,6 +116,7 @@ ieee80211_send_setup(struct ieee80211com
 #define	WH4(wh)	((struct ieee80211_frame_addr4 *)wh)
 
 	wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | type;
+
 	if ((type & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_DATA) {
 		switch (ic->ic_opmode) {
 		case IEEE80211_M_STA:
@@ -123,6 +125,7 @@ ieee80211_send_setup(struct ieee80211com
 			IEEE80211_ADDR_COPY(wh->i_addr2, sa);
 			IEEE80211_ADDR_COPY(wh->i_addr3, da);
 			break;
+
 		case IEEE80211_M_IBSS:
 		case IEEE80211_M_AHDEMO:
 			wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
@@ -130,12 +133,14 @@ ieee80211_send_setup(struct ieee80211com
 			IEEE80211_ADDR_COPY(wh->i_addr2, sa);
 			IEEE80211_ADDR_COPY(wh->i_addr3, bssid);
 			break;
+
 		case IEEE80211_M_HOSTAP:
 			wh->i_fc[1] = IEEE80211_FC1_DIR_FROMDS;
 			IEEE80211_ADDR_COPY(wh->i_addr1, da);
 			IEEE80211_ADDR_COPY(wh->i_addr2, bssid);
 			IEEE80211_ADDR_COPY(wh->i_addr3, sa);
 			break;
+
 		case IEEE80211_M_MONITOR:	/* NB: to quiet compiler */
 			break;
 		}
@@ -145,6 +150,7 @@ ieee80211_send_setup(struct ieee80211com
 		IEEE80211_ADDR_COPY(wh->i_addr2, sa);
 		IEEE80211_ADDR_COPY(wh->i_addr3, bssid);
 	}
+
 	*(u_int16_t *)>i_dur[0] = 0;
 	/* NB: use non-QoS tid */
 	*(u_int16_t *)>i_seq[0] =
@@ -187,9 +193,9 @@ ieee80211_mgmt_output(struct ieee80211co
 	M_SETCTX(m, ni);
 
 	wh = mtod(m, struct ieee80211_frame *);
-	ieee80211_send_setup(ic, ni, wh, 
-		IEEE80211_FC0_TYPE_MGT | type,
-		ic->ic_myaddr, ni->ni_macaddr, ni->ni_bssid);
+	ieee80211_send_setup(ic, ni, wh, IEEE80211_FC0_TYPE_MGT | type,
+	ic->ic_myaddr, ni->ni_macaddr, ni->ni_bssid);
+
 	if ((m->m_flags & M_LINK0) != 0 && ni->ni_challenge != NULL) {
 		m->m_flags &= ~M_LINK0;
 		IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
@@ -197,6 +203,7 @@ ieee80211_mgmt_output(struct ieee80211co
 			ether_sprintf(wh->i_addr1), __func__);
 		wh->i_fc[1] |= IEEE80211_FC1_WEP;
 	}
+
 #ifdef IEEE80211_DEBUG
 	/* avoid printing too many frames */
 	if ((ieee80211_msg_debug(ic) && doprint(ic, type)) ||
@@ -209,6 +216,7 @@ ieee80211_mgmt_output(struct ieee80211co
 		ieee80211_chan2ieee(ic, ic->ic_curchan));
 	}
 #endif
+
 	IEEE80211_NODE_STAT(ni, tx_mgmt);
 	IF_ENQUEUE(>ic_mgtq, m);
 	if (timer) {
@@ -247,13 +255,17 @@ ieee80211_send_nulldata(struct ieee80211
 	M_SETCTX(m, ni);
 
 	wh = mtod(m, struct ieee80211_frame *);
+
 	ieee80211_send_setup(ic, ni, wh,
-		IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA,
-		ic->ic_myaddr, ni->ni_macaddr, ni->ni_bssid);
+	IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_NODATA,
+	ic->ic_myaddr, ni->ni_macaddr, ni->ni_bssid);
+
 	/* NB: power management bit is never sent by an AP */
 	if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) &&
-	ic->ic_opmode != IEEE80211_M_HOSTAP)
+	ic->ic_opmode != IEEE80211_M_HOSTAP) {
 		wh->i_fc[1] |= IEEE80211_FC1_PWR_MGT;
+	}
+
 	m->m_len = m->m_pkthdr.len = sizeof(struct ieee80211_frame);
 
 	IEEE80211_NODE_STAT(ni, tx_data);
@@ -277,7 +289,8 @@ ieee80211_send_nulldata(struct ieee80211
  * applied.
  */
 int
-ieee80211_classify(struct ieee80211com *ic, struct mbuf *m, struct ieee80211_node *ni)
+ieee80211_classify(struct ieee80211com *ic, struct mbuf *m,
+struct ieee80211_node 

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

2018-01-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 18 12:49:09 UTC 2018

Modified Files:
src/sys/arch/arm/cortex: a9_mpsubr.S

Log Message:
Use r0 in the tlbiall instruction to avoid confusion.

>From Ramakrishna Rao Desetti


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/arm/cortex/a9_mpsubr.S

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

Modified files:

Index: src/sys/arch/arm/cortex/a9_mpsubr.S
diff -u src/sys/arch/arm/cortex/a9_mpsubr.S:1.54 src/sys/arch/arm/cortex/a9_mpsubr.S:1.55
--- src/sys/arch/arm/cortex/a9_mpsubr.S:1.54	Sun Dec 10 21:38:26 2017
+++ src/sys/arch/arm/cortex/a9_mpsubr.S	Thu Jan 18 12:49:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: a9_mpsubr.S,v 1.54 2017/12/10 21:38:26 skrll Exp $	*/
+/*	$NetBSD: a9_mpsubr.S,v 1.55 2018/01/18 12:49:09 skrll Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -506,7 +506,7 @@ cortex_init:
 	// turning on SMP.
 	//
 	mov	r0, #0
-	mcr	p15, 0, r1, c8, c7, 0	// TLBIALL (just this core)
+	mcr	p15, 0, r0, c8, c7, 0	// TLBIALL (just this core)
 #endif
 
 	// For the A7, SMP must be on ldrex/strex to work.



CVS commit: src/share/man/man4

2018-01-18 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Jan 18 09:54:52 UTC 2018

Modified Files:
src/share/man/man4: wm.4

Log Message:
More markup.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/share/man/man4/wm.4

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/man4/wm.4
diff -u src/share/man/man4/wm.4:1.37 src/share/man/man4/wm.4:1.38
--- src/share/man/man4/wm.4:1.37	Thu Jan 18 09:38:15 2018
+++ src/share/man/man4/wm.4	Thu Jan 18 09:54:52 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: wm.4,v 1.37 2018/01/18 09:38:15 knakahara Exp $
+.\"	$NetBSD: wm.4,v 1.38 2018/01/18 09:54:52 wiz Exp $
 .\"
 .\" Copyright 2002, 2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -183,7 +183,8 @@ The default value is 100.
 When you increase this value, both the receive latency and
 the receive throughput will increase.
 .It Dv WM_TX_PROCESS_LIMIT_DEFAULT
-Transmit side of WM_RX_PROCESS_LIMIT_DEFAULT.
+Transmit side of
+.Dv WM_RX_PROCESS_LIMIT_DEFAULT .
 .It Dv WM_RX_INTR_PROCESS_LIMIT_DEFAULT
 The maximum number of received packets processed in each
 hardware interrupt context.
@@ -194,7 +195,8 @@ The default value is 0.
 When you increase this value, both the receive latency and
 the receive throughput will decrease.
 .It Dv WM_TX_INTR_PROCESS_LIMIT_DEFAULT
-Transmit side of WM_RX_INTR_PROCESS_LIMIT_DEFAULT.
+Transmit side of
+.Dv WM_RX_INTR_PROCESS_LIMIT_DEFAULT .
 .It Dv WM_EVENT_COUNTERS
 Enable many event counters such as each Tx drop counter and Rx interrupt
 counter.



CVS commit: src/share/man/man4

2018-01-18 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Jan 18 09:38:15 UTC 2018

Modified Files:
src/share/man/man4: wm.4

Log Message:
add WM_TX_PROCESS_LIMIT_DEFAULT and WM_TX_INTR_PROCESS_LIMIT_DEFAULT man.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/share/man/man4/wm.4

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/man4/wm.4
diff -u src/share/man/man4/wm.4:1.36 src/share/man/man4/wm.4:1.37
--- src/share/man/man4/wm.4:1.36	Thu Apr 13 10:37:36 2017
+++ src/share/man/man4/wm.4	Thu Jan 18 09:38:15 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: wm.4,v 1.36 2017/04/13 10:37:36 knakahara Exp $
+.\"	$NetBSD: wm.4,v 1.37 2018/01/18 09:38:15 knakahara Exp $
 .\"
 .\" Copyright 2002, 2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 22, 2017
+.Dd January 18, 2018
 .Dt WM 4
 .Os
 .Sh NAME
@@ -182,6 +182,8 @@ The value range is from zero to
 The default value is 100.
 When you increase this value, both the receive latency and
 the receive throughput will increase.
+.It Dv WM_TX_PROCESS_LIMIT_DEFAULT
+Transmit side of WM_RX_PROCESS_LIMIT_DEFAULT.
 .It Dv WM_RX_INTR_PROCESS_LIMIT_DEFAULT
 The maximum number of received packets processed in each
 hardware interrupt context.
@@ -191,6 +193,8 @@ The value range is from zero to
 The default value is 0.
 When you increase this value, both the receive latency and
 the receive throughput will decrease.
+.It Dv WM_TX_INTR_PROCESS_LIMIT_DEFAULT
+Transmit side of WM_RX_INTR_PROCESS_LIMIT_DEFAULT.
 .It Dv WM_EVENT_COUNTERS
 Enable many event counters such as each Tx drop counter and Rx interrupt
 counter.



CVS commit: src/sys/dev/pci

2018-01-18 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Jan 18 09:36:26 UTC 2018

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

Log Message:
wm_txeof() can limit the loop count the same as wm_rxeof() now.


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

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.556 src/sys/dev/pci/if_wm.c:1.557
--- src/sys/dev/pci/if_wm.c:1.556	Wed Jan 17 02:16:07 2018
+++ src/sys/dev/pci/if_wm.c	Thu Jan 18 09:36:26 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.556 2018/01/17 02:16:07 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.557 2018/01/18 09:36:26 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.556 2018/01/17 02:16:07 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.557 2018/01/18 09:36:26 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -213,6 +213,13 @@ int wm_disable_msix = WM_DISABLE_MSIX;
 
 #define	WM_TXINTERQSIZE		256
 
+#ifndef WM_TX_PROCESS_LIMIT_DEFAULT
+#define	WM_TX_PROCESS_LIMIT_DEFAULT		100U
+#endif
+#ifndef WM_TX_INTR_PROCESS_LIMIT_DEFAULT
+#define	WM_TX_INTR_PROCESS_LIMIT_DEFAULT	0U
+#endif
+
 /*
  * Receive descriptor list size.  We have one Rx buffer for normal
  * sized packets.  Jumbo packets consume 5 Rx buffers for a full-sized
@@ -519,6 +526,8 @@ struct wm_softc {
 
 	int sc_nqueues;
 	struct wm_queue *sc_queue;
+	u_int sc_tx_process_limit;	/* Tx processing repeat limit in softint */
+	u_int sc_tx_intr_process_limit;	/* Tx processing repeat limit in H/W intr */
 	u_int sc_rx_process_limit;	/* Rx processing repeat limit in softint */
 	u_int sc_rx_intr_process_limit;	/* Rx processing repeat limit in H/W intr */
 
@@ -758,7 +767,7 @@ static void	wm_nq_send_common_locked(str
 static void	wm_deferred_start_locked(struct wm_txqueue *);
 static void	wm_handle_queue(void *);
 /* Interrupt */
-static int	wm_txeof(struct wm_softc *, struct wm_txqueue *);
+static int	wm_txeof(struct wm_txqueue *, u_int);
 static void	wm_rxeof(struct wm_rxqueue *, u_int);
 static void	wm_linkintr_gmii(struct wm_softc *, uint32_t);
 static void	wm_linkintr_tbi(struct wm_softc *, uint32_t);
@@ -2764,6 +2773,8 @@ alloc_retry:
 		ifp->if_capabilities |= IFCAP_TSOv6;
 	}
 
+	sc->sc_tx_process_limit = WM_TX_PROCESS_LIMIT_DEFAULT;
+	sc->sc_tx_intr_process_limit = WM_TX_INTR_PROCESS_LIMIT_DEFAULT;
 	sc->sc_rx_process_limit = WM_RX_PROCESS_LIMIT_DEFAULT;
 	sc->sc_rx_intr_process_limit = WM_RX_INTR_PROCESS_LIMIT_DEFAULT;
 
@@ -2972,7 +2983,9 @@ wm_watchdog_txq_locked(struct ifnet *ifp
 	 * Since we're using delayed interrupts, sweep up
 	 * before we report an error.
 	 */
-	wm_txeof(sc, txq);
+	mutex_enter(txq->txq_lock);
+	wm_txeof(txq, UINT_MAX);
+	mutex_exit(txq->txq_lock);
 
 	if (txq->txq_free != WM_NTXDESC(txq)) {
 #ifdef WM_DEBUG
@@ -7140,7 +7153,7 @@ wm_send_common_locked(struct ifnet *ifp,
 
 		/* Get a work queue entry. */
 		if (txq->txq_sfree < WM_TXQUEUE_GC(txq)) {
-			wm_txeof(sc, txq);
+			wm_txeof(txq, UINT_MAX);
 			if (txq->txq_sfree == 0) {
 DPRINTF(WM_DEBUG_TX,
 ("%s: TX: no free job descriptors\n",
@@ -7739,7 +7752,7 @@ wm_nq_send_common_locked(struct ifnet *i
 
 		/* Get a work queue entry. */
 		if (txq->txq_sfree < WM_TXQUEUE_GC(txq)) {
-			wm_txeof(sc, txq);
+			wm_txeof(txq, UINT_MAX);
 			if (txq->txq_sfree == 0) {
 DPRINTF(WM_DEBUG_TX,
 ("%s: TX: no free job descriptors\n",
@@ -8028,8 +8041,9 @@ wm_deferred_start_locked(struct wm_txque
  *	Helper; handle transmit interrupts.
  */
 static int
-wm_txeof(struct wm_softc *sc, struct wm_txqueue *txq)
+wm_txeof(struct wm_txqueue *txq, u_int limit)
 {
+	struct wm_softc *sc = txq->txq_sc;
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct wm_txsoft *txs;
 	bool processed = false;
@@ -8054,6 +8068,9 @@ wm_txeof(struct wm_softc *sc, struct wm_
 	 */
 	for (i = txq->txq_sdirty; txq->txq_sfree != WM_TXQUEUELEN(txq);
 	 i = WM_NEXTTXS(txq, i), txq->txq_sfree++) {
+		if (limit-- == 0)
+			break;
+
 		txs = >txq_soft[i];
 
 		DPRINTF(WM_DEBUG_TX, ("%s: TX: checking job %d\n",
@@ -8890,7 +8907,7 @@ wm_intr_legacy(void *arg)
 			WM_Q_EVCNT_INCR(txq, txdw);
 		}
 #endif
-		wm_txeof(sc, txq);
+		wm_txeof(txq, UINT_MAX);
 
 		mutex_exit(txq->txq_lock);
 		WM_CORE_LOCK(sc);
@@ -8960,7 +8977,8 @@ wm_txrxintr_msix(void *arg)
 	struct wm_txqueue *txq = >wmq_txq;
 	struct wm_rxqueue *rxq = >wmq_rxq;
 	struct wm_softc *sc = txq->txq_sc;
-	u_int limit = sc->sc_rx_intr_process_limit;
+	u_int txlimit = sc->sc_tx_intr_process_limit;
+	u_int rxlimit = sc->sc_rx_intr_process_limit;
 
 	KASSERT(wmq->wmq_intr_idx == wmq->wmq_id);
 
@@ -8977,7 +8995,7 @@ wm_txrxintr_msix(void *arg)
 	}
 
 	WM_Q_EVCNT_INCR(txq, txdw);
-	wm_txeof(sc, txq);
+	wm_txeof(txq, txlimit);
 	/* 

CVS commit: src/sys/kern

2018-01-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 18 08:40:56 UTC 2018

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

Log Message:
typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/kern/kern_mutex.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/kern_mutex.c
diff -u src/sys/kern/kern_mutex.c:1.68 src/sys/kern/kern_mutex.c:1.69
--- src/sys/kern/kern_mutex.c:1.68	Mon Dec 25 09:13:40 2017
+++ src/sys/kern/kern_mutex.c	Thu Jan 18 08:40:56 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_mutex.c,v 1.68 2017/12/25 09:13:40 ozaki-r Exp $	*/
+/*	$NetBSD: kern_mutex.c,v 1.69 2018/01/18 08:40:56 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #define	__MUTEX_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.68 2017/12/25 09:13:40 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.69 2018/01/18 08:40:56 skrll Exp $");
 
 #include 
 #include 
@@ -570,7 +570,7 @@ mutex_vector_enter(kmutex_t *mtx)
 
 		/*
 		 * Once we have the turnstile chain interlock, mark the
-		 * mutex has having waiters.  If that fails, spin again:
+		 * mutex as having waiters.  If that fails, spin again:
 		 * chances are that the mutex has been released.
 		 */
 		if (!MUTEX_SET_WAITERS(mtx, owner)) {