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

2017-02-28 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Mar  1 03:02:48 UTC 2017

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

Log Message:
tzdata2017a: new timezone America/Punta_Arenas


To generate a diff of this commit:
cvs rdiff -u -r1.1154 -r1.1155 src/distrib/sets/lists/base/mi

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

Modified files:

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1154 src/distrib/sets/lists/base/mi:1.1155
--- src/distrib/sets/lists/base/mi:1.1154	Tue Feb 14 01:12:02 2017
+++ src/distrib/sets/lists/base/mi	Wed Mar  1 03:02:48 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1154 2017/02/14 01:12:02 christos Exp $
+# $NetBSD: mi,v 1.1155 2017/03/01 03:02:48 kre Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -5410,6 +5410,7 @@
 ./usr/share/zoneinfo/America/Porto_Acre		base-sys-share		share
 ./usr/share/zoneinfo/America/Porto_Velho	base-sys-share		share
 ./usr/share/zoneinfo/America/Puerto_Rico	base-sys-share		share
+./usr/share/zoneinfo/America/Punta_Arenas	base-sys-share		share
 ./usr/share/zoneinfo/America/Rainy_River	base-sys-share		share
 ./usr/share/zoneinfo/America/Rankin_Inlet	base-sys-share		share
 ./usr/share/zoneinfo/America/Recife		base-sys-share		share



CVS commit: src/sys/netinet6

2017-02-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  1 03:02:35 UTC 2017

Modified Files:
src/sys/netinet6: in6.c nd6.c

Log Message:
Restore/add some softnet_lock for nd6_rt_flush and defrouter_addreq

May help PR kern/52015


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/netinet6/in6.c
cvs rdiff -u -r1.230 -r1.231 src/sys/netinet6/nd6.c

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

Modified files:

Index: src/sys/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.240 src/sys/netinet6/in6.c:1.241
--- src/sys/netinet6/in6.c:1.240	Tue Feb 28 04:07:11 2017
+++ src/sys/netinet6/in6.c	Wed Mar  1 03:02:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.240 2017/02/28 04:07:11 ozaki-r Exp $	*/
+/*	$NetBSD: in6.c,v 1.241 2017/03/01 03:02:35 ozaki-r Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.240 2017/02/28 04:07:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.241 2017/03/01 03:02:35 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2655,7 +2655,13 @@ in6_domifdetach(struct ifnet *ifp, void 
 
 	lltable_free(ext->lltable);
 	ext->lltable = NULL;
+#ifndef NET_MPSAFE
+	mutex_enter(softnet_lock);
+#endif
 	nd6_ifdetach(ifp, ext);
+#ifndef NET_MPSAFE
+	mutex_exit(softnet_lock);
+#endif
 	free(ext->in6_ifstat, M_IFADDR);
 	free(ext->icmp6_ifstat, M_IFADDR);
 	scope6_ifdetach(ext->scope6_id);

Index: src/sys/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.230 src/sys/netinet6/nd6.c:1.231
--- src/sys/netinet6/nd6.c:1.230	Wed Feb 22 07:46:00 2017
+++ src/sys/netinet6/nd6.c	Wed Mar  1 03:02:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.230 2017/02/22 07:46:00 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.c,v 1.231 2017/03/01 03:02:35 ozaki-r Exp $	*/
 /*	$KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.230 2017/02/22 07:46:00 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.231 2017/03/01 03:02:35 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -450,6 +450,10 @@ nd6_llinfo_timer(void *arg)
 	bool send_ns = false;
 	const struct in6_addr *daddr6 = NULL;
 
+#ifndef NET_MPSAFE
+	mutex_enter(softnet_lock);
+	KERNEL_LOCK(1, NULL);
+#endif
 	LLE_WLOCK(ln);
 	if ((ln->la_flags & LLE_LINKED) == 0)
 		goto out;
@@ -506,16 +510,8 @@ nd6_llinfo_timer(void *arg)
 			nd6_free(ln, 0);
 			ln = NULL;
 			if (m != NULL) {
-#ifndef NET_MPSAFE
-mutex_enter(softnet_lock);
-KERNEL_LOCK(1, NULL);
-#endif
 icmp6_error2(m, ICMP6_DST_UNREACH,
 ICMP6_DST_UNREACH_ADDR, 0, ifp);
-#ifndef NET_MPSAFE
-KERNEL_UNLOCK_ONE(NULL);
-mutex_exit(softnet_lock);
-#endif
 			}
 		}
 		break;
@@ -567,20 +563,16 @@ nd6_llinfo_timer(void *arg)
 		psrc = nd6_llinfo_get_holdsrc(ln, );
 		LLE_FREE_LOCKED(ln);
 		ln = NULL;
-#ifndef NET_MPSAFE
-		mutex_enter(softnet_lock);
-		KERNEL_LOCK(1, NULL);
-#endif
 		nd6_ns_output(ifp, daddr6, taddr6, psrc, 0);
-#ifndef NET_MPSAFE
-		KERNEL_UNLOCK_ONE(NULL);
-		mutex_exit(softnet_lock);
-#endif
 	}
 
 out:
 	if (ln != NULL)
 		LLE_FREE_LOCKED(ln);
+#ifndef NET_MPSAFE
+	KERNEL_UNLOCK_ONE(NULL);
+	mutex_exit(softnet_lock);
+#endif
 }
 
 /*



CVS commit: src/doc

2017-02-28 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Mar  1 00:41:40 UTC 2017

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Note update to tzdata2017a


To generate a diff of this commit:
cvs rdiff -u -r1.1419 -r1.1420 src/doc/3RDPARTY
cvs rdiff -u -r1.2257 -r1.2258 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1419 src/doc/3RDPARTY:1.1420
--- src/doc/3RDPARTY:1.1419	Tue Feb 21 04:58:44 2017
+++ src/doc/3RDPARTY	Wed Mar  1 00:41:39 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1419 2017/02/21 04:58:44 abhinav Exp $
+#	$NetBSD: 3RDPARTY,v 1.1420 2017/03/01 00:41:39 kre Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1412,8 +1412,8 @@ Notes:
 Added changes from a5 -> a12 manually.
 
 Package:	tz
-Version:	tzcode2016i / tzdata2016j
-Current Vers:	tzcode2016j / tzdata2016j
+Version:	tzcode2016i / tzdata2017a
+Current Vers:	tzcode2017a / tzdata2017a
 Maintainer:	Paul Eggert 
 Archive Site:	ftp://ftp.iana.org/tz/releases/
 Archive Site:	ftp://munnari.oz.au/pub/oldtz/

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2257 src/doc/CHANGES:1.2258
--- src/doc/CHANGES:1.2257	Sun Feb 26 12:06:40 2017
+++ src/doc/CHANGES	Wed Mar  1 00:41:39 2017
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2257 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2258 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -478,3 +478,4 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 		(MBR). [rin 20170219]
 	dk(4): Add DKWEDGE_METHOD_RDB option to enable Amiga Rigid Disk Block
 		(RDB) partitioning detection method. [rin 20170226]
+	zoneinfo: Import tzdata2017a.  [kre 20170301]



CVS import: src/external/public-domain/tz/dist

2017-02-28 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Mar  1 00:37:35 UTC 2017

Update of /cvsroot/src/external/public-domain/tz/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv12325

Log Message:
Import tzdata2017a from ftp://ftp.iana.org/tz/releases/tzdata2017a.tar.gz

Summary of changes in tzdata2017a (2017-02-28 00:05:36 -0800):

  Briefly: Southern Chile moves from -04/-03 to -03, and Mongolia
  discontinues DST.

  Changes to future time stamps

Mongolia no longer observes DST.
Chile's Region of Magallanes moves from -04/-03 to -03 year-round.

  Changes to past time stamps

Fix many entries for historical time stamps for Europe/Madrid
before 1979, to agree with tables compiled by Pere Planesas of the
National Astronomical Observatory of Spain.  As a side effect,
this changes some time stamps for Africa/Ceuta before 1929, which
are probably guesswork anyway.

Ecuador observed DST from 1992-11-28 to 1993-02-05.

Asia/Atyrau and Asia/Oral were at +03 (not +04) before 1930-06-21.

  Changes to past and future time zone abbreviations

Switch to numeric time zone abbreviations for South America, as
part of the ongoing project of removing invented abbreviations.

For Alaska time from 1900 through 1967, instead of "CAT" use the
abbreviation "AST", the abbreviation commonly used at the time
(Atlantic Standard Time had not been standardized yet).  Use "AWT"
and "APT" instead of the invented abbreviations "CAWT" and "CAPT".

Use "CST" and "CDT" instead of invented abbreviations for Macau
before 1999 and Taiwan before 1938, and use "JST" instead of the
invented abbreviation "JCST" for Japan and Korea before 1938.

  Change to database entry category

Move the Pacific/Johnston link from 'australasia' to 'backward',
since Johnston is now uninhabited.

Status:

Vendor Tag: TZDATA
Release Tags:   TZDATA2017A

U src/external/public-domain/tz/dist/leap-seconds.list
U src/external/public-domain/tz/dist/CONTRIBUTING
U src/external/public-domain/tz/dist/LICENSE
U src/external/public-domain/tz/dist/Makefile
U src/external/public-domain/tz/dist/NEWS
U src/external/public-domain/tz/dist/README
U src/external/public-domain/tz/dist/Theory
U src/external/public-domain/tz/dist/version
U src/external/public-domain/tz/dist/africa
U src/external/public-domain/tz/dist/antarctica
U src/external/public-domain/tz/dist/asia
U src/external/public-domain/tz/dist/australasia
U src/external/public-domain/tz/dist/europe
U src/external/public-domain/tz/dist/northamerica
U src/external/public-domain/tz/dist/southamerica
U src/external/public-domain/tz/dist/pacificnew
U src/external/public-domain/tz/dist/etcetera
U src/external/public-domain/tz/dist/backward
U src/external/public-domain/tz/dist/systemv
U src/external/public-domain/tz/dist/factory
U src/external/public-domain/tz/dist/backzone
U src/external/public-domain/tz/dist/iso3166.tab
U src/external/public-domain/tz/dist/leapseconds
U src/external/public-domain/tz/dist/zone1970.tab
U src/external/public-domain/tz/dist/zone.tab
U src/external/public-domain/tz/dist/yearistype.sh
U src/external/public-domain/tz/dist/checklinks.awk
U src/external/public-domain/tz/dist/checktab.awk
U src/external/public-domain/tz/dist/leapseconds.awk
U src/external/public-domain/tz/dist/zoneinfo2tdf.pl

No conflicts created by this import



CVS commit: src/external/public-domain/tz/dist

2017-02-28 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed Mar  1 00:38:15 UTC 2017

Modified Files:
src/external/public-domain/tz/dist: TZDATA_VERSION

Log Message:
Merge tzdata2017a


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/public-domain/tz/dist/TZDATA_VERSION

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

Modified files:

Index: src/external/public-domain/tz/dist/TZDATA_VERSION
diff -u src/external/public-domain/tz/dist/TZDATA_VERSION:1.6 src/external/public-domain/tz/dist/TZDATA_VERSION:1.7
--- src/external/public-domain/tz/dist/TZDATA_VERSION:1.6	Thu Nov 24 05:43:58 2016
+++ src/external/public-domain/tz/dist/TZDATA_VERSION	Wed Mar  1 00:38:15 2017
@@ -1 +1 @@
-tzdata-2016j
+tzdata-2017a



CVS commit: src/sys/sys

2017-02-28 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Mar  1 00:19:23 UTC 2017

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

Log Message:
Add new SIGTRAP types: TRAP_SCE and TRAP_SCX

New entries:
 - TRAP_SCE7   /* Process syscall entry trap   */
 - TRAP_SCX8   /* Process syscall exit trap*/

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/sys/siginfo.h

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

Modified files:

Index: src/sys/sys/siginfo.h
diff -u src/sys/sys/siginfo.h:1.31 src/sys/sys/siginfo.h:1.32
--- src/sys/sys/siginfo.h:1.31	Fri Feb 17 01:49:24 2017
+++ src/sys/sys/siginfo.h	Wed Mar  1 00:19:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: siginfo.h,v 1.31 2017/02/17 01:49:24 kamil Exp $	 */
+/*	$NetBSD: siginfo.h,v 1.32 2017/03/01 00:19:22 kamil Exp $	 */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -214,6 +214,8 @@ typedef union siginfo {
 #define	TRAP_CHLD	4	/* Process child trap			*/
 #define	TRAP_LWP	5	/* Process lwp trap			*/
 #define	TRAP_DBREG	6	/* Process hardware debug register trap	*/
+#define	TRAP_SCE	7	/* Process syscall entry trap		*/
+#define	TRAP_SCX	8	/* Process syscall exit trap		*/
 
 /* SIGCHLD */
 #define	CLD_EXITED	1	/* Child has exited			*/



CVS commit: src/sys/dev/ic

2017-02-28 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue Feb 28 20:55:09 UTC 2017

Modified Files:
src/sys/dev/ic: ld_nvme.c

Log Message:
change DIOCCACHESYNC to not issue the FLUSH command at all when the controller
has no volatile write cache


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/ld_nvme.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/ic/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.13 src/sys/dev/ic/ld_nvme.c:1.14
--- src/sys/dev/ic/ld_nvme.c:1.13	Tue Feb 28 20:53:50 2017
+++ src/sys/dev/ic/ld_nvme.c	Tue Feb 28 20:55:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.13 2017/02/28 20:53:50 jdolecek Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.14 2017/02/28 20:55:09 jdolecek Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.13 2017/02/28 20:53:50 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.14 2017/02/28 20:55:09 jdolecek Exp $");
 
 #include 
 #include 
@@ -199,6 +199,11 @@ ld_nvme_flush(struct ld_softc *ld, bool 
 {
 	struct ld_nvme_softc *sc = device_private(ld->sc_dv);
 
+	if (!nvme_has_volatile_write_cache(sc->sc_nvme)) {
+		/* cache not present, no value in trying to flush it */
+		return 0;
+	}
+
 	return nvme_ns_sync(sc->sc_nvme, sc->sc_nsid, sc,
 	poll ? NVME_NS_CTX_F_POLL : 0,
 	ld_nvme_syncdone);



CVS commit: src/sys/dev/ic

2017-02-28 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue Feb 28 20:53:50 UTC 2017

Modified Files:
src/sys/dev/ic: ld_nvme.c nvme.c nvmereg.h nvmevar.h

Log Message:
implement DIOCGCACHE


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/ld_nvme.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/ic/nvme.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/nvmereg.h
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ic/nvmevar.h

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

Modified files:

Index: src/sys/dev/ic/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.12 src/sys/dev/ic/ld_nvme.c:1.13
--- src/sys/dev/ic/ld_nvme.c:1.12	Mon Feb 27 21:48:34 2017
+++ src/sys/dev/ic/ld_nvme.c	Tue Feb 28 20:53:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.12 2017/02/27 21:48:34 jdolecek Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.13 2017/02/28 20:53:50 jdolecek Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.12 2017/02/27 21:48:34 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.13 2017/02/28 20:53:50 jdolecek Exp $");
 
 #include 
 #include 
@@ -49,6 +49,14 @@ struct ld_nvme_softc {
 	struct nvme_softc	*sc_nvme;
 
 	uint16_t		sc_nsid;
+
+	/* getcache handling */
+	kmutex_t		sc_getcache_lock;
+	kcondvar_t		sc_getcache_cv;
+	kcondvar_t		sc_getcache_ready_cv;
+	bool			sc_getcache_waiting;
+	bool			sc_getcache_ready;
+	int			sc_getcache_result;
 };
 
 static int	ld_nvme_match(device_t, cfdata_t, void *);
@@ -61,10 +69,12 @@ CFATTACH_DECL_NEW(ld_nvme, sizeof(struct
 static int	ld_nvme_start(struct ld_softc *, struct buf *);
 static int	ld_nvme_dump(struct ld_softc *, void *, int, int);
 static int	ld_nvme_flush(struct ld_softc *, bool);
+static int	ld_nvme_getcache(struct ld_softc *, int *);
 static int	ld_nvme_ioctl(struct ld_softc *, u_long, void *, int32_t, bool);
 
-static void	ld_nvme_biodone(void *, struct buf *, uint16_t);
-static void	ld_nvme_syncdone(void *, struct buf *, uint16_t);
+static void	ld_nvme_biodone(void *, struct buf *, uint16_t, uint32_t);
+static void	ld_nvme_syncdone(void *, struct buf *, uint16_t, uint32_t);
+static void	ld_nvme_getcache_done(void *, struct buf *, uint16_t, uint32_t);
 
 static int
 ld_nvme_match(device_t parent, cfdata_t match, void *aux)
@@ -93,6 +103,10 @@ ld_nvme_attach(device_t parent, device_t
 	sc->sc_nvme = nsc;
 	sc->sc_nsid = naa->naa_nsid;
 
+	mutex_init(>sc_getcache_lock, MUTEX_DEFAULT, IPL_SOFTBIO);
+	cv_init(>sc_getcache_cv, "nvmegcq");
+	cv_init(>sc_getcache_ready_cv, "nvmegcr");
+
 	aprint_naive("\n");
 	aprint_normal("\n");
 
@@ -159,7 +173,7 @@ ld_nvme_dump(struct ld_softc *ld, void *
 }
 
 static void
-ld_nvme_biodone(void *xc, struct buf *bp, uint16_t cmd_status)
+ld_nvme_biodone(void *xc, struct buf *bp, uint16_t cmd_status, uint32_t cdw0)
 {
 	struct ld_nvme_softc *sc = xc;
 	uint16_t status = NVME_CQE_SC(cmd_status);
@@ -190,6 +204,104 @@ ld_nvme_flush(struct ld_softc *ld, bool 
 	ld_nvme_syncdone);
 }
 
+static void
+ld_nvme_syncdone(void *xc, struct buf *bp, uint16_t cmd_status, uint32_t cdw0)
+{
+	/* nothing to do */
+}
+
+static int
+ld_nvme_getcache(struct ld_softc *ld, int *addr)
+{
+	int error;
+	struct ld_nvme_softc *sc = device_private(ld->sc_dv);
+
+	*addr = 0;
+
+	if (!nvme_has_volatile_write_cache(sc->sc_nvme)) {
+		/* cache simply not present */
+		return 0;
+	}
+
+	/*
+	 * This is admin queue request. The queue is relatively limited in size,
+	 * and this is not performance critical call, so have at most one pending
+	 * cache request at a time to avoid spurious EWOULDBLOCK failures.
+	 */ 
+	mutex_enter(>sc_getcache_lock);
+	while (sc->sc_getcache_waiting) {
+		error = cv_wait_sig(>sc_getcache_cv, >sc_getcache_lock);
+		if (error)
+			goto out;
+	}
+	sc->sc_getcache_waiting = true;
+	sc->sc_getcache_ready = false;
+	mutex_exit(>sc_getcache_lock);
+
+	error = nvme_admin_getcache(sc->sc_nvme, sc, ld_nvme_getcache_done);
+	if (error) {
+		mutex_enter(>sc_getcache_lock);
+		goto out;
+	}
+
+	mutex_enter(>sc_getcache_lock);
+	while (!sc->sc_getcache_ready) {
+		error = cv_wait_sig(>sc_getcache_ready_cv,
+		>sc_getcache_lock);
+		if (error)
+			goto out;
+	}
+
+	KDASSERT(sc->sc_getcache_ready);
+
+	if (sc->sc_getcache_result >= 0)
+		*addr |= sc->sc_getcache_result;
+	else
+		error = EINVAL;
+
+out:
+	sc->sc_getcache_waiting = false;
+
+	/* wake one of eventual waiters */
+	cv_signal(>sc_getcache_cv);
+
+	mutex_exit(>sc_getcache_lock);
+
+	return error;
+}
+
+static void
+ld_nvme_getcache_done(void *xc, struct buf *bp, uint16_t cmd_status, uint32_t cdw0)
+{
+	struct ld_nvme_softc *sc = xc;
+	uint16_t status = NVME_CQE_SC(cmd_status);
+	int result;
+
+	if (status == NVME_CQE_SC_SUCCESS) {
+		result = 0;
+
+		if (cdw0 & NVME_CQE_CDW0_VWC_WCE)
+			result |= DKCACHE_WRITE;
+
+		/*
+		 * If volatile write cache is present, the flag shall also be
+		 * 

CVS commit: src/sys/arch/powerpc/powerpc

2017-02-28 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Feb 28 17:35:29 UTC 2017

Modified Files:
src/sys/arch/powerpc/powerpc: locore_subr.S

Log Message:
in cpu_switchto() and the fast-softint context switch code,
put back the stwcx. instruction to clear the reservation.
we used to have this in the old cpu_switch() until it was
if-0'd in 2003 and removed completely in 2007.
this fixes hangs I've seen where a softint thread is
blocked waiting for a mutex that is not held.
this should also fix PR 44387.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/powerpc/powerpc/locore_subr.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/powerpc/powerpc/locore_subr.S
diff -u src/sys/arch/powerpc/powerpc/locore_subr.S:1.54 src/sys/arch/powerpc/powerpc/locore_subr.S:1.55
--- src/sys/arch/powerpc/powerpc/locore_subr.S:1.54	Wed Jul 30 23:27:55 2014
+++ src/sys/arch/powerpc/powerpc/locore_subr.S	Tue Feb 28 17:35:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_subr.S,v 1.54 2014/07/30 23:27:55 matt Exp $	*/
+/*	$NetBSD: locore_subr.S,v 1.55 2017/02/28 17:35:29 chs Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -288,6 +288,7 @@ switchto_restore:
  */
 	ldreg	%r31,CFRAME_R31(%r1)	/* restore saved registers */
 	ldreg	%r30,CFRAME_R30(%r1)
+	stwcx.	%r1,0,%r1		/* clear reservation */
 #if 1
 	addi	%r1,%r1,CALLFRAMELEN
 #else
@@ -328,6 +329,7 @@ _ENTRY(softint_cleanup)
 	mtmsr	%r0
 	isync
 #endif
+	stwcx.	%r1,0,%r1		/* clear reservation */
 	addi	%r1, %r1, CALLFRAMELEN
 	ldreg	%r0, CFRAME_LR(%r1)
 	mtlr	%r0
@@ -478,6 +480,7 @@ _ENTRY(softint_fast_dispatch)
 	ldreg	%r29,SFRAME_R29(%r1)	/* R29 */
 	ldreg	%r31,SFRAMELEN+CFRAME_R31(%r1)	/* restore saved registers */
 	ldreg	%r30,SFRAMELEN+CFRAME_R30(%r1)
+	stwcx.	%r1,0,%r1		/* clear reservation */
 	addi	%r1,%r1,SFRAMELEN+2*CALLFRAMELEN /* remove switch & callframes */
 #endif
 	ldreg	%r0,CFRAME_LR(%r1)



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

2017-02-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 28 15:00:32 UTC 2017

Modified Files:
src/sys/arch/evbarm/conf: std.marvell

Log Message:
typo


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/conf/std.marvell

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/evbarm/conf/std.marvell
diff -u src/sys/arch/evbarm/conf/std.marvell:1.3 src/sys/arch/evbarm/conf/std.marvell:1.4
--- src/sys/arch/evbarm/conf/std.marvell:1.3	Sun Dec 16 23:47:56 2012
+++ src/sys/arch/evbarm/conf/std.marvell	Tue Feb 28 15:00:32 2017
@@ -1,6 +1,6 @@
-#	$NetBSD: std.marvell,v 1.3 2012/12/16 23:47:56 matt Exp $
+#	$NetBSD: std.marvell,v 1.4 2017/02/28 15:00:32 skrll Exp $
 #
-# standard NetBSD/evbarm for MAEVELL options
+# standard NetBSD/evbarm for MARVELL options
 
 machine	evbarm arm
 include		"arch/evbarm/conf/std.evbarm"



CVS commit: src/tests/kernel

2017-02-28 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Feb 28 13:29:52 UTC 2017

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Mark resume1 and syscallemu1 tests broken in t_ptrace_wait*

resume1:
PR kern/51995 ptrace(2) PT_RESUME is not reliable

syscallemu1:
PR kern/52012 PT_SYSCALL does not stop on syscall entry

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/tests/kernel/t_ptrace_wait.c

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

Modified files:

Index: src/tests/kernel/t_ptrace_wait.c
diff -u src/tests/kernel/t_ptrace_wait.c:1.74 src/tests/kernel/t_ptrace_wait.c:1.75
--- src/tests/kernel/t_ptrace_wait.c:1.74	Tue Feb 28 13:19:50 2017
+++ src/tests/kernel/t_ptrace_wait.c	Tue Feb 28 13:29:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.74 2017/02/28 13:19:50 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.75 2017/02/28 13:29:52 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.74 2017/02/28 13:19:50 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.75 2017/02/28 13:29:52 kamil Exp $");
 
 #include 
 #include 
@@ -7298,6 +7298,8 @@ ATF_TC_BODY(resume1, tc)
 	struct ptrace_lwpinfo pl;
 	struct ptrace_siginfo psi;
 
+	atf_tc_expect_fail("PR kern/51995");
+
 	ATF_REQUIRE(msg_open() == 0);
 
 	printf("Before forking process PID=%d\n", getpid());
@@ -7486,6 +7488,8 @@ ATF_TC_BODY(syscallemu1, tc)
 	int status;
 #endif
 
+	atf_tc_expect_fail("PR kern/52012");
+
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {



CVS commit: src/tests/kernel

2017-02-28 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Feb 28 13:19:50 UTC 2017

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Add new test syscallemu1 in t_ptrace_wait*

syscallemu1:
Verify that exit(2) can be intercepted with PT_SYSCALLEMU

This test is failing as PT_SYSCALL does not stop the process on syscall
entry. This renders PT_SYSCALL broken on NetBSD.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/tests/kernel/t_ptrace_wait.c

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

Modified files:

Index: src/tests/kernel/t_ptrace_wait.c
diff -u src/tests/kernel/t_ptrace_wait.c:1.73 src/tests/kernel/t_ptrace_wait.c:1.74
--- src/tests/kernel/t_ptrace_wait.c:1.73	Fri Feb 24 06:17:48 2017
+++ src/tests/kernel/t_ptrace_wait.c	Tue Feb 28 13:19:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.73 2017/02/24 06:17:48 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.74 2017/02/28 13:19:50 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.73 2017/02/24 06:17:48 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.74 2017/02/28 13:19:50 kamil Exp $");
 
 #include 
 #include 
@@ -7470,6 +7470,77 @@ ATF_TC_BODY(syscall1, tc)
 	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
 }
 
+ATF_TC(syscallemu1);
+ATF_TC_HEAD(syscallemu1, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Verify that exit(2) can be intercepted with PT_SYSCALLEMU");
+}
+
+ATF_TC_BODY(syscallemu1, tc)
+{
+	const int exitval = 5;
+	const int sigval = SIGSTOP;
+	pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+
+	printf("Before forking process PID=%d\n", getpid());
+	ATF_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		syscall(SYS_exit, 100);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_SYSCALL, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	printf("Set SYSCALLEMU for intercepted syscall\n");
+	ATF_REQUIRE(ptrace(PT_SYSCALLEMU, child, (void *)1, 0) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_SYSCALL, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_exited(status, exitval);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	setvbuf(stdout, NULL, _IONBF, 0);
@@ -7600,5 +7671,7 @@ ATF_TP_ADD_TCS(tp)
 
 	ATF_TP_ADD_TC(tp, syscall1);
 
+	ATF_TP_ADD_TC(tp, syscallemu1);
+
 	return atf_no_error();
 }



CVS commit: src/doc

2017-02-28 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Feb 28 13:10:54 UTC 2017

Modified Files:
src/doc: TODO.ptrace

Log Message:
Sync TODO.ptrace with reality

Remove entries:
- add new ptrace(2) calls to lock (suspend) and unlock LWP within a process
- switch PT_WATCHPOINT* to PT_*ETDBREGS and document it, add ATF tests
- add ATF tests for PT_SYSCALL and PT_SYSCALLEMU

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/doc/TODO.ptrace

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

Modified files:

Index: src/doc/TODO.ptrace
diff -u src/doc/TODO.ptrace:1.23 src/doc/TODO.ptrace:1.24
--- src/doc/TODO.ptrace:1.23	Mon Feb 20 03:37:24 2017
+++ src/doc/TODO.ptrace	Tue Feb 28 13:10:54 2017
@@ -1,4 +1,4 @@
-$NetBSD: TODO.ptrace,v 1.23 2017/02/20 03:37:24 kamil Exp $
+$NetBSD: TODO.ptrace,v 1.24 2017/02/28 13:10:54 kamil Exp $
 
 Items we (currently) plan to finish in the ptrace(2) field:
 
@@ -6,10 +6,8 @@ Items we (currently) plan to finish in t
it must point to the real parent, not tracer
  - adapt OpenBSD regress test (regress/sys/ptrace/ptrace.c) for the ATF context
  - reiterate over FreeBSD tests and add missing ones if applicable
- - add new ptrace(2) calls to lock (suspend) and unlock LWP within a process
  - add PT_DUMPCORE tests in the ATF framework
  - add ATF tests for PT_WRITE_I and PIOD_WRITE_I - test mprotect restrictions
- - switch PT_WATCHPOINT* to PT_*ETDBREGS and document it, add ATF tests
  - add tests for the procfs interface covering all functions available on the
same level as ptrace(2)
  - remove 4.4BSD tracing with /proc, restrict /proc to Linux compat, to be
@@ -26,7 +24,6 @@ Items we (currently) plan to finish in t
  - add proper implementation of PTRACE_VFORK for vfork(2)-like events
  - add ATF tests for SIGCHLD
  - add si_code values for PT_SYSCALL: TRAP_SCE and TRAP_SCX
- - add ATF tests for PT_SYSCALL and PT_SYSCALLEMU
  - research support PT_SYSCALL & PT_STEP combined like in Linux
  - fix more calls for netbsd32 compat
  - research ipkdb(4)



CVS commit: src/sys/dev/pci

2017-02-28 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Feb 28 09:55:47 UTC 2017

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

Log Message:
fix EITR setting.

+ 82574
  - add EITR setting, that is MSI-X mode interrupt interval
+ 82575
  - fix EITR value. 82575's EITR usage is the same as legacy (not NEWQUEUE)
controllers
  - apply workaround which 82575's EITR does not have CNT_INGR bit
+ other NEWQUEUE controllers
  - fix interrupt interval field. NEWQUEUE (include 82575) controllers'
interrupt interval field is 2:14
  - use CNT_INGR bit which avoid to overwrite counter

tested 82574, 82575 and I354.
ok by msaitoh@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.488 -r1.489 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/pci/if_wmreg.h

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.488 src/sys/dev/pci/if_wm.c:1.489
--- src/sys/dev/pci/if_wm.c:1.488	Mon Feb 27 09:27:27 2017
+++ src/sys/dev/pci/if_wm.c	Tue Feb 28 09:55:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.488 2017/02/27 09:27:27 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.489 2017/02/28 09:55:47 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.488 2017/02/27 09:27:27 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.489 2017/02/28 09:55:47 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4874,8 +4874,19 @@ wm_init_locked(struct ifnet *ifp)
 		wm_gmii_reset(sc);
 
 	/* Calculate (E)ITR value */
-	if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
-		sc->sc_itr = 450;	/* For EITR */
+	if ((sc->sc_flags & WM_F_NEWQUEUE) != 0 && sc->sc_type != WM_T_82575) {
+		/*
+		 * For NEWQUEUE's EITR (except for 82575).
+		 * 82575's EITR should be set same throttling value as other
+		 * old controllers' ITR because the interrupt/sec calculation
+		 * is the same, that is, 1,000,000,000 / (N * 256).
+		 *
+		 * 82574's EITR should be set same throttling value as ITR.
+		 *
+		 * For N interrupts/sec, set this value to:
+		 * 1,000,000 / N in contrast to ITR throttoling value.
+		 */
+		sc->sc_itr = 450;
 	} else if (sc->sc_type >= WM_T_82543) {
 		/*
 		 * Set up the interrupt throttling register (units of 256ns)
@@ -4891,11 +4902,10 @@ wm_init_locked(struct ifnet *ifp)
 
 		/*
 		 * For N interrupts/sec, set this value to:
-		 * 10 / (N * 256).  Note that we set the
+		 * 1,000,000,000 / (N * 256).  Note that we set the
 		 * absolute and packet timer values to this value
 		 * divided by 4 to get "simple timer" behavior.
 		 */
-
 		sc->sc_itr = 1500;		/* 2604 ints/sec */
 	}
 
@@ -5192,16 +5202,26 @@ wm_init_locked(struct ifnet *ifp)
 	CSR_WRITE(sc, WMREG_TIPG, sc->sc_tipg);
 
 	if (sc->sc_type >= WM_T_82543) {
-		/*
-		 * XXX 82574 has both ITR and EITR. SET EITR when we use
-		 * the multi queue function with MSI-X.
-		 */
 		if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
 			int qidx;
 			for (qidx = 0; qidx < sc->sc_nqueues; qidx++) {
 struct wm_queue *wmq = >sc_queue[qidx];
+uint32_t eitr = __SHIFTIN(sc->sc_itr,
+EITR_ITR_INT_MASK);
+
+/*
+ * 82575 doesn't have CNT_INGR field.
+ * So, overwrite counter field by software.
+ */
+if (sc->sc_type == WM_T_82575) {
+	eitr |= __SHIFTIN(sc->sc_itr,
+	EITR_COUNTER_MASK_82575);
+} else {
+	eitr |= EITR_CNT_INGR;
+}
+
 CSR_WRITE(sc, WMREG_EITR(wmq->wmq_intr_idx),
-sc->sc_itr);
+eitr);
 			}
 			/*
 			 * Link interrupts occur much less than TX
@@ -5209,6 +5229,17 @@ wm_init_locked(struct ifnet *ifp)
 			 * tune EINTR(WM_MSIX_LINKINTR_IDX) value like
 			 * FreeBSD's if_igb.
 			 */
+		} else if (sc->sc_type == WM_T_82574 && sc->sc_nintrs > 1) {
+			/*
+			 * 82574 has both ITR and EITR. SET EITR when we use
+			 * the multi queue function with MSI-X.
+			 */
+			for (int qidx = 0; qidx < sc->sc_nqueues; qidx++) {
+struct wm_queue *wmq = >sc_queue[qidx];
+CSR_WRITE(sc,
+WMREG_EITR_82574(wmq->wmq_intr_idx),
+sc->sc_itr & EITR_ITR_INT_MASK_82574);
+			}
 		} else
 			CSR_WRITE(sc, WMREG_ITR, sc->sc_itr);
 	}

Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.97 src/sys/dev/pci/if_wmreg.h:1.98
--- src/sys/dev/pci/if_wmreg.h:1.97	Thu Feb  2 05:38:59 2017
+++ src/sys/dev/pci/if_wmreg.h	Tue Feb 28 09:55:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.97 2017/02/02 05:38:59 msaitoh Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.98 2017/02/28 09:55:47 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -1051,7 +1051,12 @@ struct livengood_tcpip_ctxdesc {
 #define EITR_OTHER	0x8000 /* Interrupt Cause Active */
 
 #define WMREG_EITR(x)	(0x01680 + (0x4 * (x)))
-#define EITR_ITR_INT_MASK	0x

CVS commit: src/tests/net/mcast

2017-02-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Feb 28 09:23:23 UTC 2017

Modified Files:
src/tests/net/mcast: mcast.c t_mcast.sh

Log Message:
Add tests that destroy an interface while the mcast program is running


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/net/mcast/mcast.c
cvs rdiff -u -r1.4 -r1.5 src/tests/net/mcast/t_mcast.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/mcast/mcast.c
diff -u src/tests/net/mcast/mcast.c:1.3 src/tests/net/mcast/mcast.c:1.4
--- src/tests/net/mcast/mcast.c:1.3	Thu May 28 10:19:17 2015
+++ src/tests/net/mcast/mcast.c	Tue Feb 28 09:23:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcast.c,v 1.3 2015/05/28 10:19:17 ozaki-r Exp $	*/
+/*	$NetBSD: mcast.c,v 1.4 2017/02/28 09:23:23 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 #include 
 #ifdef __RCSID
-__RCSID("$NetBSD: mcast.c,v 1.3 2015/05/28 10:19:17 ozaki-r Exp $");
+__RCSID("$NetBSD: mcast.c,v 1.4 2017/02/28 09:23:23 ozaki-r Exp $");
 #else
 extern const char *__progname;
 #define getprogname() __progname
@@ -73,6 +73,7 @@ extern const char *__progname;
 #endif
 
 static int debug;
+static int nsleep;
 
 #define TOTAL 10
 #define PORT_V4MAPPED ""
@@ -338,6 +339,8 @@ receiver(const int fd, const char *host,
 			seq, msg.seq);
 	}
 
+	if (nsleep)
+		sleep(nsleep);
 	/* Tell I'm finished */
 	synchronize(fd, false);
 }
@@ -417,7 +420,7 @@ main(int argc, char *argv[])
 	n = TOTAL;
 	bug = conn = false;
 
-	while ((c = getopt(argc, argv, "46bcdmn:")) != -1)
+	while ((c = getopt(argc, argv, "46bcdmn:s:")) != -1)
 		switch (c) {
 		case '4':
 			host = HOST_V4;
@@ -443,8 +446,12 @@ main(int argc, char *argv[])
 		case 'n':
 			n = atoi(optarg);
 			break;
+		case 's':
+			nsleep = atoi(optarg);
+			break;
 		default:
-			fprintf(stderr, "Usage: %s [-cdm46] [-n ]",
+			fprintf(stderr, "Usage: %s [-cdm46] [-n ]"
+			" [-s ]",
 			getprogname());
 			return 1;
 		}

Index: src/tests/net/mcast/t_mcast.sh
diff -u src/tests/net/mcast/t_mcast.sh:1.4 src/tests/net/mcast/t_mcast.sh:1.5
--- src/tests/net/mcast/t_mcast.sh:1.4	Fri Nov 25 08:51:16 2016
+++ src/tests/net/mcast/t_mcast.sh	Tue Feb 28 09:23:23 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: t_mcast.sh,v 1.4 2016/11/25 08:51:16 ozaki-r Exp $
+#	$NetBSD: t_mcast.sh,v 1.5 2017/02/28 09:23:23 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -62,15 +62,61 @@ run_test()
 	unset LD_PRELOAD
 }
 
+run_test_destroyif()
+{
+	local name="$1"
+	local opts="$2"
+	local mcast="$(atf_get_srcdir)/mcast"
+	local sleep=3
+
+	rump_server_start $RUMP_SERVER netinet6
+	rump_server_add_iface $RUMP_SERVER shmif0 bus1
+	export RUMP_SERVER=$RUMP_SERVER
+	atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.2/24
+	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2/64
+	atf_check -s exit:0 rump.ifconfig shmif0 up
+
+	atf_check -s exit:0 rump.ifconfig -w 10
+	atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep -q tentative"
+
+	# A route to the mcast address is required to join the mcast group
+	atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1
+	atf_check -s exit:0 -o ignore rump.route add -inet6 default fc00::1
+
+	$DEBUG && rump.ifconfig
+	$DEBUG && rump.netstat -nr
+
+	export LD_PRELOAD=/usr/lib/librumphijack.so
+	#$DEBUG && /usr/sbin/ifmcstat  # Not yet run on rump kernel
+	if $DEBUG; then
+		$mcast -d ${opts} -s $sleep &
+	else
+		$mcast ${opts} -s $sleep &
+	fi
+	#$DEBUG && /usr/sbin/ifmcstat  # Not yet run on rump kernel
+	unset LD_PRELOAD
+
+	# Give a chance to setup mcast
+	sleep 1
+
+	# Try to destroy an interface that the mcast program is running on
+	atf_check -s exit:0 rump.ifconfig shmif0 destroy
+
+	wait
+	atf_check -s exit:0 -o ignore rump.ifconfig
+}
+
 add_test()
 {
 	local name=$1
 	local opts="$2"
 	local desc="$3"
+	local fulldesc=
 
+	fulldesc="Checks $desc"
 	atf_test_case "mcast_${name}" cleanup
 	eval "mcast_${name}_head() { \
-			atf_set \"descr\" \"${desc}\"; \
+			atf_set \"descr\" \"${fulldesc}\"; \
 			atf_set \"require.progs\" \"rump_server\"; \
 		}; \
 	mcast_${name}_body() { \
@@ -82,25 +128,40 @@ add_test()
 			cleanup; \
 		}"
 	atf_add_test_case "mcast_${name}"
+
+	fulldesc="Destroying interface while testing ${desc}"
+	atf_test_case "mcast_destroyif_${name}" cleanup
+	eval "mcast_destroyif_${name}_head() { \
+			atf_set \"descr\" \"${fulldesc}\"; \
+			atf_set \"require.progs\" \"rump_server\"; \
+		}; \
+	mcast_destroyif_${name}_body() { \
+			run_test_destroyif \"${name}\" \"${opts}\"; \
+		}; \
+	mcast_destroyif_${name}_cleanup() { \
+			${DEBUG} && dump; \
+			cleanup; \
+		}"
+	atf_add_test_case "mcast_destroyif_${name}"
 }
 
 atf_init_test_cases()
 {
 
 	add_test conninet4"-c -4" \
-	"Checks connected multicast for ipv4"
+	"connected multicast for ipv4"
 	add_test