CVS commit: src/sys/net

2017-12-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Dec 15 07:29:11 UTC 2017

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

Log Message:
Make softint and callout MP-safe


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/sys/net/bpf.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/bpf.c
diff -u src/sys/net/bpf.c:1.221 src/sys/net/bpf.c:1.222
--- src/sys/net/bpf.c:1.221	Tue Dec 12 06:26:57 2017
+++ src/sys/net/bpf.c	Fri Dec 15 07:29:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.221 2017/12/12 06:26:57 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.222 2017/12/15 07:29:11 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.221 2017/12/12 06:26:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.222 2017/12/15 07:29:11 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -561,9 +561,10 @@ bpfopen(dev_t dev, int flag, int mode, s
 #endif
 	getnanotime(>bd_btime);
 	d->bd_atime = d->bd_mtime = d->bd_btime;
-	callout_init(>bd_callout, 0);
+	callout_init(>bd_callout, CALLOUT_MPSAFE);
 	selinit(>bd_sel);
-	d->bd_sih = softint_establish(SOFTINT_CLOCK, bpf_softintr, d);
+	d->bd_sih = softint_establish(SOFTINT_CLOCK|SOFTINT_MPSAFE,
+	bpf_softintr, d);
 	d->bd_jitcode = NULL;
 	d->bd_filter = NULL;
 	BPF_DLIST_ENTRY_INIT(d);
@@ -765,8 +766,10 @@ bpf_softintr(void *cookie)
 	struct bpf_d *d;
 
 	d = cookie;
+	mutex_enter(d->bd_mtx);
 	if (d->bd_async)
 		fownsignal(d->bd_pgid, SIGIO, 0, 0, NULL);
+	mutex_exit(d->bd_mtx);
 }
 
 static void
@@ -1231,7 +1234,9 @@ bpf_ioctl(struct file *fp, u_long cmd, v
 		break;
 
 	case FIOASYNC:		/* Send signal on receive packets */
+		mutex_enter(d->bd_mtx);
 		d->bd_async = *(int *)addr;
+		mutex_exit(d->bd_mtx);
 		break;
 
 	case TIOCSPGRP:		/* Process or group to send signals to */



CVS commit: src/sys

2017-12-14 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Dec 15 05:01:17 UTC 2017

Modified Files:
src/sys/netinet: in_l2tp.c
src/sys/netinet6: in6_l2tp.c

Log Message:
Fix pullup'ed mbuf leaks. The match function just requires enough mbuf length.

XXX need pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.9 -r1.10 src/sys/netinet6/in6_l2tp.c

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

Modified files:

Index: src/sys/netinet/in_l2tp.c
diff -u src/sys/netinet/in_l2tp.c:1.6 src/sys/netinet/in_l2tp.c:1.7
--- src/sys/netinet/in_l2tp.c:1.6	Fri Dec 15 04:58:31 2017
+++ src/sys/netinet/in_l2tp.c	Fri Dec 15 05:01:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_l2tp.c,v 1.6 2017/12/15 04:58:31 knakahara Exp $	*/
+/*	$NetBSD: in_l2tp.c,v 1.7 2017/12/15 05:01:16 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.6 2017/12/15 04:58:31 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.7 2017/12/15 05:01:16 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -369,12 +369,10 @@ in_l2tp_match(struct mbuf *m, int off, i
 	KASSERT(proto == IPPROTO_L2TP);
 
 	if (m->m_len < off + sizeof(uint32_t)) {
-		m = m_pullup(m, off + sizeof(uint32_t));
-		if (!m) {
-			/* if payload length < 4 octets */
+		/* if payload length < 4 octets */
+		if(!m_ensure_contig(, off + sizeof(uint32_t)))
 			return 0;
-		}
-}
+	}
 
 	/* get L2TP session ID */
 	m_copydata(m, off, sizeof(uint32_t), (void *)_id);

Index: src/sys/netinet6/in6_l2tp.c
diff -u src/sys/netinet6/in6_l2tp.c:1.9 src/sys/netinet6/in6_l2tp.c:1.10
--- src/sys/netinet6/in6_l2tp.c:1.9	Fri Dec 15 04:58:31 2017
+++ src/sys/netinet6/in6_l2tp.c	Fri Dec 15 05:01:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_l2tp.c,v 1.9 2017/12/15 04:58:31 knakahara Exp $	*/
+/*	$NetBSD: in6_l2tp.c,v 1.10 2017/12/15 05:01:16 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.9 2017/12/15 04:58:31 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.10 2017/12/15 05:01:16 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -361,12 +361,10 @@ in6_l2tp_match(struct mbuf *m, int off, 
 	KASSERT(proto == IPPROTO_L2TP);
 
 	if (m->m_len < off + sizeof(uint32_t)) {
-		m = m_pullup(m, off + sizeof(uint32_t));
-		if (!m) {
-			/* if payload length < 4 octets */
+		/* if payload length < 4 octets */
+		if(!m_ensure_contig(, off + sizeof(uint32_t)))
 			return 0;
-		}
-}
+	}
 
 	/* get L2TP session ID */
 	m_copydata(m, off, sizeof(uint32_t), (void *)_id);



CVS commit: src/sys

2017-12-14 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Dec 15 04:58:32 UTC 2017

Modified Files:
src/sys/netinet: in_l2tp.c
src/sys/netinet6: in6_l2tp.c

Log Message:
backout wrong fix as it causes atf net/ipsec/t_ipsec_l2tp failures.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.8 -r1.9 src/sys/netinet6/in6_l2tp.c

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

Modified files:

Index: src/sys/netinet/in_l2tp.c
diff -u src/sys/netinet/in_l2tp.c:1.5 src/sys/netinet/in_l2tp.c:1.6
--- src/sys/netinet/in_l2tp.c:1.5	Mon Dec 11 02:17:35 2017
+++ src/sys/netinet/in_l2tp.c	Fri Dec 15 04:58:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_l2tp.c,v 1.5 2017/12/11 02:17:35 knakahara Exp $	*/
+/*	$NetBSD: in_l2tp.c,v 1.6 2017/12/15 04:58:31 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.5 2017/12/11 02:17:35 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.6 2017/12/15 04:58:31 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -368,9 +368,13 @@ in_l2tp_match(struct mbuf *m, int off, i
 
 	KASSERT(proto == IPPROTO_L2TP);
 
-	/* if payload length < 4 octets */
-	if (m->m_len < off + sizeof(uint32_t))
-		return 0;
+	if (m->m_len < off + sizeof(uint32_t)) {
+		m = m_pullup(m, off + sizeof(uint32_t));
+		if (!m) {
+			/* if payload length < 4 octets */
+			return 0;
+		}
+}
 
 	/* get L2TP session ID */
 	m_copydata(m, off, sizeof(uint32_t), (void *)_id);

Index: src/sys/netinet6/in6_l2tp.c
diff -u src/sys/netinet6/in6_l2tp.c:1.8 src/sys/netinet6/in6_l2tp.c:1.9
--- src/sys/netinet6/in6_l2tp.c:1.8	Mon Dec 11 02:17:35 2017
+++ src/sys/netinet6/in6_l2tp.c	Fri Dec 15 04:58:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_l2tp.c,v 1.8 2017/12/11 02:17:35 knakahara Exp $	*/
+/*	$NetBSD: in6_l2tp.c,v 1.9 2017/12/15 04:58:31 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.8 2017/12/11 02:17:35 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.9 2017/12/15 04:58:31 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -360,9 +360,13 @@ in6_l2tp_match(struct mbuf *m, int off, 
 
 	KASSERT(proto == IPPROTO_L2TP);
 
-	/* if payload length < 4 octets */
-	if (m->m_len < off + sizeof(uint32_t))
-		return 0;
+	if (m->m_len < off + sizeof(uint32_t)) {
+		m = m_pullup(m, off + sizeof(uint32_t));
+		if (!m) {
+			/* if payload length < 4 octets */
+			return 0;
+		}
+}
 
 	/* get L2TP session ID */
 	m_copydata(m, off, sizeof(uint32_t), (void *)_id);



CVS commit: src/share/misc

2017-12-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec 15 04:10:50 UTC 2017

Modified Files:
src/share/misc: bsd-family-tree

Log Message:
Update for dfly 5.0.1 and 5.0.2.

>From Eitan Adler .


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/share/misc/bsd-family-tree

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

Modified files:

Index: src/share/misc/bsd-family-tree
diff -u src/share/misc/bsd-family-tree:1.62 src/share/misc/bsd-family-tree:1.63
--- src/share/misc/bsd-family-tree:1.62	Thu Dec 14 10:34:06 2017
+++ src/share/misc/bsd-family-tree	Fri Dec 15 04:10:49 2017
@@ -357,8 +357,13 @@ FreeBSD 5.2   |  |  
  |  FreeBSD   |   | |  |   |
  |   11.1  FreeBSD| |  |   |
  | |10.4  | | OpenBSD 6.2  |
+ | |  | |  |   |
  | v  | |  |   DragonFly 5.0.0
  || |  |   |
+ || |  |   DragonFly 5.0.1
+ || |  |   |
+ || |  |   DragonFly 5.0.2
+ || |  |   |
 FreeBSD 12 -current   | NetBSD -current   OpenBSD -currentDragonFly -current
  || |  |   |
  vv v  v   v
@@ -723,6 +728,8 @@ macOS 10.13		2017-09-25 [APL]
 FreeBSD 10.4		2017-10-03 [FBD]
 OpenBSD 6.2		2017-10-09 [OBD]
 DragonFly 5.0.0		2017-10-16 [DFB]
+DragonFly 5.0.1		2017-11-06 [DFB]
+DragonFly 5.0.2		2017-12-04 [DFB]
 
 Bibliography
 
@@ -788,4 +795,4 @@ Copyright (c) 1997-2012 Wolfram Schneide
 URL: http://svnweb.freebsd.org/base/head/share/misc/bsd-family-tree
 
 $FreeBSD: head/share/misc/bsd-family-tree 326724 2017-12-09 05:05:25Z imp $
-$NetBSD: bsd-family-tree,v 1.62 2017/12/14 10:34:06 maya Exp $
+$NetBSD: bsd-family-tree,v 1.63 2017/12/15 04:10:49 riastradh Exp $



CVS commit: src/sys/net

2017-12-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Dec 15 04:06:42 UTC 2017

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

Log Message:
Describe which lock is used to protect each member variable of struct ifnet

Requested by skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/sys/net/if.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/net/if.h
diff -u src/sys/net/if.h:1.254 src/sys/net/if.h:1.255
--- src/sys/net/if.h:1.254	Fri Dec 15 04:03:46 2017
+++ src/sys/net/if.h	Fri Dec 15 04:06:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.254 2017/12/15 04:03:46 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.255 2017/12/15 04:06:42 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -235,86 +235,111 @@ struct in6_multi;
 
 typedef unsigned short if_index_t;
 
+/*
+ * Interface.  Field markings and the corresponding locks:
+ *
+ * i:	IFNET_LOCK (a.k.a., if_ioctl_lock)
+ * q:	ifq_lock (struct ifaltq)
+ * a:	if_afdata_lock
+ * 6:	in6_multilock (global lock)
+ * ::	unlocked, stable
+ * ?:	unkown, maybe unsafe
+ *
+ * Lock order: IFNET_LOCK => in6_multilock => if_afdata_lock => ifq_lock
+ *   Note that currently if_afdata_lock and ifq_lock aren't held
+ *   at the same time, but define the order anyway.
+ *
+ * Lock order of IFNET_LOCK with other locks:
+ * softnet_lock => solock => IFNET_LOCK => ND6_LOCK, in_multilock
+ */
 typedef struct ifnet {
-	void	*if_softc;		/* lower-level data for this if */
+	void		*if_softc;	/* :: lower-level data for this if */
 	/* DEPRECATED. Keep it to avoid breaking kvm(3) users */
-	TAILQ_ENTRY(ifnet) if_list;	/* all struct ifnets are chained */
-	TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */
-	char	if_xname[IFNAMSIZ];	/* external name (name + unit) */
-	int	if_pcount;		/* number of promiscuous listeners */
-	struct bpf_if *if_bpf;		/* packet filter structure */
-	if_index_t	if_index;	/* numeric abbreviation for this if */
-	short	if_timer;		/* time 'til if_slowtimo called */
-	unsigned short	if_flags;	/* up/down, broadcast, etc. */
-	short	if_extflags;		/* if_output MP-safe, etc. */
-	struct	if_data if_data;	/* statistics and other data about if */
+	TAILQ_ENTRY(ifnet)
+			if_list;	/* i: all struct ifnets are chained */
+	TAILQ_HEAD(, ifaddr)
+			if_addrlist;	/* i: linked list of addresses per if */
+	char		if_xname[IFNAMSIZ];
+	/* :: external name (name + unit) */
+	int		if_pcount;	/* i: number of promiscuous listeners */
+	struct bpf_if	*if_bpf;	/* :: packet filter structure */
+	if_index_t	if_index;	/* :: numeric abbreviation for this if */
+	short		if_timer;	/* ?: time 'til if_slowtimo called */
+	unsigned short	if_flags;	/* i: up/down, broadcast, etc. */
+	short		if_extflags;	/* :: if_output MP-safe, etc. */
+	struct if_data	if_data;	/* ?: statistics and other data about if */
 	/*
 	 * Procedure handles.  If you add more of these, don't forget the
 	 * corresponding NULL stub in if.c.
 	 */
-	int	(*if_output)		/* output routine (enqueue) */
-		(struct ifnet *, struct mbuf *, const struct sockaddr *,
-		 const struct rtentry *);
-	void	(*_if_input)		/* input routine (from h/w driver) */
-		(struct ifnet *, struct mbuf *);
-	void	(*if_start)		/* initiate output routine */
-		(struct ifnet *);
-	int	(*if_transmit)		/* output routine, must be MP-safe */
-		(struct ifnet *, struct mbuf *);
-	int	(*if_ioctl)		/* ioctl routine */
-		(struct ifnet *, u_long, void *);
-	int	(*if_init)		/* init routine */
-		(struct ifnet *);
-	void	(*if_stop)		/* stop routine */
-		(struct ifnet *, int);
-	void	(*if_slowtimo)		/* timer routine */
-		(struct ifnet *);
+	int		(*if_output)	/* :: output routine (enqueue) */
+			(struct ifnet *, struct mbuf *, const struct sockaddr *,
+			 const struct rtentry *);
+	void		(*_if_input)	/* :: input routine (from h/w driver) */
+			(struct ifnet *, struct mbuf *);
+	void		(*if_start)	/* :: initiate output routine */
+			(struct ifnet *);
+	int		(*if_transmit)	/* :: output routine, must be MP-safe */
+			(struct ifnet *, struct mbuf *);
+	int		(*if_ioctl)	/* :: ioctl routine */
+			(struct ifnet *, u_long, void *);
+	int		(*if_init)	/* :: init routine */
+			(struct ifnet *);
+	void		(*if_stop)	/* :: stop routine */
+			(struct ifnet *, int);
+	void		(*if_slowtimo)	/* :: timer routine */
+			(struct ifnet *);
 #define	if_watchdog	if_slowtimo
-	void	(*if_drain)		/* routine to release resources */
-		(struct ifnet *);
-	struct ifaltq if_snd;		/* output queue (includes altq) */
-	struct ifaddr	*if_dl;		/* identity of this interface. */
-	const struct	sockaddr_dl *if_sadl;	/* pointer to sockaddr_dl
-		 * of if_dl
-		 */
-	/* if_hwdl: h/w identity
-	 *
+	void		(*if_drain)	/* :: routine to release resources */
+			(struct ifnet *);
+	struct ifaltq	if_snd;		/* q: output queue (includes 

CVS commit: src/sys/net

2017-12-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Dec 15 04:07:20 UTC 2017

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

Log Message:
Write a guideline for converting an interface to IFEF_MPSAFE

Requested by skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/net/if.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/net/if.h
diff -u src/sys/net/if.h:1.255 src/sys/net/if.h:1.256
--- src/sys/net/if.h:1.255	Fri Dec 15 04:06:42 2017
+++ src/sys/net/if.h	Fri Dec 15 04:07:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.255 2017/12/15 04:06:42 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.256 2017/12/15 04:07:20 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -427,11 +427,33 @@ typedef struct ifnet {
 #define	IFEF_NO_LINK_STATE_CHANGE	__BIT(1)	/* doesn't use link state interrupts */
 
 /*
- * The following if_XXX() handlers don't take KERNEL_LOCK if the interface
- * is set IFEF_MPSAFE:
- *   - if_start
- *   - if_output
- *   - if_ioctl
+ * The guidelines for converting an interface to IFEF_MPSAFE are as follows
+ *
+ * Enabling IFEF_MPSAFE on an interface suppresses taking KERNEL_LOCK when
+ * calling the following handlers:
+ * - if_start
+ *   - Note that if_transmit is always called without KERNEL_LOCK
+ * - if_output
+ * - if_ioctl
+ * - if_init
+ * - if_stop
+ *
+ * This means that an interface with IFEF_MPSAFE must make the above handlers
+ * MP-safe or take KERNEL_LOCK by itself inside handlers that aren't MP-safe
+ * yet.
+ *
+ * There are some additional restrictions to access member variables of struct
+ * ifnet:
+ * - if_flags
+ *   - Must be updated with holding IFNET_LOCK
+ *   - You cannot use the flag in Tx/Rx paths anymore because there is no
+ * synchronization on the flag except for IFNET_LOCK
+ * - if_watchdog and if_timer
+ *   - The watchdog framework works only for non-IFEF_MPSAFE interfaces
+ * that rely on KERNEL_LOCK
+ *   - Interfaces with IFEF_MPSAFE have to provide its own watchdog mechanism
+ * if needed
+ * - Keep if_watchdog NULL when calling if_attach
  */
 
 #ifdef _KERNEL



CVS commit: src/sys/net

2017-12-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Dec 15 04:04:59 UTC 2017

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

Log Message:
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held


To generate a diff of this commit:
cvs rdiff -u -r1.415 -r1.416 src/sys/net/if.c

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

Modified files:

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.415 src/sys/net/if.c:1.416
--- src/sys/net/if.c:1.415	Fri Dec 15 04:03:46 2017
+++ src/sys/net/if.c	Fri Dec 15 04:04:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.415 2017/12/15 04:03:46 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.416 2017/12/15 04:04:58 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.415 2017/12/15 04:03:46 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.416 2017/12/15 04:04:58 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1792,11 +1792,18 @@ ifa_insert(struct ifnet *ifp, struct ifa
 
 	ifa->ifa_ifp = ifp;
 
-	IFNET_GLOBAL_LOCK();
+	/*
+	 * Check !IFF_RUNNING for initialization routines that normally don't
+	 * take IFNET_LOCK but it's safe because there is no competitor.
+	 * XXX there are false positive cases because IFF_RUNNING can be off on
+	 * if_stop.
+	 */
+	KASSERT(!ISSET(ifp->if_flags, IFF_RUNNING) ||
+	IFNET_LOCKED(ifp));
+
 	TAILQ_INSERT_TAIL(>if_addrlist, ifa, ifa_list);
 	IFADDR_ENTRY_INIT(ifa);
 	IFADDR_WRITER_INSERT_TAIL(ifp, ifa);
-	IFNET_GLOBAL_UNLOCK();
 
 	ifaref(ifa);
 }
@@ -1806,14 +1813,19 @@ ifa_remove(struct ifnet *ifp, struct ifa
 {
 
 	KASSERT(ifa->ifa_ifp == ifp);
+	/*
+	 * if_is_deactivated indicates ifa_remove is called form if_detach
+	 * where is safe even if IFNET_LOCK isn't held.
+	 */
+	KASSERT(if_is_deactivated(ifp) || IFNET_LOCKED(ifp));
 
-	IFNET_GLOBAL_LOCK();
 	TAILQ_REMOVE(>if_addrlist, ifa, ifa_list);
 	IFADDR_WRITER_REMOVE(ifa);
 #ifdef NET_MPSAFE
+	IFNET_GLOBAL_LOCK();
 	pserialize_perform(ifnet_psz);
-#endif
 	IFNET_GLOBAL_UNLOCK();
+#endif
 
 #ifdef NET_MPSAFE
 	psref_target_destroy(>ifa_psref, ifa_psref_class);



CVS commit: src/sys

2017-12-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Dec 15 04:03:46 UTC 2017

Modified Files:
src/sys/net: if.c if.h if_vlan.c
src/sys/netinet: in.c in_pcb.c ip_output.c
src/sys/netinet6: in6.c in6_pcb.c ip6_output.c nd6.c nd6_rtr.c

Log Message:
Ensure to call if_mcast_op with holding IFNET_LOCK

Note that CARP doesn't deal with IFNET_LOCK yet.


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.415 src/sys/net/if.c
cvs rdiff -u -r1.253 -r1.254 src/sys/net/if.h
cvs rdiff -u -r1.119 -r1.120 src/sys/net/if_vlan.c
cvs rdiff -u -r1.210 -r1.211 src/sys/netinet/in.c
cvs rdiff -u -r1.179 -r1.180 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.286 -r1.287 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.254 -r1.255 src/sys/netinet6/in6.c
cvs rdiff -u -r1.161 -r1.162 src/sys/netinet6/in6_pcb.c
cvs rdiff -u -r1.195 -r1.196 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.239 -r1.240 src/sys/netinet6/nd6.c
cvs rdiff -u -r1.135 -r1.136 src/sys/netinet6/nd6_rtr.c

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

Modified files:

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.414 src/sys/net/if.c:1.415
--- src/sys/net/if.c:1.414	Thu Dec 14 05:46:54 2017
+++ src/sys/net/if.c	Fri Dec 15 04:03:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.414 2017/12/14 05:46:54 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.415 2017/12/15 04:03:46 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.414 2017/12/14 05:46:54 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.415 2017/12/15 04:03:46 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2721,12 +2721,27 @@ if_put(const struct ifnet *ifp, struct p
 	psref_release(psref, >if_psref, ifnet_psref_class);
 }
 
+/*
+ * Return ifp having idx. Return NULL if not found.  Normally if_byindex
+ * should be used.
+ */
+ifnet_t *
+_if_byindex(u_int idx)
+{
+
+	return (__predict_true(idx < if_indexlim)) ? ifindex2ifnet[idx] : NULL;
+}
+
+/*
+ * Return ifp having idx. Return NULL if not found or the found ifp is
+ * already deactivated.
+ */
 ifnet_t *
 if_byindex(u_int idx)
 {
 	ifnet_t *ifp;
 
-	ifp = (__predict_true(idx < if_indexlim)) ? ifindex2ifnet[idx] : NULL;
+	ifp = _if_byindex(idx);
 	if (ifp != NULL && if_is_deactivated(ifp))
 		ifp = NULL;
 	return ifp;
@@ -3570,6 +3585,10 @@ if_mcast_op(ifnet_t *ifp, const unsigned
 	int rc;
 	struct ifreq ifr;
 
+	/* CARP still doesn't deal with the lock yet */
+#if !defined(NCARP) || (NCARP == 0)
+	KASSERT(IFNET_LOCKED(ifp));
+#endif
 	if (ifp->if_mcastop != NULL)
 		rc = (*ifp->if_mcastop)(ifp, cmd, sa);
 	else {

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.253 src/sys/net/if.h:1.254
--- src/sys/net/if.h:1.253	Mon Dec 11 03:29:20 2017
+++ src/sys/net/if.h	Fri Dec 15 04:03:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.253 2017/12/11 03:29:20 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.254 2017/12/15 04:03:46 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1026,6 +1026,7 @@ int	if_clone_list(int, char *, int *);
 struct	ifnet *ifunit(const char *);
 struct	ifnet *if_get(const char *, struct psref *);
 ifnet_t *if_byindex(u_int);
+ifnet_t *_if_byindex(u_int);
 ifnet_t *if_get_byindex(u_int, struct psref *);
 ifnet_t *if_get_bylla(const void *, unsigned char, struct psref *);
 void	if_put(const struct ifnet *, struct psref *);

Index: src/sys/net/if_vlan.c
diff -u src/sys/net/if_vlan.c:1.119 src/sys/net/if_vlan.c:1.120
--- src/sys/net/if_vlan.c:1.119	Mon Dec 11 03:29:20 2017
+++ src/sys/net/if_vlan.c	Fri Dec 15 04:03:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vlan.c,v 1.119 2017/12/11 03:29:20 ozaki-r Exp $	*/
+/*	$NetBSD: if_vlan.c,v 1.120 2017/12/15 04:03:46 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.119 2017/12/11 03:29:20 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.120 2017/12/15 04:03:46 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1160,7 +1160,9 @@ vlan_ether_addmulti(struct ifvlan *ifv, 
 	mib = ifv->ifv_mib;
 
 	KERNEL_LOCK_UNLESS_IFP_MPSAFE(mib->ifvm_p);
+	IFNET_LOCK(mib->ifvm_p);
 	error = if_mcast_op(mib->ifvm_p, SIOCADDMULTI, sa);
+	IFNET_UNLOCK(mib->ifvm_p);
 	KERNEL_UNLOCK_UNLESS_IFP_MPSAFE(mib->ifvm_p);
 
 	if (error != 0)
@@ -1201,7 +1203,9 @@ vlan_ether_delmulti(struct ifvlan *ifv, 
 
 	/* We no longer use this multicast address.  Tell parent so. */
 	mib = ifv->ifv_mib;
+	IFNET_LOCK(mib->ifvm_p);
 	error = if_mcast_op(mib->ifvm_p, SIOCDELMULTI, sa);
+	IFNET_UNLOCK(mib->ifvm_p);
 
 	if (error == 0) {
 		/* And forget about this address. */
@@ -1236,8 +1240,10 @@ vlan_ether_purgemulti(struct ifvlan *ifv
 	}
 
 	while ((mc = LIST_FIRST(>ifv_mc_listhead)) != NULL) {
+		IFNET_LOCK(mib->ifvm_p);
 		

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

2017-12-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec 15 02:24:22 UTC 2017

Modified Files:
src/sys/arch/arm/sunxi: sun6i_dma.c

Log Message:
match allwinner,sun50i-a64-dma


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sunxi/sun6i_dma.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/sunxi/sun6i_dma.c
diff -u src/sys/arch/arm/sunxi/sun6i_dma.c:1.2 src/sys/arch/arm/sunxi/sun6i_dma.c:1.3
--- src/sys/arch/arm/sunxi/sun6i_dma.c:1.2	Sun Aug  6 17:13:15 2017
+++ src/sys/arch/arm/sunxi/sun6i_dma.c	Fri Dec 15 02:24:22 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: sun6i_dma.c,v 1.2 2017/08/06 17:13:15 jmcneill Exp $ */
+/* $NetBSD: sun6i_dma.c,v 1.3 2017/12/15 02:24:22 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun6i_dma.c,v 1.2 2017/08/06 17:13:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun6i_dma.c,v 1.3 2017/12/15 02:24:22 jmcneill Exp $");
 
 #include 
 #include 
@@ -96,6 +96,7 @@ static const struct of_compat_data compa
 	{ "allwinner,sun6i-a31-dma",		16 },
 	{ "allwinner,sun8i-a83t-dma",		8 },
 	{ "allwinner,sun8i-h3-dma",		12 },
+	{ "allwinner,sun50i-a64-dma",		8 },
 	{ NULL }
 };
 



CVS commit: src/sys/kern

2017-12-14 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Dec 14 22:29:00 UTC 2017

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

Log Message:
Remove the check for duplicate-module-name-on-pending-list since it really
doesn't help.  The check really cannot fail, and it only looks at the list
belonging to the current level of recursion.

Instead, verify that the module's modcmd(MODULE_CMD_INIT, ...) does not
introduce a duplicate module name as a result of recursively calling
module_do_load().


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/kern/kern_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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.129 src/sys/kern/kern_module.c:1.130
--- src/sys/kern/kern_module.c:1.129	Thu Dec 14 11:45:40 2017
+++ src/sys/kern/kern_module.c	Thu Dec 14 22:28:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.129 2017/12/14 11:45:40 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.130 2017/12/14 22:28:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.129 2017/12/14 11:45:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.130 2017/12/14 22:28:59 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1047,18 +1047,7 @@ module_do_load(const char *name, bool is
 	 */
 	if (mod->mod_source == MODULE_SOURCE_FILESYS) {
 		mod2 = module_lookup(mod->mod_info->mi_name);
-		if (mod2 == NULL) {
-			TAILQ_FOREACH(mod2, pending, mod_chain) {
-if (strcmp(mod2->mod_info->mi_name, name) == 0) {
-	break;
-}
-			}
-		}
-
-		if (mod2 == NULL) {
-			module_error("newly added module `%s'"
-			" not found", mod->mod_info->mi_name);
-		} else if (mod2 != mod) {
+		if ( mod2 && mod2 != mod) {
 			module_error("module with name `%s' already loaded",
 			mod2->mod_info->mi_name);
 			error = EEXIST;
@@ -1161,6 +1150,18 @@ module_do_load(const char *name, bool is
 	}
 
 	/*
+	 * If a recursive load already added a module with the same
+	 * name, abort.
+	 */
+	mod2 = module_lookup(mi->mi_name);
+	if (mod2 && mod2 != mod) {
+		module_error("recursive load causes duplicate module `%s'",
+		mi->mi_name);
+		error = EEXIST;
+		goto fail1;
+	}
+
+	/*
 	 * Good, the module loaded successfully.  Put it onto the
 	 * list and add references to its requisite modules.
 	 */
@@ -1182,6 +1183,8 @@ module_do_load(const char *name, bool is
 	module_print("module `%s' loaded successfully", mi->mi_name);
 	return 0;
 
+ fail1:
+	(*mi->mi_modcmd)(MODULE_CMD_FINI, NULL);
  fail:
 	kobj_unload(mod->mod_kobj);
  fail2:



CVS commit: src/usr.sbin/mtree

2017-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 14 18:34:41 UTC 2017

Modified Files:
src/usr.sbin/mtree: create.c spec.c specspec.c

Log Message:
use uintmax_t for nlink_t from FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/mtree/create.c
cvs rdiff -u -r1.89 -r1.90 src/usr.sbin/mtree/spec.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/mtree/specspec.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/mtree/create.c
diff -u src/usr.sbin/mtree/create.c:1.73 src/usr.sbin/mtree/create.c:1.74
--- src/usr.sbin/mtree/create.c:1.73	Thu Apr 24 13:22:41 2014
+++ src/usr.sbin/mtree/create.c	Thu Dec 14 13:34:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: create.c,v 1.74 2017/12/14 18:34:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)create.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: create.c,v 1.73 2014/04/24 17:22:41 christos Exp $");
+__RCSID("$NetBSD: create.c,v 1.74 2017/12/14 18:34:41 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -224,7 +224,8 @@ statf(FILE *fp, int indent, FTSENT *p)
 		output(fp, indent, , "device=%#jx",
 		(uintmax_t)p->fts_statp->st_rdev);
 	if (keys & F_NLINK && p->fts_statp->st_nlink != 1)
-		output(fp, indent, , "nlink=%u", p->fts_statp->st_nlink);
+		output(fp, indent, , "nlink=%ju",
+		(uintmax_t)p->fts_statp->st_nlink);
 	if (keys & F_SIZE &&
 	(flavor == F_FREEBSD9 || S_ISREG(p->fts_statp->st_mode)))
 		output(fp, indent, , "size=%ju",

Index: src/usr.sbin/mtree/spec.c
diff -u src/usr.sbin/mtree/spec.c:1.89 src/usr.sbin/mtree/spec.c:1.90
--- src/usr.sbin/mtree/spec.c:1.89	Thu Apr 24 13:22:41 2014
+++ src/usr.sbin/mtree/spec.c	Thu Dec 14 13:34:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec.c,v 1.89 2014/04/24 17:22:41 christos Exp $	*/
+/*	$NetBSD: spec.c,v 1.90 2017/12/14 18:34:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = "@(#)spec.c	8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: spec.c,v 1.89 2014/04/24 17:22:41 christos Exp $");
+__RCSID("$NetBSD: spec.c,v 1.90 2017/12/14 18:34:41 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -363,7 +363,8 @@ dump_nodes(FILE *fp, const char *dir, NO
 			appendfield(fp, pathlast, "device=%#jx",
 			(uintmax_t)cur->st_rdev);
 		if (MATCHFLAG(F_NLINK))
-			appendfield(fp, pathlast, "nlink=%d", cur->st_nlink);
+			appendfield(fp, pathlast, "nlink=%ju",
+			(uintmax_t)cur->st_nlink);
 		if (MATCHFLAG(F_SLINK))
 			appendfield(fp, pathlast, "link=%s",
 			vispath(cur->slink));

Index: src/usr.sbin/mtree/specspec.c
diff -u src/usr.sbin/mtree/specspec.c:1.3 src/usr.sbin/mtree/specspec.c:1.4
--- src/usr.sbin/mtree/specspec.c:1.3	Wed Jan  7 15:50:36 2015
+++ src/usr.sbin/mtree/specspec.c	Thu Dec 14 13:34:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: specspec.c,v 1.3 2015/01/07 20:50:36 joerg Exp $	*/
+/*	$NetBSD: specspec.c,v 1.4 2017/12/14 18:34:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 Poul-Henning Kamp
@@ -31,7 +31,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: specspec.c,v 1.3 2015/01/07 20:50:36 joerg Exp $");
+__RCSID("$NetBSD: specspec.c,v 1.4 2017/12/14 18:34:41 christos Exp $");
 
 #include 
 #include 
@@ -73,7 +73,7 @@ shownode(NODE *n, int f, char const *pat
 	if (f & F_MODE)
 		printf(" mode=%o", n->st_mode);
 	if (f & F_NLINK)
-		printf(" nlink=%d", (int)n->st_nlink);
+		printf(" nlink=%ju", (uintmax_t)n->st_nlink);
 	if (f & F_SIZE)
 		printf(" size=%jd", (intmax_t)n->st_size);
 	if (f & F_UID)



CVS commit: src/doc

2017-12-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Dec 14 16:49:12 UTC 2017

Modified Files:
src/doc: 3RDPARTY

Log Message:
dtc 1.4.5 is the latest release


To generate a diff of this commit:
cvs rdiff -u -r1.1490 -r1.1491 src/doc/3RDPARTY

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.1490 src/doc/3RDPARTY:1.1491
--- src/doc/3RDPARTY:1.1490	Thu Dec 14 16:48:28 2017
+++ src/doc/3RDPARTY	Thu Dec 14 16:49:11 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1490 2017/12/14 16:48:28 jmcneill Exp $
+#	$NetBSD: 3RDPARTY,v 1.1491 2017/12/14 16:49:11 jmcneill Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1705,7 +1705,7 @@ Notes:
 
 Package:	dtc,libfdt
 Version:	1.4.4
-Current Vers:	1.4.4
+Current Vers:	1.4.5
 Maintainer:	David Gibson , Jon Loeliger 
 Archive Site:	https://git.kernel.org/pub/scm/utils/dtc/dtc.git
 Home Page:	https://git.kernel.org/pub/scm/utils/dtc/dtc.git



CVS commit: src/doc

2017-12-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Dec 14 16:48:28 UTC 2017

Modified Files:
src/doc: 3RDPARTY

Log Message:
gnu-efi 3.0.6 is the latest release


To generate a diff of this commit:
cvs rdiff -u -r1.1489 -r1.1490 src/doc/3RDPARTY

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.1489 src/doc/3RDPARTY:1.1490
--- src/doc/3RDPARTY:1.1489	Wed Dec  6 10:37:08 2017
+++ src/doc/3RDPARTY	Thu Dec 14 16:48:28 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1489 2017/12/06 10:37:08 roy Exp $
+#	$NetBSD: 3RDPARTY,v 1.1490 2017/12/14 16:48:28 jmcneill Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1681,7 +1681,7 @@ Location:   usr.bin/nc
 
 Package:	gnu-efi
 Version:	3.0u
-Current Vers:	3.0.5
+Current Vers:	3.0.6
 Maintainer:	https://sourceforge.net/projects/gnu-efi/
 Archive Site:	https://sourceforge.net/projects/gnu-efi/
 Home Page:	https://sourceforge.net/projects/gnu-efi/



CVS commit: src/tests/kernel

2017-12-14 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Thu Dec 14 14:38:17 UTC 2017

Modified Files:
src/tests/kernel: Makefile

Log Message:
Use SCRIPTS instead of PROGS to avoid strip(1) if STRIPFLAG=-s.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/tests/kernel/Makefile

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/Makefile
diff -u src/tests/kernel/Makefile:1.51 src/tests/kernel/Makefile:1.52
--- src/tests/kernel/Makefile:1.51	Tue Dec 12 18:19:45 2017
+++ src/tests/kernel/Makefile	Thu Dec 14 14:38:17 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.51 2017/12/12 18:19:45 christos Exp $
+# $NetBSD: Makefile,v 1.52 2017/12/14 14:38:17 nakayama Exp $
 
 NOMAN=		# defined
 
@@ -29,8 +29,9 @@ PROGS=		h_ps_strings1
 PROGS+=		h_ps_strings2
 PROGS+=		h_segv
 PROGS+=		h_getprocpath
-PROGS+=		h_interpreter
-SRCS.h_interpreter += h_interpreter.sh
+
+SCRIPTSDIR=	${TESTSDIR}
+SCRIPTS=	h_interpreter.sh
 
 LDADD.t_mqueue+= -lrt
 



CVS commit: src/usr.sbin/sysinst/arch/evbarm

2017-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Dec 14 14:12:39 UTC 2017

Modified Files:
src/usr.sbin/sysinst/arch/evbarm: md.c

Log Message:
Fix RPI kernel file after FDTisation.

>From Harold Gutch


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/arch/evbarm/md.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/sysinst/arch/evbarm/md.c
diff -u src/usr.sbin/sysinst/arch/evbarm/md.c:1.4 src/usr.sbin/sysinst/arch/evbarm/md.c:1.5
--- src/usr.sbin/sysinst/arch/evbarm/md.c:1.4	Sun May 10 10:14:02 2015
+++ src/usr.sbin/sysinst/arch/evbarm/md.c	Thu Dec 14 14:12:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
+/*	$NetBSD: md.c,v 1.5 2017/12/14 14:12:39 skrll Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -209,7 +209,7 @@ md_post_extract(void)
 	if (boardtype == BOARD_TYPE_NORMAL)
 		return 0;
 	if (boardtype == BOARD_TYPE_RPI) {
-		snprintf(kernelbin, 100, "%s/netbsd.bin", targetroot_mnt);
+		snprintf(kernelbin, 100, "%s/netbsd.img", targetroot_mnt);
 		if (file_exists_p(kernelbin)) {
 			run_program(RUN_DISPLAY,
 			"/bin/cp %s /targetroot/boot/kernel.img", kernelbin);



CVS commit: src/sys/kern

2017-12-14 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Dec 14 11:45:40 UTC 2017

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

Log Message:
When looking for a duplicate module name, also check the pending list.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/kern/kern_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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.128 src/sys/kern/kern_module.c:1.129
--- src/sys/kern/kern_module.c:1.128	Thu Dec 14 10:39:32 2017
+++ src/sys/kern/kern_module.c	Thu Dec 14 11:45:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.128 2017/12/14 10:39:32 martin Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.129 2017/12/14 11:45:40 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.128 2017/12/14 10:39:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.129 2017/12/14 11:45:40 pgoyette Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1048,6 +1048,14 @@ module_do_load(const char *name, bool is
 	if (mod->mod_source == MODULE_SOURCE_FILESYS) {
 		mod2 = module_lookup(mod->mod_info->mi_name);
 		if (mod2 == NULL) {
+			TAILQ_FOREACH(mod2, pending, mod_chain) {
+if (strcmp(mod2->mod_info->mi_name, name) == 0) {
+	break;
+}
+			}
+		}
+
+		if (mod2 == NULL) {
 			module_error("newly added module `%s'"
 			" not found", mod->mod_info->mi_name);
 		} else if (mod2 != mod) {



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

2017-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 14 11:39:31 UTC 2017

Modified Files:
src/sys/arch/evbarm/fdt: fdt_machdep.c

Log Message:
Fix the calculation of the end address of a reserved memory range.
>From Nick. Makes my CubieTruck boot again.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/fdt/fdt_machdep.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/evbarm/fdt/fdt_machdep.c
diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.17 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.18
--- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.17	Wed Dec 13 00:22:24 2017
+++ src/sys/arch/evbarm/fdt/fdt_machdep.c	Thu Dec 14 11:39:31 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.17 2017/12/13 00:22:24 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.18 2017/12/14 11:39:31 martin Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.17 2017/12/13 00:22:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.18 2017/12/14 11:39:31 martin Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -178,17 +178,16 @@ fdt_get_memory(uint64_t *paddr, uint64_t
 void
 fdt_add_reserved_memory_range(uint64_t addr, uint64_t size)
 {
-	int error;
+	uint64_t start = trunc_page(addr);
+	uint64_t end = round_page(addr + size);
 
-	addr = trunc_page(addr);
-	size = round_page(size);
-
-	error = extent_free(fdt_memory_ext, addr, size, EX_NOWAIT);
+	int error = extent_free(fdt_memory_ext, start,
+	 end - start, EX_NOWAIT);
 	if (error != 0)
 		printf("MEM ERROR: res %llx-%llx failed: %d\n",
-		addr, addr + size, error);
+		start, end, error);
 	else
-		DPRINTF("MEM: res %llx-%llx\n", addr, addr + size);
+		DPRINTF("MEM: res %llx-%llx\n", start, end);
 }
 
 /*
@@ -242,8 +241,8 @@ fdt_build_bootconfig(uint64_t mem_addr, 
 		EX_NOWAIT);
 		if (error != 0)
 			printf("MEM ERROR: add %llx-%llx failed: %d\n",
-			addr, size, error);
-		DPRINTF("MEM: add %llx-%llx\n", addr, size);
+			addr, addr + size, error);
+		DPRINTF("MEM: add %llx-%llx\n", addr, addr + size);
 	}
 
 	fdt_add_reserved_memory(max_addr);



CVS commit: src/sys/kern

2017-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 14 10:39:32 UTC 2017

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

Log Message:
Change a KASSERTMSG into a regular module_error - not nice for the kernel
to panic when I try to modload the 'ntfs' module.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/kern/kern_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/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.127 src/sys/kern/kern_module.c:1.128
--- src/sys/kern/kern_module.c:1.127	Mon Dec 11 22:00:26 2017
+++ src/sys/kern/kern_module.c	Thu Dec 14 10:39:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.127 2017/12/11 22:00:26 pgoyette Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.128 2017/12/14 10:39:32 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.127 2017/12/11 22:00:26 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.128 2017/12/14 10:39:32 martin Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1047,8 +1047,10 @@ module_do_load(const char *name, bool is
 	 */
 	if (mod->mod_source == MODULE_SOURCE_FILESYS) {
 		mod2 = module_lookup(mod->mod_info->mi_name);
-		KASSERTMSG(mod2, "Newly added module not found!");
-		if (mod2 != mod) {
+		if (mod2 == NULL) {
+			module_error("newly added module `%s'"
+			" not found", mod->mod_info->mi_name);
+		} else if (mod2 != mod) {
 			module_error("module with name `%s' already loaded",
 			mod2->mod_info->mi_name);
 			error = EEXIST;



CVS commit: src/share/misc

2017-12-14 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Dec 14 10:34:06 UTC 2017

Modified Files:
src/share/misc: bsd-family-tree

Log Message:
Fixup bsd family tree for netbsd after PR misc/52808
add netbsd 7.0.2 too.

requested by phone who is actually paying attention.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/share/misc/bsd-family-tree

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

Modified files:

Index: src/share/misc/bsd-family-tree
diff -u src/share/misc/bsd-family-tree:1.61 src/share/misc/bsd-family-tree:1.62
--- src/share/misc/bsd-family-tree:1.61	Wed Dec 13 11:17:54 2017
+++ src/share/misc/bsd-family-tree	Thu Dec 14 10:34:06 2017
@@ -339,28 +339,29 @@ FreeBSD 5.2   |  |  
  | |  |  | |   DragonFly 4.2.0
  |  FreeBSD   |  | |   |
  |   10.2 |  | |   |
- | |macOS  NetBSD 7.0   |   |
- | |10.11|OpenBSD 5.8  |
- | |  |  | |   DragonFly 4.4.1
- |  FreeBSD   |  |OpenBSD 5.9  |
- |   10.3 |  | |   |
- | |  |   NetBSD 7.0.1 |   |
- | `--.   |  | |   DragonFly 4.6.0
- ||   |  | |   |
- ||   |  | |   |
- *--FreeBSD   | macOS|OpenBSD 6.0  |
- |   11.0 | 10.12| |   |
- | |  |   |   NetBSD 7.1   |   |
- | |  | macOS| |   DragonFly 4.8.0
- | |  | 10.13|OpenBSD 6.1  |
- |  FreeBSD   |   |  | |   |
- |   11.1  FreeBSD|  | |   |
- | |10.4  |  |OpenBSD 6.2  |
- | v  |  | |   DragonFly 5.0.0
- ||  | |   |
-FreeBSD 12 -current   |  NetBSD -current  OpenBSD -currentDragonFly -current
- ||  | |   |
- vv  v v   v
+ | |macOS  NetBSD 7.0  |   |
+ | |10.11   | | | OpenBSD 5.8  |
+ | |  | | | `--.   |   DragonFly 4.4.1
+ |  FreeBSD   | | ||  OpenBSD 5.9  |
+ |   10.3 | | ||   |   |
+ | |  | | | NetBSD 7.0.1   |   |
+ | `--.   | | ||   |   DragonFly 4.6.0
+ ||   | | ||   |   |
+ ||   | | ||   |   |
+ *--FreeBSD   | macOS   | ||  OpenBSD 6.0  |
+ |   11.0 | 10.12   | | NetBSD 7.0.2   |   |
+ | |  |   | | ||   |
+ | |  |   | | *- NetBSD 7.1|   |
+ | |  | macOS   |  |   DragonFly 4.8.0
+ | |  | 10.13   | OpenBSD 6.1  |
+ |  FreeBSD   |   | |  |   |
+ |   11.1  FreeBSD| |  |   |
+ | |10.4  | | OpenBSD 6.2  |
+ | v  | |  |   DragonFly 5.0.0
+ || |  |   |
+FreeBSD 12 -current   | NetBSD -current   OpenBSD -currentDragonFly -current
+ || |  |   |
+ vv v  v   v
 
 Time
 
@@ -712,6 +713,7 @@ NetBSD 7.0.1		2016-05-22 [NBD]
 DragonFly 4.6.0		2016-08-02 [DFB]
 OpenBSD 6.0		2016-09-01 [OBD]
 macOS 10.12		2016-09-20 [APL]
+NetBSD 7.0.2		2016-10-21 [NBD]
 FreeBSD 11.0		2016-10-10 [FBD]
 NetBSD 7.1		2017-03-11 [NBD]
 DragonFly 4.8.0		2017-03-27 [DFB]
@@ -786,4 +788,4 @@ Copyright (c) 1997-2012 Wolfram Schneide
 URL: http://svnweb.freebsd.org/base/head/share/misc/bsd-family-tree
 
 $FreeBSD: head/share/misc/bsd-family-tree 326724 2017-12-09 05:05:25Z imp $
-$NetBSD: bsd-family-tree,v 1.61 2017/12/13