CVS commit: src/sys/opencrypto

2017-05-17 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed May 17 07:12:50 UTC 2017

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
refactor crypto_kdispatch() in a similar way as crypto_dispatch().


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/opencrypto/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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.67 src/sys/opencrypto/crypto.c:1.68
--- src/sys/opencrypto/crypto.c:1.67	Wed May 17 06:53:02 2017
+++ src/sys/opencrypto/crypto.c	Wed May 17 07:12:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.67 2017/05/17 06:53:02 knakahara Exp $ */
+/*	$NetBSD: crypto.c,v 1.68 2017/05/17 07:12:50 knakahara Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.67 2017/05/17 06:53:02 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.68 2017/05/17 07:12:50 knakahara Exp $");
 
 #include 
 #include 
@@ -853,36 +853,49 @@ crypto_kdispatch(struct cryptkop *krp)
 	cryptostats.cs_kops++;
 
 	cap = crypto_checkdriver(krp->krp_hid);
-	if (cap && !cap->cc_kqblocked) {
+	/*
+	 * TODO:
+	 * If we can ensure the driver has been valid until the driver is
+	 * done crypto_unregister(), this migrate operation is not required.
+	 */
+	if (cap == NULL) {
+		TAILQ_INSERT_TAIL(&crp_kq, krp, krp_next);
 		mutex_spin_exit(&crypto_q_mtx);
-		result = crypto_kinvoke(krp, 0);
-		if (result == ERESTART) {
-			/*
-			 * The driver ran out of resources, mark the
-			 * driver ``blocked'' for cryptop's and put
-			 * the op on the queue.
-			 */
-			mutex_spin_enter(&crypto_q_mtx);
-			crypto_drivers[krp->krp_hid].cc_kqblocked = 1;
-			TAILQ_INSERT_HEAD(&crp_kq, krp, krp_next);
-			cryptostats.cs_kblocks++;
-			mutex_spin_exit(&crypto_q_mtx);
 
-			/*
-			 * The krp is enqueued to crp_kq, that is,
-			 * no error occurs. So, this function should
-			 * not return error.
-			 */
-			result = 0;
-		}
-	} else {
+		return 0;
+	}
+
+	if (cap->cc_kqblocked != 0) {
 		/*
 		 * The driver is blocked, just queue the op until
 		 * it unblocks and the swi thread gets kicked.
 		 */
 		TAILQ_INSERT_TAIL(&crp_kq, krp, krp_next);
-		result = 0;
 		mutex_spin_exit(&crypto_q_mtx);
+
+		return 0;
+	}
+
+	mutex_spin_exit(&crypto_q_mtx);
+	result = crypto_kinvoke(krp, 0);
+	if (result == ERESTART) {
+		/*
+		 * The driver ran out of resources, mark the
+		 * driver ``blocked'' for cryptop's and put
+		 * the op on the queue.
+		 */
+		mutex_spin_enter(&crypto_q_mtx);
+		crypto_drivers[krp->krp_hid].cc_kqblocked = 1;
+		TAILQ_INSERT_HEAD(&crp_kq, krp, krp_next);
+		cryptostats.cs_kblocks++;
+		mutex_spin_exit(&crypto_q_mtx);
+
+		/*
+		 * The krp is enqueued to crp_kq, that is,
+		 * no error occurs. So, this function should
+		 * not return error.
+		 */
+		result = 0;
 	}
 
 	return result;



CVS commit: src/share/man/man4

2017-05-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed May 17 09:03:12 UTC 2017

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

Log Message:
Sort SEE ALSO.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/vioscsi.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/vioscsi.4
diff -u src/share/man/man4/vioscsi.4:1.1 src/share/man/man4/vioscsi.4:1.2
--- src/share/man/man4/vioscsi.4:1.1	Tue May 16 23:21:53 2017
+++ src/share/man/man4/vioscsi.4	Wed May 17 09:03:12 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: vioscsi.4,v 1.1 2017/05/16 23:21:53 jdolecek Exp $
+.\" $NetBSD: vioscsi.4,v 1.2 2017/05/17 09:03:12 wiz Exp $
 .\"
 .\" Copyright (c) 2017 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -39,9 +39,9 @@ driver provides support for
 .Xr virtio 4
 SCSI adapters.
 .Sh SEE ALSO
-.Xr virtio 4 ,
 .Xr scsi 4 ,
-.Xr sd 4
+.Xr sd 4 ,
+.Xr virtio 4
 .Sh HISTORY
 The
 .Nm



CVS commit: src/sys/opencrypto

2017-05-17 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed May 17 11:03:42 UTC 2017

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
fix cryptointr() can process unexpected request.

If migrate crp is linked after batch crp, "submit" is already set to
the batch crp. So, cryptointr() can process the batch crp instead of
the target migrate crp.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/opencrypto/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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.68 src/sys/opencrypto/crypto.c:1.69
--- src/sys/opencrypto/crypto.c:1.68	Wed May 17 07:12:50 2017
+++ src/sys/opencrypto/crypto.c	Wed May 17 11:03:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.68 2017/05/17 07:12:50 knakahara Exp $ */
+/*	$NetBSD: crypto.c,v 1.69 2017/05/17 11:03:42 knakahara Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.68 2017/05/17 07:12:50 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.69 2017/05/17 11:03:42 knakahara Exp $");
 
 #include 
 #include 
@@ -1262,8 +1262,7 @@ cryptointr(void)
 			cap = crypto_checkdriver(hid);
 			if (cap == NULL || cap->cc_process == NULL) {
 /* Op needs to be migrated, process it. */
-if (submit == NULL)
-	submit = crp;
+submit = crp;
 break;
 			}
 			if (!cap->cc_qblocked) {



CVS commit: src/sys/opencrypto

2017-05-17 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed May 17 11:04:38 UTC 2017

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
refactor cryptointr(), no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/opencrypto/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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.69 src/sys/opencrypto/crypto.c:1.70
--- src/sys/opencrypto/crypto.c:1.69	Wed May 17 11:03:42 2017
+++ src/sys/opencrypto/crypto.c	Wed May 17 11:04:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.69 2017/05/17 11:03:42 knakahara Exp $ */
+/*	$NetBSD: crypto.c,v 1.70 2017/05/17 11:04:38 knakahara Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.69 2017/05/17 11:03:42 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.70 2017/05/17 11:04:38 knakahara Exp $");
 
 #include 
 #include 
@@ -1265,26 +1265,30 @@ cryptointr(void)
 submit = crp;
 break;
 			}
-			if (!cap->cc_qblocked) {
-if (submit != NULL) {
-	/*
-	 * We stop on finding another op,
-	 * regardless whether its for the same
-	 * driver or not.  We could keep
-	 * searching the queue but it might be
-	 * better to just use a per-driver
-	 * queue instead.
-	 */
-	if (CRYPTO_SESID2HID(submit->crp_sid)
-	== hid)
-		hint = CRYPTO_HINT_MORE;
+
+			/*
+			 * skip blocked crp regardless of CRYPTO_F_BATCH
+			 */
+			if (cap->cc_qblocked != 0)
+continue;
+
+			if (submit != NULL) {
+/*
+ * We stop on finding another op,
+ * regardless whether its for the same
+ * driver or not.  We could keep
+ * searching the queue but it might be
+ * better to just use a per-driver
+ * queue instead.
+ */
+if (CRYPTO_SESID2HID(submit->crp_sid) == hid)
+	hint = CRYPTO_HINT_MORE;
+break;
+			} else {
+submit = crp;
+if ((submit->crp_flags & CRYPTO_F_BATCH) == 0)
 	break;
-} else {
-	submit = crp;
-	if ((submit->crp_flags & CRYPTO_F_BATCH) == 0)
-		break;
-	/* keep scanning for more are q'd */
-}
+/* keep scanning for more are q'd */
 			}
 		}
 		if (submit != NULL) {



CVS commit: src/sys/opencrypto

2017-05-17 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed May 17 12:11:41 UTC 2017

Modified Files:
src/sys/opencrypto: crypto.c

Log Message:
decrease the priority of batch crp even if there are more than one batch crp.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/opencrypto/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/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.70 src/sys/opencrypto/crypto.c:1.71
--- src/sys/opencrypto/crypto.c:1.70	Wed May 17 11:04:38 2017
+++ src/sys/opencrypto/crypto.c	Wed May 17 12:11:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.70 2017/05/17 11:04:38 knakahara Exp $ */
+/*	$NetBSD: crypto.c,v 1.71 2017/05/17 12:11:41 knakahara Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $	*/
 /*	$OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $	*/
 
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.70 2017/05/17 11:04:38 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.71 2017/05/17 12:11:41 knakahara Exp $");
 
 #include 
 #include 
@@ -1272,24 +1272,30 @@ cryptointr(void)
 			if (cap->cc_qblocked != 0)
 continue;
 
-			if (submit != NULL) {
-/*
- * We stop on finding another op,
- * regardless whether its for the same
- * driver or not.  We could keep
- * searching the queue but it might be
- * better to just use a per-driver
- * queue instead.
- */
-if (CRYPTO_SESID2HID(submit->crp_sid) == hid)
-	hint = CRYPTO_HINT_MORE;
-break;
-			} else {
-submit = crp;
-if ((submit->crp_flags & CRYPTO_F_BATCH) == 0)
-	break;
-/* keep scanning for more are q'd */
+			/*
+			 * skip batch crp until the end of crp_q
+			 */
+			if ((crp->crp_flags & CRYPTO_F_BATCH) != 0) {
+if (submit == NULL) {
+	submit = crp;
+} else {
+	if (CRYPTO_SESID2HID(submit->crp_sid)
+	== hid)
+		hint = CRYPTO_HINT_MORE;
+}
+
+continue;
 			}
+
+			/*
+			 * found first crp which is neither blocked nor batch.
+			 */
+			submit = crp;
+			/*
+			 * batch crp can be processed much later, so clear hint.
+			 */
+			hint = 0;
+			break;
 		}
 		if (submit != NULL) {
 			TAILQ_REMOVE(&crp_q, submit, crp_next);



CVS commit: src/sys/kern

2017-05-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed May 17 12:45:03 UTC 2017

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

Log Message:
Suspend file system while unmounting.  This way no operations run
on the mounted file system during unmount and all operations see
the state before or after the (possibly failed) unmount.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/vfs_mount.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/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.61 src/sys/kern/vfs_mount.c:1.62
--- src/sys/kern/vfs_mount.c:1.61	Sun May  7 08:26:58 2017
+++ src/sys/kern/vfs_mount.c	Wed May 17 12:45:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.61 2017/05/07 08:26:58 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.61 2017/05/07 08:26:58 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 hannken Exp $");
 
 #include 
 #include 
@@ -599,7 +599,7 @@ vflush(struct mount *mp, vnode_t *skipvp
 		 * First, flush out any vnode references from the
 		 * deferred vrele list.
 		 */
-		vfs_drainvnodes();
+		vrele_flush(mp);
 
 		vfs_vnode_iterator_init(mp, &marker);
 
@@ -875,6 +875,12 @@ dounmount(struct mount *mp, int flags, s
 	 */
 	mutex_enter(&syncer_mutex);
 
+	error = vfs_suspend(mp, 0);
+	if (error) {
+		mutex_exit(&syncer_mutex);
+		return error;
+	}
+
 	/*
 	 * Abort unmount attempt when the filesystem is in use
 	 */
@@ -882,6 +888,7 @@ dounmount(struct mount *mp, int flags, s
 	if (mp->mnt_busynest != 0) {
 		mutex_exit(&mp->mnt_unmounting);
 		mutex_exit(&syncer_mutex);
+		vfs_resume(mp);
 		return EBUSY;
 	}
 
@@ -933,6 +940,7 @@ dounmount(struct mount *mp, int flags, s
 			vfs_syncer_add_to_worklist(mp);
 		mp->mnt_flag |= async;
 		mutex_exit(&mp->mnt_updating);
+		vfs_resume(mp);
 		if (used_syncer)
 			mutex_exit(&syncer_mutex);
 		if (used_extattr) {
@@ -955,6 +963,7 @@ dounmount(struct mount *mp, int flags, s
 	 */
 	mp->mnt_iflag |= IMNT_GONE;
 	mutex_exit(&mp->mnt_unmounting);
+	vfs_resume(mp);
 
 	if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) {
 		vn_lock(coveredvp, LK_EXCLUSIVE | LK_RETRY);



CVS commit: src/sys/kern

2017-05-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed May 17 12:46:14 UTC 2017

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

Log Message:
Suspend file system while revoking a vnode.  This way no operations run
on the mounted file system during revoke and all operations see
the state before or after the revoke.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/kern/vfs_vnode.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/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.87 src/sys/kern/vfs_vnode.c:1.88
--- src/sys/kern/vfs_vnode.c:1.87	Mon Apr 17 08:32:01 2017
+++ src/sys/kern/vfs_vnode.c	Wed May 17 12:46:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.87 2017/04/17 08:32:01 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.88 2017/05/17 12:46:14 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.87 2017/04/17 08:32:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.88 2017/05/17 12:46:14 hannken Exp $");
 
 #include 
 #include 
@@ -950,31 +950,48 @@ vrecycle(vnode_t *vp)
 void
 vrevoke(vnode_t *vp)
 {
+	int error;
+	struct mount *mp;
 	vnode_t *vq;
 	enum vtype type;
 	dev_t dev;
 
 	KASSERT(vp->v_usecount > 0);
 
+	mp = vp->v_mount;
+	error = vfs_suspend(mp, 0);
+	KASSERT(error == 0 || error == EOPNOTSUPP);
+	if (error)
+		mp = NULL;
+
 	mutex_enter(vp->v_interlock);
 	VSTATE_WAIT_STABLE(vp);
 	if (VSTATE_GET(vp) == VS_RECLAIMED) {
 		mutex_exit(vp->v_interlock);
-		return;
 	} else if (vp->v_type != VBLK && vp->v_type != VCHR) {
 		atomic_inc_uint(&vp->v_usecount);
 		mutex_exit(vp->v_interlock);
 		vgone(vp);
-		return;
 	} else {
 		dev = vp->v_rdev;
 		type = vp->v_type;
 		mutex_exit(vp->v_interlock);
-	}
 
-	while (spec_node_lookup_by_dev(type, dev, &vq) == 0) {
-		vgone(vq);
+		while (spec_node_lookup_by_dev(type, dev, &vq) == 0) {
+			if (mp != vq->v_mount) {
+if (mp)
+	vfs_resume(mp);
+mp = vp->v_mount;
+error = vfs_suspend(mp, 0);
+KASSERT(error == 0 || error == EOPNOTSUPP);
+if (error)
+	mp = NULL;
+			}
+			vgone(vq);
+		}
 	}
+	if (mp)
+		vfs_resume(mp);
 }
 
 /*



CVS commit: src/sys/dev/usb

2017-05-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed May 17 14:15:29 UTC 2017

Modified Files:
src/sys/dev/usb: uts.c

Log Message:
fix tpyo


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/usb/uts.c

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

Modified files:

Index: src/sys/dev/usb/uts.c
diff -u src/sys/dev/usb/uts.c:1.6 src/sys/dev/usb/uts.c:1.7
--- src/sys/dev/usb/uts.c:1.6	Thu Apr  6 20:06:44 2017
+++ src/sys/dev/usb/uts.c	Wed May 17 14:15:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uts.c,v 1.6 2017/04/06 20:06:44 macallan Exp $	*/
+/*	$NetBSD: uts.c,v 1.7 2017/05/17 14:15:29 macallan Exp $	*/
 
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.6 2017/04/06 20:06:44 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.7 2017/05/17 14:15:29 macallan Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -212,7 +212,7 @@ uts_attach(device_t parent, device_t sel
 			 * valid data
 			 */
 			aprint_debug_dev(sc->sc_hdev.sc_dev,
-			"ELAN touchscreen found, workinmg around bug.\n");
+			"ELAN touchscreen found, working around bug.\n");
 		} else {
 			aprint_error_dev(sc->sc_hdev.sc_dev,
 			"touchscreen has no range report\n");



CVS commit: src/sys/dev/pci

2017-05-17 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed May 17 18:21:40 UTC 2017

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

Log Message:
do not set IFF_OACTIVE if dma map load or the virtio reserve fails;
this causes interface to ignore any further TX requests if this happens
when there are no other TX requests in progress

fixes kern/52211 by Juergen Hannken-Illjes


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/if_vioif.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_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.34 src/sys/dev/pci/if_vioif.c:1.35
--- src/sys/dev/pci/if_vioif.c:1.34	Tue Mar 28 04:10:33 2017
+++ src/sys/dev/pci/if_vioif.c	Wed May 17 18:21:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.34 2017/03/28 04:10:33 ozaki-r Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.35 2017/05/17 18:21:40 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.34 2017/03/28 04:10:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.35 2017/05/17 18:21:40 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -844,7 +844,6 @@ retry:
 		if (r != 0) {
 			bus_dmamap_unload(virtio_dmat(vsc),
 	  sc->sc_tx_dmamaps[slot]);
-			ifp->if_flags |= IFF_OACTIVE;
 			vioif_tx_vq_done_locked(vq);
 			if (retry++ == 0)
 goto retry;
@@ -868,10 +867,8 @@ retry:
 		bpf_mtap(ifp, m);
 	}
 
-	if (m != NULL) {
-		ifp->if_flags |= IFF_OACTIVE;
+	if (m != NULL)
 		m_freem(m);
-	}
 
 	if (queued > 0) {
 		virtio_enqueue_commit(vsc, vq, -1, true);



CVS commit: src/usr.sbin/npf/npftest

2017-05-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 17 18:55:13 UTC 2017

Modified Files:
src/usr.sbin/npf/npftest: npftest.c

Log Message:
set "testing mode" for ioctl I/O


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/npf/npftest/npftest.c

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

Modified files:

Index: src/usr.sbin/npf/npftest/npftest.c
diff -u src/usr.sbin/npf/npftest/npftest.c:1.20 src/usr.sbin/npf/npftest/npftest.c:1.21
--- src/usr.sbin/npf/npftest/npftest.c:1.20	Mon Dec 26 18:05:05 2016
+++ src/usr.sbin/npf/npftest/npftest.c	Wed May 17 14:55:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: npftest.c,v 1.20 2016/12/26 23:05:05 christos Exp $	*/
+/*	$NetBSD: npftest.c,v 1.21 2017/05/17 18:55:13 christos Exp $	*/
 
 /*
  * NPF testing framework.
@@ -195,6 +195,8 @@ npf_kern_fini(void)
 #endif
 }
 
+extern int rumpns_npfctl_testing;
+
 int
 main(int argc, char **argv)
 {
@@ -276,6 +278,7 @@ main(int argc, char **argv)
 	/*
 	 * Initialise the NPF kernel component.
 	 */
+	rumpns_npfctl_testing = 1;
 	npf_kern_init();
 	rumpns_npf_test_init(inet_pton, inet_ntop, random);
 



CVS commit: src/sys/net/npf

2017-05-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 17 18:56:12 UTC 2017

Modified Files:
src/sys/net/npf: npf_ctl.c

Log Message:
Allow npf to be used "normally" from a rump kernel, not just from the
test harness (problem reported by Frank Kardel)


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/net/npf/npf_ctl.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/npf/npf_ctl.c
diff -u src/sys/net/npf/npf_ctl.c:1.47 src/sys/net/npf/npf_ctl.c:1.48
--- src/sys/net/npf/npf_ctl.c:1.47	Sat Jan 28 19:15:54 2017
+++ src/sys/net/npf/npf_ctl.c	Wed May 17 14:56:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_ctl.c,v 1.47 2017/01/29 00:15:54 christos Exp $	*/
+/*	$NetBSD: npf_ctl.c,v 1.48 2017/05/17 18:56:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.47 2017/01/29 00:15:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.48 2017/05/17 18:56:12 christos Exp $");
 
 #include 
 #include 
@@ -491,6 +491,10 @@ npf_mk_connlist(npf_t *npf, prop_array_t
 	return error;
 }
 
+#if defined(_NPF_TESTING) || defined(_NPF_STANDALONE)
+int npfctl_testing;
+#endif
+
 /*
  * npfctl_load: store passed data i.e. update settings, create passed
  * tables, rules and atomically activate all them.
@@ -512,14 +516,17 @@ npfctl_load(npf_t *npf, u_long cmd, void
 	int error;
 
 	/* Retrieve the dictionary. */
-#if !defined(_NPF_TESTING) && !defined(_NPF_STANDALONE)
-	error = prop_dictionary_copyin_ioctl_size(pref, cmd, &npf_dict,
-	4 * 1024 * 1024);
-	if (error)
-		return error;
-#else
-	npf_dict = (prop_dictionary_t)pref;
+#if defined(_NPF_TESTING) || defined(_NPF_STANDALONE)
+	if (npfctl_testing)
+		npf_dict = (prop_dictionary_t)pref;
+	else
 #endif
+	{
+		error = prop_dictionary_copyin_ioctl_size(pref, cmd, &npf_dict,
+		4 * 1024 * 1024);
+		if (error)
+		return error;
+	}
 
 	/* Dictionary for error reporting and version check. */
 	errdict = prop_dictionary_create();



CVS commit: src/sys/dev/pci

2017-05-17 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed May 17 20:04:50 UTC 2017

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

Log Message:
simplify vioif_start() - remove the delivery attempts on failure and retries,
leave that for the dedicated thread

if dma map load fails, retry after m_defrag(), but continue processing
other queue items regardless

set interface queue length according to the length of virtio queue, so that
higher layer won't queue more than interface can manage to keep in flight

use the mutexes always, not just with NET_MPSAFE, so they continue
being exercised and hence working; they also enforce proper IPL level

inspired by discussion around PR kern/52211, thanks to Masanobu SAITOH
for the m_defrag() idea and code


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/if_vioif.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_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.35 src/sys/dev/pci/if_vioif.c:1.36
--- src/sys/dev/pci/if_vioif.c:1.35	Wed May 17 18:21:40 2017
+++ src/sys/dev/pci/if_vioif.c	Wed May 17 20:04:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.35 2017/05/17 18:21:40 jdolecek Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.36 2017/05/17 20:04:50 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.35 2017/05/17 18:21:40 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.36 2017/05/17 20:04:50 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -226,8 +226,8 @@ struct vioif_softc {
 	}			sc_ctrl_inuse;
 	kcondvar_t		sc_ctrl_wait;
 	kmutex_t		sc_ctrl_wait_lock;
-	kmutex_t		*sc_tx_lock;
-	kmutex_t		*sc_rx_lock;
+	kmutex_t		sc_tx_lock;
+	kmutex_t		sc_rx_lock;
 	bool			sc_stopping;
 
 	bool			sc_has_ctrl;
@@ -235,12 +235,12 @@ struct vioif_softc {
 #define VIRTIO_NET_TX_MAXNSEGS		(16) /* XXX */
 #define VIRTIO_NET_CTRL_MAC_MAXENTRIES	(64) /* XXX */
 
-#define VIOIF_TX_LOCK(_sc)	if ((_sc)->sc_tx_lock) mutex_enter((_sc)->sc_tx_lock)
-#define VIOIF_TX_UNLOCK(_sc)	if ((_sc)->sc_tx_lock) mutex_exit((_sc)->sc_tx_lock)
-#define VIOIF_TX_LOCKED(_sc)	(!(_sc)->sc_tx_lock || mutex_owned((_sc)->sc_tx_lock))
-#define VIOIF_RX_LOCK(_sc)	if ((_sc)->sc_rx_lock) mutex_enter((_sc)->sc_rx_lock)
-#define VIOIF_RX_UNLOCK(_sc)	if ((_sc)->sc_rx_lock) mutex_exit((_sc)->sc_rx_lock)
-#define VIOIF_RX_LOCKED(_sc)	(!(_sc)->sc_rx_lock || mutex_owned((_sc)->sc_rx_lock))
+#define VIOIF_TX_LOCK(_sc)	mutex_enter(&(_sc)->sc_tx_lock)
+#define VIOIF_TX_UNLOCK(_sc)	mutex_exit(&(_sc)->sc_tx_lock)
+#define VIOIF_TX_LOCKED(_sc)	mutex_owned(&(_sc)->sc_tx_lock)
+#define VIOIF_RX_LOCK(_sc)	mutex_enter(&(_sc)->sc_rx_lock)
+#define VIOIF_RX_UNLOCK(_sc)	mutex_exit(&(_sc)->sc_rx_lock)
+#define VIOIF_RX_LOCKED(_sc)	mutex_owned(&(_sc)->sc_rx_lock)
 
 /* cfattach interface functions */
 static int	vioif_match(device_t, cfdata_t, void *);
@@ -439,7 +439,7 @@ vioif_alloc_mems(struct vioif_softc *sc)
 		C_L1(txhdr_dmamaps[i], tx_hdrs[i],
 		sizeof(struct virtio_net_hdr), 1,
 		WRITE, "tx header");
-		C(tx_dmamaps[i], NULL, ETHER_MAX_LEN, 16 /* XXX */, 0,
+		C(tx_dmamaps[i], NULL, ETHER_MAX_LEN, VIRTIO_NET_TX_MAXNSEGS, 0,
 		  "tx payload");
 	}
 
@@ -592,13 +592,8 @@ vioif_attach(device_t parent, device_t s
 
 	aprint_normal_dev(self, "Ethernet address %s\n", ether_sprintf(sc->sc_mac));
 
-#ifdef VIOIF_MPSAFE
-	sc->sc_tx_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
-	sc->sc_rx_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
-#else
-	sc->sc_tx_lock = NULL;
-	sc->sc_rx_lock = NULL;
-#endif
+	mutex_init(&sc->sc_tx_lock, MUTEX_DEFAULT, IPL_NET);
+	mutex_init(&sc->sc_rx_lock, MUTEX_DEFAULT, IPL_NET);
 	sc->sc_stopping = false;
 
 	/*
@@ -680,6 +675,8 @@ skip:
 	ifp->if_stop = vioif_stop;
 	ifp->if_capabilities = 0;
 	ifp->if_watchdog = vioif_watchdog;
+	IFQ_SET_MAXLEN(&ifp->if_snd, MAX(sc->sc_vq[VQ_TX].vq_num, IFQ_MAXLEN));
+	IFQ_SET_READY(&ifp->if_snd);
 
 	sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
 
@@ -690,10 +687,8 @@ skip:
 	return;
 
 err:
-	if (sc->sc_tx_lock)
-		mutex_obj_free(sc->sc_tx_lock);
-	if (sc->sc_rx_lock)
-		mutex_obj_free(sc->sc_rx_lock);
+	mutex_destroy(&sc->sc_tx_lock);
+	mutex_destroy(&sc->sc_rx_lock);
 
 	if (sc->sc_has_ctrl) {
 		cv_destroy(&sc->sc_ctrl_wait);
@@ -799,7 +794,7 @@ vioif_start(struct ifnet *ifp)
 	struct virtio_softc *vsc = sc->sc_virtio;
 	struct virtqueue *vq = &sc->sc_vq[VQ_TX];
 	struct mbuf *m;
-	int queued = 0, retry = 0;
+	int queued = 0;
 
 	VIOIF_TX_LOCK(sc);
 
@@ -814,41 +809,58 @@ vioif_start(struct ifnet *ifp)
 		int slot, r;
 
 		IFQ_DEQUEUE(&ifp->if_snd, m);
-
 		if (m == NULL)
 			break;
 
-retry:
 		r = virtio_enqueue_prep(vsc, vq, &slot);
 		if (r == EAGAIN) {
 			ifp->if_flags |= IFF_OACTIVE;
-			vioif_tx_vq_done_locked(vq);
-			if (retry++ == 0)
-goto retry;
-			else
-break;
+			m_fr

CVS commit: src/sys/dev/pci

2017-05-17 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed May 17 20:13:02 UTC 2017

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

Log Message:
more precise m_freem() on error paths, and update m after the m_defrag() call


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/pci/if_vioif.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_vioif.c
diff -u src/sys/dev/pci/if_vioif.c:1.36 src/sys/dev/pci/if_vioif.c:1.37
--- src/sys/dev/pci/if_vioif.c:1.36	Wed May 17 20:04:50 2017
+++ src/sys/dev/pci/if_vioif.c	Wed May 17 20:13:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vioif.c,v 1.36 2017/05/17 20:04:50 jdolecek Exp $	*/
+/*	$NetBSD: if_vioif.c,v 1.37 2017/05/17 20:13:02 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.36 2017/05/17 20:04:50 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.37 2017/05/17 20:13:02 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -832,19 +832,19 @@ vioif_start(struct ifnet *ifp)
 			if (newm == NULL) {
 aprint_error_dev(sc->sc_dev,
 "m_defrag() failed\n");
-m_freem(m);
 goto skip;
 			}
 
+			m = newm;
 			r = bus_dmamap_load_mbuf(virtio_dmat(vsc),
 	 sc->sc_tx_dmamaps[slot],
-	 newm, BUS_DMA_WRITE|BUS_DMA_NOWAIT);
+	 m, BUS_DMA_WRITE|BUS_DMA_NOWAIT);
 			if (r != 0) {
 aprint_error_dev(sc->sc_dev,
 	   			"tx dmamap load failed, error code %d\n",
 r);
-m_freem(newm);
 skip:
+m_freem(m);
 virtio_enqueue_abort(vsc, vq, slot);
 continue;
 			}
@@ -860,6 +860,7 @@ skip:
 			bus_dmamap_unload(virtio_dmat(vsc),
 	  sc->sc_tx_dmamaps[slot]);
 			/* slot already freed by virtio_enqueue_reserve */
+			m_freem(m);
 			continue;
 		}
 



CVS commit: src/external/gpl3/gcc/dist/gcc

2017-05-17 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Wed May 17 22:06:10 UTC 2017

Modified Files:
src/external/gpl3/gcc/dist/gcc: auto-profile.c
graphite-isl-ast-to-gimple.c system.h

Log Message:
Fix building GCC 5 with clang 4.0
Obtained from FreeBSD ports r432958
https://svnweb.freebsd.org/ports?view=revision&revision=432958
"doesn't compile with recent versions of libc++, because it attempts to 
redefine abort():
/usr/include/c++/v1/functional:1398:2: error: no member named 'fancy_abort' in 
namespace 'std::__1'; did you mean simply 'fancy_abort'?
_VSTD::abort();
^~~
/usr/include/c++/v1/__config:383:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE"


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/gpl3/gcc/dist/gcc/auto-profile.c \
src/external/gpl3/gcc/dist/gcc/graphite-isl-ast-to-gimple.c
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/dist/gcc/system.h

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

Modified files:

Index: src/external/gpl3/gcc/dist/gcc/auto-profile.c
diff -u src/external/gpl3/gcc/dist/gcc/auto-profile.c:1.1.1.1 src/external/gpl3/gcc/dist/gcc/auto-profile.c:1.2
--- src/external/gpl3/gcc/dist/gcc/auto-profile.c:1.1.1.1	Sun Jan 24 06:06:05 2016
+++ src/external/gpl3/gcc/dist/gcc/auto-profile.c	Wed May 17 22:06:10 2017
@@ -19,11 +19,11 @@ along with GCC; see the file COPYING3.  
 .  */
 
 #include "config.h"
-#include "system.h"
 
 #include 
 #include 
 #include 
+#include "system.h"
 
 #include "coretypes.h"
 #include "hash-set.h"
Index: src/external/gpl3/gcc/dist/gcc/graphite-isl-ast-to-gimple.c
diff -u src/external/gpl3/gcc/dist/gcc/graphite-isl-ast-to-gimple.c:1.1.1.1 src/external/gpl3/gcc/dist/gcc/graphite-isl-ast-to-gimple.c:1.2
--- src/external/gpl3/gcc/dist/gcc/graphite-isl-ast-to-gimple.c:1.1.1.1	Sun Jan 24 06:06:08 2016
+++ src/external/gpl3/gcc/dist/gcc/graphite-isl-ast-to-gimple.c	Wed May 17 22:06:10 2017
@@ -38,6 +38,7 @@ extern "C" {
 #endif
 #endif
 
+#include 
 #include "system.h"
 #include "coretypes.h"
 #include "hash-set.h"
@@ -75,7 +76,6 @@ extern "C" {
 #include "tree-scalar-evolution.h"
 #include "gimple-ssa.h"
 #include "tree-into-ssa.h"
-#include 
 
 #ifdef HAVE_isl
 #include "graphite-poly.h"

Index: src/external/gpl3/gcc/dist/gcc/system.h
diff -u src/external/gpl3/gcc/dist/gcc/system.h:1.4 src/external/gpl3/gcc/dist/gcc/system.h:1.5
--- src/external/gpl3/gcc/dist/gcc/system.h:1.4	Sun Jan 24 09:43:31 2016
+++ src/external/gpl3/gcc/dist/gcc/system.h	Wed May 17 22:06:10 2017
@@ -224,6 +224,7 @@ extern int errno;
 #ifdef __cplusplus
 # include 
 # include 
+# include 
 # include 
 #endif
 #endif



CVS commit: src/sys/uvm

2017-05-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 17 22:43:12 UTC 2017

Modified Files:
src/sys/uvm: uvm_extern.h

Log Message:
snprintb(3) for UVM_FLAGS.


To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/sys/uvm/uvm_extern.h

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

Modified files:

Index: src/sys/uvm/uvm_extern.h
diff -u src/sys/uvm/uvm_extern.h:1.204 src/sys/uvm/uvm_extern.h:1.205
--- src/sys/uvm/uvm_extern.h:1.204	Sat May  6 17:34:52 2017
+++ src/sys/uvm/uvm_extern.h	Wed May 17 18:43:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_extern.h,v 1.204 2017/05/06 21:34:52 joerg Exp $	*/
+/*	$NetBSD: uvm_extern.h,v 1.205 2017/05/17 22:43:12 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -132,6 +132,48 @@
 #define UVM_FLAG_VAONLY  0x200 /* unmap: no pages are mapped */
 #define UVM_FLAG_COLORMATCH 0x400 /* match color given in off */
 
+#define UVM_FLAG_BITS "\177\020\
+F\0\3\
+:\0PROT=NONE\0\
+:\1PROT=R\0\
+:\2PROT=W\0\
+:\3PROT=RW\0\
+:\4PROT=X\0\
+:\5PROT=RX\0\
+:\6PROT=WX\0\
+:\7PROT=RWX\0\
+F\4\2\
+:\0INH=SHARE\0\
+:\1INH=COPY\0\
+:\2INH=NONE\0\
+:\3INH=DONATE\0\
+F\10\3\
+:\0MAXPROT=NONE\0\
+:\1MAXPROT=R\0\
+:\2MAXPROT=W\0\
+:\3MAXPROT=RW\0\
+:\4MAXPROT=X\0\
+:\5MAXPROT=RX\0\
+:\6MAXPROT=WX\0\
+:\7MAXPROT=RWX\0\
+F\14\3\
+:\0ADV=NORMAL\0\
+:\1ADV=RANDOM\0\
+:\2ADV=SEQUENTIAL\0\
+:\3ADV=WILLNEED\0\
+:\4ADV=DONTNEED\0\
+:\5ADV=NOREUSE\0\
+b\20FIXED\0\
+b\21OVERLAY\0\
+b\22NOMERGE\0\
+b\23COPYONW\0\
+b\24AMAPPAD\0\
+b\25TRYLOCK\0\
+b\26NOWAIT\0\
+b\27WAITVA\0\
+b\30VAONLY\0\
+b\31COLORMATCH\0"
+
 /* macros to extract info */
 #define UVM_PROTECTION(X)	((X) & UVM_PROT_MASK)
 #define UVM_INHERIT(X)		(((X) & UVM_INH_MASK) >> 4)



CVS commit: src/sys/dev/pci

2017-05-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu May 18 01:32:46 UTC 2017

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

Log Message:
Fixed m is not freed if m_defrag() fails.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/if_rtwn.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_rtwn.c
diff -u src/sys/dev/pci/if_rtwn.c:1.11 src/sys/dev/pci/if_rtwn.c:1.12
--- src/sys/dev/pci/if_rtwn.c:1.11	Thu Feb  2 10:05:35 2017
+++ src/sys/dev/pci/if_rtwn.c	Thu May 18 01:32:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_rtwn.c,v 1.11 2017/02/02 10:05:35 nonaka Exp $	*/
+/*	$NetBSD: if_rtwn.c,v 1.12 2017/05/18 01:32:46 nonaka Exp $	*/
 /*	$OpenBSD: if_rtwn.c,v 1.5 2015/06/14 08:02:47 stsp Exp $	*/
 #define	IEEE80211_NO_HT
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.11 2017/02/02 10:05:35 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.12 2017/05/18 01:32:46 nonaka Exp $");
 
 #include 
 #include 
@@ -1957,10 +1957,13 @@ rtwn_tx(struct rtwn_softc *sc, struct mb
 	}
 	if (error != 0) {
 		/* Too many DMA segments, linearize mbuf. */
-		if ((m = m_defrag(m, M_DONTWAIT)) == NULL) {
+		struct mbuf *newm = m_defrag(m, M_DONTWAIT);
+		if (newm == NULL) {
 			aprint_error_dev(sc->sc_dev, "can't defrag mbuf\n");
+			m_freem(m);
 			return ENOBUFS;
 		}
+		m = newm;
 
 		error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m,
 		BUS_DMA_NOWAIT | BUS_DMA_WRITE);



CVS commit: src/sys/uvm

2017-05-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 18 02:21:05 UTC 2017

Modified Files:
src/sys/uvm: uvm_map.h

Log Message:
more snprintb bits


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/uvm/uvm_map.h

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

Modified files:

Index: src/sys/uvm/uvm_map.h
diff -u src/sys/uvm/uvm_map.h:1.73 src/sys/uvm/uvm_map.h:1.74
--- src/sys/uvm/uvm_map.h:1.73	Wed May 25 13:43:58 2016
+++ src/sys/uvm/uvm_map.h	Wed May 17 22:21:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.h,v 1.73 2016/05/25 17:43:58 christos Exp $	*/
+/*	$NetBSD: uvm_map.h,v 1.74 2017/05/18 02:21:05 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -238,6 +238,13 @@ struct vm_map {
 #define	VM_MAP_TOPDOWN		0x40		/* ro: arrange map top-down */
 #define	VM_MAP_WANTVA		0x100		/* rw: want va */
 
+#define VM_MAP_BITS	"\177\020\
+b\0PAGEABLE\0\
+b\2WIREFUTURE\0\
+b\5DYING\0\
+b\6TOPDOWN\0\
+b\10WANTVA\0"
+
 #ifdef _KERNEL
 struct uvm_map_args {
 	struct vm_map_entry *uma_prev;



CVS commit: src/sys/netinet

2017-05-17 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu May 18 06:33:11 UTC 2017

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

Log Message:
Lookup caches from a CARP interface if the packet is routed to the interface

This fixes CARP setups without carpdev (physical interface) having any IPs.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/sys/netinet/if_arp.c

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

Modified files:

Index: src/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.249 src/sys/netinet/if_arp.c:1.250
--- src/sys/netinet/if_arp.c:1.249	Fri May 12 17:53:53 2017
+++ src/sys/netinet/if_arp.c	Thu May 18 06:33:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.249 2017/05/12 17:53:53 ryo Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.250 2017/05/18 06:33:11 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.249 2017/05/12 17:53:53 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.250 2017/05/18 06:33:11 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -720,6 +720,11 @@ arpresolve(struct ifnet *ifp, const stru
 	const char *create_lookup;
 	bool renew;
 	int error;
+	struct ifnet *origifp = ifp;
+#if NCARP > 0
+	if (rt != NULL && rt->rt_ifp->if_type == IFT_CARP)
+		ifp = rt->rt_ifp;
+#endif
 
 	KASSERT(m != NULL);
 
@@ -796,12 +801,8 @@ notfound:
 
 		if (renew) {
 			const u_int8_t *enaddr =
-#if NCARP > 0
-			(ifp->if_type == IFT_CARP) ?
-			CLLADDR(ifp->if_sadl):
-#endif
 			CLLADDR(ifp->if_sadl);
-			arprequest(ifp,
+			arprequest(origifp,
 			&satocsin(rt->rt_ifa->ifa_addr)->sin_addr,
 			&satocsin(dst)->sin_addr, enaddr);
 		}
@@ -861,10 +862,6 @@ notfound:
 
 	if (renew) {
 		const u_int8_t *enaddr =
-#if NCARP > 0
-		(rt != NULL && rt->rt_ifp->if_type == IFT_CARP) ?
-		CLLADDR(rt->rt_ifp->if_sadl):
-#endif
 		CLLADDR(ifp->if_sadl);
 		la->la_expire = time_uptime;
 		arp_settimer(la, arpt_down);
@@ -872,7 +869,8 @@ notfound:
 		LLE_WUNLOCK(la);
 
 		if (rt != NULL) {
-			arprequest(ifp, &satocsin(rt->rt_ifa->ifa_addr)->sin_addr,
+			arprequest(origifp,
+			&satocsin(rt->rt_ifa->ifa_addr)->sin_addr,
 			&satocsin(dst)->sin_addr, enaddr);
 		} else {
 			struct sockaddr_in sin;
@@ -884,7 +882,7 @@ notfound:
 			_rt = rtalloc1((struct sockaddr *)&sin, 0);
 			if (_rt == NULL)
 goto bad;
-			arprequest(ifp,
+			arprequest(origifp,
 			&satocsin(_rt->rt_ifa->ifa_addr)->sin_addr,
 			&satocsin(dst)->sin_addr, enaddr);
 			rt_unref(_rt);



CVS commit: src/tests/net/carp

2017-05-17 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu May 18 06:33:49 UTC 2017

Modified Files:
src/tests/net/carp: t_basic.sh

Log Message:
Reduce duplicated codes (DRY)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/net/carp/t_basic.sh

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

Modified files:

Index: src/tests/net/carp/t_basic.sh
diff -u src/tests/net/carp/t_basic.sh:1.4 src/tests/net/carp/t_basic.sh:1.5
--- src/tests/net/carp/t_basic.sh:1.4	Mon Feb 27 08:26:53 2017
+++ src/tests/net/carp/t_basic.sh	Thu May 18 06:33:49 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: t_basic.sh,v 1.4 2017/02/27 08:26:53 ozaki-r Exp $
+#	$NetBSD: t_basic.sh,v 1.5 2017/05/18 06:33:49 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -31,21 +31,7 @@ SOCK_BACKUP=unix://carp_backup
 BUS=bus_carp
 TIMEOUT=3
 
-atf_test_case carp_handover_halt cleanup
-carp_handover_head()
-{
-
-	atf_set "descr" "Tests for CARP handover on halt"
-	atf_set "require.progs" "rump_server"
-}
-
-atf_test_case carp_handover_ifdown cleanup
-carp_handover_head()
-{
-
-	atf_set "descr" "Tests for CARP handover on ifconfig down"
-	atf_set "require.progs" "rump_server"
-}
+DEBUG=${DEBUG:-false}
 
 IP_CLIENT=10.1.1.240
 IP_MASTER=10.1.1.1
@@ -103,7 +89,7 @@ wait_handover()
 	fi
 }
 
-test_carp_handover()
+test_carp_handover_ipv4()
 {
 	local op=$1
 
@@ -172,48 +158,6 @@ test_carp_handover()
 	fi
 }
 
-carp_handover_halt_body()
-{
-
-	test_carp_handover halt
-}
-
-carp_handover_ifdown_body()
-{
-
-	test_carp_handover ifdown
-}
-
-carp_handover_halt_cleanup()
-{
-
-	$DEBUG && dump
-	cleanup
-}
-
-carp_handover_ifdown_cleanup()
-{
-
-	$DEBUG && dump
-	cleanup
-}
-
-atf_test_case carp6_handover_halt cleanup
-carp6_handover_halt_head()
-{
-
-	atf_set "descr" "Tests for CARP handover on halt (IPv6)"
-	atf_set "require.progs" "rump_server"
-}
-
-atf_test_case carp6_handover_ifdown cleanup
-carp6_handover_ifdown_head()
-{
-
-	atf_set "descr" "Tests for CARP handover on ifconfig down (IPv6)"
-	atf_set "require.progs" "rump_server"
-}
-
 IP6_CLIENT=fd00:1::240
 IP6_MASTER=fd00:1::1
 IP6_BACKUP=fd00:1::2
@@ -269,7 +213,7 @@ wait_carp6_handover()
 	fi
 }
 
-test_carp6_handover()
+test_carp_handover_ipv6()
 {
 	local op=$1
 
@@ -338,37 +282,41 @@ test_carp6_handover()
 	fi
 }
 
-carp6_handover_halt_body()
+add_test_case()
 {
+	local ipproto=$1
+	local halt=$2
 
-	test_carp6_handover halt
-}
+	name="carp_handover_${ipproto}_${halt}"
+	desc="Tests for CARP (${ipproto}) handover on ${halt}"
 
-carp6_handover_ifdown_body()
-{
-
-	test_carp6_handover ifdown
-}
-
-carp6_handover_halt_cleanup()
-{
-
-	$DEBUG && dump
-	cleanup
-}
-
-carp6_handover_ifdown_cleanup()
-{
-
-	$DEBUG && dump
-	cleanup
+	atf_test_case ${name} cleanup
+	eval "			\
+	${name}_head() {	\
+	atf_set \"descr\" \"$desc\";			\
+	atf_set \"require.progs\" \"rump_server\";	\
+	};			\
+	${name}_body() {	\
+	test_carp_handover_${ipproto} $halt;		\
+	if [ $halt != halt ]; then			\
+	 rump_server_destroy_ifaces;		\
+	fi		\
+	};			\
+	${name}_cleanup() {	\
+	$DEBUG && dump;	\
+	cleanup;	\
+	}			\
+	"
+	atf_add_test_case ${name}
 }
 
 atf_init_test_cases()
 {
+	local proto= halt=
 
-	atf_add_test_case carp_handover_halt
-	atf_add_test_case carp_handover_ifdown
-	atf_add_test_case carp6_handover_halt
-	atf_add_test_case carp6_handover_ifdown
+	for proto in ipv4 ipv6; do
+		for halt in halt ifdown; do
+			add_test_case $proto $halt
+		done
+	done
 }



CVS commit: src/tests/net/carp

2017-05-17 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu May 18 06:34:48 UTC 2017

Modified Files:
src/tests/net/carp: t_basic.sh

Log Message:
Test CARP handover on setups without having IPs on carpdev (shmif)

Note that tests for IPv6 don't pass yet; nd6 needs to handle CARP
correctly like arp does.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/net/carp/t_basic.sh

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

Modified files:

Index: src/tests/net/carp/t_basic.sh
diff -u src/tests/net/carp/t_basic.sh:1.5 src/tests/net/carp/t_basic.sh:1.6
--- src/tests/net/carp/t_basic.sh:1.5	Thu May 18 06:33:49 2017
+++ src/tests/net/carp/t_basic.sh	Thu May 18 06:34:48 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: t_basic.sh,v 1.5 2017/05/18 06:33:49 ozaki-r Exp $
+#	$NetBSD: t_basic.sh,v 1.6 2017/05/18 06:34:48 ozaki-r Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -42,6 +42,7 @@ setup_carp()
 {
 	local sock=$1
 	local master=$2
+	local carpdevip=$3
 	local carpif= ip= advskew=
 
 	if $master; then
@@ -60,10 +61,17 @@ setup_carp()
 		rump.sysctl -w net.inet.carp.log=1
 	fi
 	atf_check -s exit:0 rump.ifconfig $carpif create
-	atf_check -s exit:0 rump.ifconfig shmif0 $ip/24 up
-	atf_check -s exit:0 rump.ifconfig $carpif \
-	vhid 175 advskew $advskew advbase 1 pass s3cret \
-	$IP_CARP netmask 255.255.255.0
+	if [ $carpdevip = yes ]; then
+		atf_check -s exit:0 rump.ifconfig shmif0 $ip/24 up
+		atf_check -s exit:0 rump.ifconfig $carpif \
+		vhid 175 advskew $advskew advbase 1 pass s3cret \
+		$IP_CARP netmask 255.255.255.0
+	else
+		atf_check -s exit:0 rump.ifconfig shmif0 up
+		atf_check -s exit:0 rump.ifconfig $carpif \
+		vhid 175 advskew $advskew advbase 1 pass s3cret \
+		carpdev shmif0 $IP_CARP netmask 255.255.255.0
+	fi
 	atf_check -s exit:0 rump.ifconfig -w 10
 }
 
@@ -92,6 +100,7 @@ wait_handover()
 test_carp_handover_ipv4()
 {
 	local op=$1
+	local carpdevip=$2
 
 	rump_server_start $SOCK_CLIENT
 	rump_server_start $SOCK_MASTER
@@ -101,18 +110,20 @@ test_carp_handover_ipv4()
 	rump_server_add_iface $SOCK_MASTER shmif0 $BUS
 	rump_server_add_iface $SOCK_BACKUP shmif0 $BUS
 
-	setup_carp $SOCK_MASTER true
-	setup_carp $SOCK_BACKUP false
+	setup_carp $SOCK_MASTER true $carpdevip
+	setup_carp $SOCK_BACKUP false $carpdevip
 
 	export RUMP_SERVER=$SOCK_CLIENT
 	atf_check -s exit:0 rump.ifconfig shmif0 $IP_CLIENT/24 up
 	atf_check -s exit:0 rump.ifconfig -w 10
 
-	# Check that the primary addresses are up
-	atf_check -s exit:0 -o ignore \
-	rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
-	atf_check -s exit:0 -o ignore \
-	rump.ping -n -w $TIMEOUT -c 1 $IP_BACKUP
+	if [ $carpdevip = yes ]; then
+		# Check that the primary addresses are up
+		atf_check -s exit:0 -o ignore \
+		rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
+		atf_check -s exit:0 -o ignore \
+		rump.ping -n -w $TIMEOUT -c 1 $IP_BACKUP
+	fi
 
 	# Give carp a while to croak
 	sleep 4
@@ -141,8 +152,12 @@ test_carp_handover_ipv4()
 	sleep 1
 
 	# Check that primary is now dead
-	atf_check -s not-exit:0 -o ignore \
-	rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
+	if [ $carpdevip = yes ]; then
+		atf_check -s not-exit:0 -o ignore \
+		rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
+	else
+		# XXX how to check?
+	fi
 
 	# Do it in installments. carp will cluck meanwhile
 	wait_handover
@@ -167,6 +182,7 @@ setup_carp6()
 {
 	local sock=$1
 	local master=$2
+	local carpdevip=$3
 	local carpif= ip= advskew=
 
 	if $master; then
@@ -185,9 +201,16 @@ setup_carp6()
 		rump.sysctl -w net.inet.carp.log=1
 	fi
 	atf_check -s exit:0 rump.ifconfig $carpif create
-	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip up
-	atf_check -s exit:0 rump.ifconfig $carpif inet6 \
-	vhid 175 advskew $advskew advbase 1 pass s3cret $IP6_CARP
+	if [ $carpdevip = yes ]; then
+		atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip up
+		atf_check -s exit:0 rump.ifconfig $carpif inet6 \
+		vhid 175 advskew $advskew advbase 1 pass s3cret $IP6_CARP
+	else
+		atf_check -s exit:0 rump.ifconfig shmif0 up
+		atf_check -s exit:0 rump.ifconfig $carpif inet6 \
+		vhid 175 advskew $advskew advbase 1 pass s3cret \
+		carpdev shmif0 $IP6_CARP
+	fi
 	atf_check -s exit:0 rump.ifconfig -w 10
 }
 
@@ -216,6 +239,7 @@ wait_carp6_handover()
 test_carp_handover_ipv6()
 {
 	local op=$1
+	local carpdevip=$2
 
 	rump_server_start $SOCK_CLIENT netinet6
 	rump_server_start $SOCK_MASTER netinet6
@@ -225,18 +249,20 @@ test_carp_handover_ipv6()
 	rump_server_add_iface $SOCK_MASTER shmif0 $BUS
 	rump_server_add_iface $SOCK_BACKUP shmif0 $BUS
 
-	setup_carp6 $SOCK_MASTER true
-	setup_carp6 $SOCK_BACKUP false
+	setup_carp6 $SOCK_MASTER true $carpdevip
+	setup_carp6 $SOCK_BACKUP false $carpdevip
 
 	export RUMP_SERVER=$SOCK_CLIENT
 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_CLIENT up
 	atf_check -s exit:0 rump.ifconfig -w 10
 
-	# C