CVS commit: src/tests/net

2016-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun 21 05:04:16 UTC 2016

Modified Files:
src/tests/net/arp: t_arp.sh
src/tests/net/if: t_ifconfig.sh
src/tests/net/if_bridge: t_bridge.sh
src/tests/net/if_tap: t_tap.sh
src/tests/net/ndp: t_ndp.sh
src/tests/net/net: t_forwarding.sh
src/tests/net/route: t_flags.sh t_route.sh

Log Message:
Make a bunch of test names self-descriptive


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/net/arp/t_arp.sh
cvs rdiff -u -r1.9 -r1.10 src/tests/net/if/t_ifconfig.sh
cvs rdiff -u -r1.11 -r1.12 src/tests/net/if_bridge/t_bridge.sh
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_tap/t_tap.sh
cvs rdiff -u -r1.11 -r1.12 src/tests/net/ndp/t_ndp.sh
cvs rdiff -u -r1.12 -r1.13 src/tests/net/net/t_forwarding.sh
cvs rdiff -u -r1.8 -r1.9 src/tests/net/route/t_flags.sh
cvs rdiff -u -r1.4 -r1.5 src/tests/net/route/t_route.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/arp/t_arp.sh
diff -u src/tests/net/arp/t_arp.sh:1.15 src/tests/net/arp/t_arp.sh:1.16
--- src/tests/net/arp/t_arp.sh:1.15	Mon Apr 18 02:27:34 2016
+++ src/tests/net/arp/t_arp.sh	Tue Jun 21 05:04:16 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_arp.sh,v 1.15 2016/04/18 02:27:34 ozaki-r Exp $
+#	$NetBSD: t_arp.sh,v 1.16 2016/06/21 05:04:16 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -39,65 +39,65 @@ IP4DST_PROXYARP2=10.0.1.4
 DEBUG=false
 TIMEOUT=1
 
-atf_test_case cache_expiration_5s cleanup
-atf_test_case cache_expiration_10s cleanup
-atf_test_case command cleanup
-atf_test_case garp cleanup
-atf_test_case cache_overwriting cleanup
-atf_test_case proxy_arp_pub cleanup
-atf_test_case proxy_arp_pubproxy cleanup
-atf_test_case link_activation cleanup
-atf_test_case static_arp cleanup
+atf_test_case arp_cache_expiration_5s cleanup
+atf_test_case arp_cache_expiration_10s cleanup
+atf_test_case arp_command cleanup
+atf_test_case arp_garp cleanup
+atf_test_case arp_cache_overwriting cleanup
+atf_test_case arp_proxy_arp_pub cleanup
+atf_test_case arp_proxy_arp_pubproxy cleanup
+atf_test_case arp_link_activation cleanup
+atf_test_case arp_static cleanup
 
-cache_expiration_5s_head()
+arp_cache_expiration_5s_head()
 {
 	atf_set "descr" "Tests for ARP cache expiration (5s)"
 	atf_set "require.progs" "rump_server"
 }
 
-cache_expiration_10s_head()
+arp_cache_expiration_10s_head()
 {
 	atf_set "descr" "Tests for ARP cache expiration (10s)"
 	atf_set "require.progs" "rump_server"
 }
 
-command_head()
+arp_command_head()
 {
-	atf_set "descr" "Tests for commands of arp(8)"
+	atf_set "descr" "Tests for arp_commands of arp(8)"
 	atf_set "require.progs" "rump_server"
 }
 
-garp_head()
+arp_garp_head()
 {
 	atf_set "descr" "Tests for GARP"
 	atf_set "require.progs" "rump_server"
 }
 
-cache_overwriting_head()
+arp_cache_overwriting_head()
 {
 	atf_set "descr" "Tests for behavior of overwriting ARP caches"
 	atf_set "require.progs" "rump_server"
 }
 
-proxy_arp_pub_head()
+arp_proxy_arp_pub_head()
 {
 	atf_set "descr" "Tests for Proxy ARP (pub)"
 	atf_set "require.progs" "rump_server"
 }
 
-proxy_arp_pubproxy_head()
+arp_proxy_arp_pubproxy_head()
 {
 	atf_set "descr" "Tests for Proxy ARP (pub proxy)"
 	atf_set "require.progs" "rump_server"
 }
 
-link_activation_head()
+arp_link_activation_head()
 {
 	atf_set "descr" "Tests for activating a new MAC address"
 	atf_set "require.progs" "rump_server"
 }
 
-static_arp_head()
+arp_static_head()
 {
 
 	atf_set "descr" "Tests for static ARP entries"
@@ -170,17 +170,17 @@ test_cache_expiration()
 	atf_check -s not-exit:0 -e ignore rump.arp -n $IP4DST
 }
 
-cache_expiration_5s_body()
+arp_cache_expiration_5s_body()
 {
 	test_cache_expiration 5
 }
 
-cache_expiration_10s_body()
+arp_cache_expiration_10s_body()
 {
 	test_cache_expiration 10
 }
 
-command_body()
+arp_command_body()
 {
 	local arp_keep=5
 	local bonus=2
@@ -269,7 +269,7 @@ make_pkt_str_arpreq()
 	echo $pkt
 }
 
-garp_body()
+arp_garp_body()
 {
 	local pkt=
 
@@ -306,7 +306,7 @@ garp_body()
 	atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
 }
 
-cache_overwriting_body()
+arp_cache_overwriting_body()
 {
 	local arp_keep=5
 	local bonus=2
@@ -478,19 +478,19 @@ test_proxy_arp()
 	atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP2
 }
 
-proxy_arp_pub_body()
+arp_proxy_arp_pub_body()
 {
 
 	test_proxy_arp pub
 }
 
-proxy_arp_pubproxy_body()
+arp_proxy_arp_pubproxy_body()
 {
 
 	test_proxy_arp pubproxy
 }
 
-link_activation_body()
+arp_link_activation_body()
 {
 	local arp_keep=5
 	local bonus=2
@@ -528,7 +528,7 @@ link_activation_body()
 	"cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'"
 }
 
-static_arp_body()
+arp_static_body()
 {
 	local arp_keep=5
 	local macaddr_src=
@@ -584,56 +584,56 @@ dump()
 	shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
 }
 

CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Jun 21 03:54:04 UTC 2016

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

Log Message:
fix ATF net/carp failure


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/net/if_ethersubr.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_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.224 src/sys/net/if_ethersubr.c:1.225
--- src/sys/net/if_ethersubr.c:1.224	Mon Jun 20 07:01:45 2016
+++ src/sys/net/if_ethersubr.c	Tue Jun 21 03:54:04 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.224 2016/06/20 07:01:45 knakahara Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.225 2016/06/21 03:54:04 knakahara Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.224 2016/06/20 07:01:45 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.225 2016/06/21 03:54:04 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -204,7 +204,12 @@ ether_output(struct ifnet * const ifp0, 
 	struct at_ifaddr *aa;
 #endif /* NETATALK */
 
-	KASSERT(ifp->if_extflags & IFEF_OUTPUT_MPSAFE);
+	/*
+	 * some paths such as carp_output() call ethr_output() with "ifp"
+	 * argument as other than ether ifnet.
+	 */
+	KASSERT(ifp->if_output != ether_output
+	|| ifp->if_extflags & IFEF_OUTPUT_MPSAFE);
 
 #ifdef MBUFTRACE
 	m_claimm(m, ifp->if_mowner);



CVS commit: src/sys/sys

2016-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun 21 03:34:23 UTC 2016

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

Log Message:
Bump kernel version for ip_moptions and ip6_moptions changes

And maybe if_output_lock changes also needed a bump?


To generate a diff of this commit:
cvs rdiff -u -r1.497 -r1.498 src/sys/sys/param.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/param.h
diff -u src/sys/sys/param.h:1.497 src/sys/sys/param.h:1.498
--- src/sys/sys/param.h:1.497	Thu Jun 16 02:54:41 2016
+++ src/sys/sys/param.h	Tue Jun 21 03:34:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.497 2016/06/16 02:54:41 ozaki-r Exp $	*/
+/*	$NetBSD: param.h,v 1.498 2016/06/21 03:34:22 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799003100	/* NetBSD 7.99.31 */
+#define	__NetBSD_Version__	799003200	/* NetBSD 7.99.32 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys

2016-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun 21 03:28:28 UTC 2016

Modified Files:
src/sys/dist/pf/net: if_pfsync.c
src/sys/net: if.h
src/sys/netinet: igmp.c in.c in_pcb.c ip_carp.c ip_mroute.c ip_output.c
ip_var.h
src/sys/netinet6: in6_pcb.c in6_src.c ip6_mroute.c ip6_output.c
ip6_var.h mld6.c nd6_nbr.c

Log Message:
Replace ifp of ip_moptions and ip6_moptions with if_index

The motivation is the same as the mbuf's rcvif case; avoid having a pointer
of an ifnet object in ip_moptions and ip6_moptions, which is not MP-safe.

ip_moptions and ip6_moptions can be stored in a PCB for inet or inet6
that's life time is different from ifnet one and so an ifnet object can be
disappeared anytime we get it via them. Thus we need to look up an ifnet
object by if_index every time for safe.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dist/pf/net/if_pfsync.c
cvs rdiff -u -r1.212 -r1.213 src/sys/net/if.h
cvs rdiff -u -r1.58 -r1.59 src/sys/netinet/igmp.c
cvs rdiff -u -r1.166 -r1.167 src/sys/netinet/in.c
cvs rdiff -u -r1.163 -r1.164 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.70 -r1.71 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.140 -r1.141 src/sys/netinet/ip_mroute.c
cvs rdiff -u -r1.257 -r1.258 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.113 -r1.114 src/sys/netinet/ip_var.h
cvs rdiff -u -r1.143 -r1.144 src/sys/netinet6/in6_pcb.c
cvs rdiff -u -r1.60 -r1.61 src/sys/netinet6/in6_src.c
cvs rdiff -u -r1.110 -r1.111 src/sys/netinet6/ip6_mroute.c
cvs rdiff -u -r1.167 -r1.168 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.65 -r1.66 src/sys/netinet6/ip6_var.h
cvs rdiff -u -r1.67 -r1.68 src/sys/netinet6/mld6.c
cvs rdiff -u -r1.119 -r1.120 src/sys/netinet6/nd6_nbr.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/dist/pf/net/if_pfsync.c
diff -u src/sys/dist/pf/net/if_pfsync.c:1.14 src/sys/dist/pf/net/if_pfsync.c:1.15
--- src/sys/dist/pf/net/if_pfsync.c:1.14	Fri Jun 10 13:31:44 2016
+++ src/sys/dist/pf/net/if_pfsync.c	Tue Jun 21 03:28:27 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_pfsync.c,v 1.14 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: if_pfsync.c,v 1.15 2016/06/21 03:28:27 ozaki-r Exp $	*/
 /*	$OpenBSD: if_pfsync.c,v 1.83 2007/06/26 14:44:12 mcbride Exp $	*/
 
 /*
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_pfsync.c,v 1.14 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pfsync.c,v 1.15 2016/06/21 03:28:27 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -941,7 +941,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cm
 			}
 			if (imo->imo_num_memberships > 0) {
 in_delmulti(imo->imo_membership[--imo->imo_num_memberships]);
-imo->imo_multicast_ifp = NULL;
+imo->imo_multicast_if_index = 0;
 			}
 			break;
 		}
@@ -961,7 +961,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cm
 
 		if (imo->imo_num_memberships > 0) {
 			in_delmulti(imo->imo_membership[--imo->imo_num_memberships]);
-			imo->imo_multicast_ifp = NULL;
+			imo->imo_multicast_if_index = 0;
 		}
 
 		if (sc->sc_sync_ifp &&
@@ -983,7 +983,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cm
 return (ENOBUFS);
 			}
 			imo->imo_num_memberships++;
-			imo->imo_multicast_ifp = sc->sc_sync_ifp;
+			imo->imo_multicast_if_index = if_get_index(sc->sc_sync_ifp);
 			imo->imo_multicast_ttl = PFSYNC_DFLTTL;
 			imo->imo_multicast_loop = 0;
 		}

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.212 src/sys/net/if.h:1.213
--- src/sys/net/if.h:1.212	Tue Jun 21 03:07:54 2016
+++ src/sys/net/if.h	Tue Jun 21 03:28:27 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.212 2016/06/21 03:07:54 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.213 2016/06/21 03:28:27 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -954,6 +954,13 @@ ifnet_t *if_get_byindex(u_int, struct ps
 void	if_put(const struct ifnet *, struct psref *);
 void	if_acquire_unsafe(struct ifnet *, struct psref *);
 
+static inline if_index_t
+if_get_index(const struct ifnet *ifp)
+{
+
+	return ifp != NULL ? ifp->if_index : 0;
+}
+
 bool	if_held(struct ifnet *);
 
 void	if_input(struct ifnet *, struct mbuf *);

Index: src/sys/netinet/igmp.c
diff -u src/sys/netinet/igmp.c:1.58 src/sys/netinet/igmp.c:1.59
--- src/sys/netinet/igmp.c:1.58	Fri Jun 10 13:31:44 2016
+++ src/sys/netinet/igmp.c	Tue Jun 21 03:28:27 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: igmp.c,v 1.58 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: igmp.c,v 1.59 2016/06/21 03:28:27 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.58 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.59 2016/06/21 03:28:27 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -618,7 +618,7 @@ igmp_sendpkt(struct in_multi *inm, int t
 	m->m_data -= sizeof(struct 

CVS commit: src/sys

2016-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun 21 03:07:55 UTC 2016

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

Log Message:
Introduce if_index_t


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/sys/net/if.h
cvs rdiff -u -r1.165 -r1.166 src/sys/sys/mbuf.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.211 src/sys/net/if.h:1.212
--- src/sys/net/if.h:1.211	Mon Jun 20 08:24:36 2016
+++ src/sys/net/if.h	Tue Jun 21 03:07:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.211 2016/06/20 08:24:36 knakahara Exp $	*/
+/*	$NetBSD: if.h,v 1.212 2016/06/21 03:07:54 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -231,6 +231,8 @@ struct callout;
 struct krwlock;
 struct if_percpuq;
 
+typedef unsigned short if_index_t;
+
 typedef struct ifnet {
 	void	*if_softc;		/* lower-level data for this if */
 	/* DEPRECATED. Keep it to avoid breaking kvm(3) users */
@@ -239,7 +241,7 @@ typedef struct ifnet {
 	char	if_xname[IFNAMSIZ];	/* external name (name + unit) */
 	int	if_pcount;		/* number of promiscuous listeners */
 	struct bpf_if *if_bpf;		/* packet filter structure */
-	u_short	if_index;		/* numeric abbreviation for this if */
+	if_index_t	if_index;	/* numeric abbreviation for this if */
 	short	if_timer;		/* time 'til if_slowtimo called */
 	short	if_flags;		/* up/down, broadcast, etc. */
 	short	if_extflags;		/* if_output MP-safe, etc. */

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.165 src/sys/sys/mbuf.h:1.166
--- src/sys/sys/mbuf.h:1.165	Sun Jun 12 10:14:12 2016
+++ src/sys/sys/mbuf.h	Tue Jun 21 03:07:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.165 2016/06/12 10:14:12 ozaki-r Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.166 2016/06/21 03:07:54 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -180,7 +180,7 @@ struct m_hdr {
 struct	pkthdr {
 	union {
 		void		*ctx;		/* for M_GETCTX/M_SETCTX */
-		uint16_t	index;		/* rcv interface index */
+		if_index_t	index;		/* rcv interface index */
 	} _rcvif;
 #define rcvif_index		_rcvif.index
 	SLIST_HEAD(packet_tags, m_tag) tags;	/* list of packet tags */



CVS commit: src/sys/netinet6

2016-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun 21 02:14:11 UTC 2016

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

Log Message:
Fix nd6_output (if_output_lock conversion mistake)


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 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/nd6.c
diff -u src/sys/netinet6/nd6.c:1.196 src/sys/netinet6/nd6.c:1.197
--- src/sys/netinet6/nd6.c:1.196	Mon Jun 20 06:46:38 2016
+++ src/sys/netinet6/nd6.c	Tue Jun 21 02:14:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.196 2016/06/20 06:46:38 knakahara Exp $	*/
+/*	$NetBSD: nd6.c,v 1.197 2016/06/21 02:14:11 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.196 2016/06/20 06:46:38 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.197 2016/06/21 02:14:11 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2292,7 +2292,7 @@ nd6_output(struct ifnet *ifp, struct ifn
 		LLE_WUNLOCK(ln);
 
 	if ((ifp->if_flags & IFF_LOOPBACK) != 0)
-		error = if_output_lock(origifp, origifp, m, sin6tocsa(dst), rt);
+		error = if_output_lock(ifp, origifp, m, sin6tocsa(dst), rt);
 	else
 		error = if_output_lock(ifp, ifp, m, sin6tocsa(dst), rt);
 	goto exit;



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 22:59:36 UTC 2016

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

Log Message:
fix: kern/51259


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/net/if_mpls.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_mpls.c
diff -u src/sys/net/if_mpls.c:1.24 src/sys/net/if_mpls.c:1.25
--- src/sys/net/if_mpls.c:1.24	Mon Jun 20 06:46:37 2016
+++ src/sys/net/if_mpls.c	Mon Jun 20 22:59:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mpls.c,v 1.24 2016/06/20 06:46:37 knakahara Exp $ */
+/*	$NetBSD: if_mpls.c,v 1.25 2016/06/20 22:59:36 knakahara Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.24 2016/06/20 06:46:37 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.25 2016/06/20 22:59:36 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -478,7 +478,7 @@ mpls_send_frame(struct mbuf *m, struct i
 #ifdef INET
 		ret = ip_if_output(ifp, m, rt->rt_gateway, rt);
 #else
-		if_output_lock(ifp, ifp, m, rt->rt_gateway, rt);
+		ret = if_output_lock(ifp, ifp, m, rt->rt_gateway, rt);
 #endif
 		return ret;
 		break;



CVS commit: src/sys/arch/pmax/ibus

2016-06-20 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jun 20 20:19:43 UTC 2016

Modified Files:
src/sys/arch/pmax/ibus: sii.c

Log Message:
Fix DEBUG build
While here, if DIAGNOSTIC panic to KASSERTMSG.

ok mlelstv@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/pmax/ibus/sii.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/pmax/ibus/sii.c
diff -u src/sys/arch/pmax/ibus/sii.c:1.11 src/sys/arch/pmax/ibus/sii.c:1.12
--- src/sys/arch/pmax/ibus/sii.c:1.11	Sun Nov 10 20:09:52 2013
+++ src/sys/arch/pmax/ibus/sii.c	Mon Jun 20 20:19:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sii.c,v 1.11 2013/11/10 20:09:52 christos Exp $	*/
+/*	$NetBSD: sii.c,v 1.12 2016/06/20 20:19:43 maya Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sii.c,v 1.11 2013/11/10 20:09:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sii.c,v 1.12 2016/06/20 20:19:43 maya Exp $");
 
 #include "sii.h"
 /*
@@ -1759,11 +1759,8 @@ sii_CmdDone(struct siisoftc *sc, int tar
 {
 	int i;
 
-#ifdef DIAGNOSTIC
-	ScsiCmd *scsicmd = sc->sc_cmd[target];
-	if (target < 0 || !scsicmd)
-		panic("sii_CmdDone");
-#endif
+	ScsiCmd *scsicmd __unused = sc->sc_cmd[target];
+	KASSERTMSG(target >= 0 && scsicmd, "sii_CmdDone");
 	sc->sc_cmd[target] = (ScsiCmd *)0;
 #ifdef DEBUG
 	if (sii_debug > 1) {



CVS commit: src/sys/kern

2016-06-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 20 19:14:35 UTC 2016

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

Log Message:
put back commented out name resolution code that was gc'ed after previous
refactoring.


To generate a diff of this commit:
cvs rdiff -u -r1.433 -r1.434 src/sys/kern/kern_exec.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_exec.c
diff -u src/sys/kern/kern_exec.c:1.433 src/sys/kern/kern_exec.c:1.434
--- src/sys/kern/kern_exec.c:1.433	Wed Jun  8 20:17:45 2016
+++ src/sys/kern/kern_exec.c	Mon Jun 20 15:14:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.433 2016/06/09 00:17:45 christos Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.434 2016/06/20 19:14:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.433 2016/06/09 00:17:45 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.434 2016/06/20 19:14:35 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -916,11 +916,12 @@ execve_free_data(struct execve_data *dat
 }
 
 static void
-pathexec(struct exec_package *epp, struct proc *p, const char *pathstring)
+pathexec(struct exec_package *epp, struct lwp *l, const char *pathstring)
 {
 	const char		*commandname;
 	size_t			commandlen;
 	char			*path;
+	struct proc 		*p = l->l_proc;
 
 	/* set command name & other accounting info */
 	commandname = strrchr(epp->ep_resolvedname, '/');
@@ -939,12 +940,31 @@ pathexec(struct exec_package *epp, struc
 	 * This handles the majority of the cases.
 	 * In the future perhaps we could canonicalize it?
 	 */
+	path = PNBUF_GET();
 	if (pathstring[0] == '/') {
-		path = PNBUF_GET();
 		(void)strlcpy(path, pathstring, MAXPATHLEN);
 		epp->ep_path = path;
-	} else
-		epp->ep_path = NULL;
+	}
+#ifdef notyet
+	/*
+	 * Although this works most of the time [since the entry was just
+	 * entered in the cache] we don't use it because it will fail for
+	 * entries that are not placed in the cache because their name is
+	 * longer than NCHNAMLEN and it is not the cleanest interface,
+	 * because there could be races. When the namei cache is re-written,
+	 * this can be changed to use the appropriate function.
+	 */
+	else if (!(error = vnode_to_path(path, MAXPATHLEN, p->p_textvp, l, p)))
+		epp->ep_path = path;
+#endif
+	else {
+#ifdef notyet
+		printf("Cannot get path for pid %d [%s] (error %d)\n",
+		(int)p->p_pid, p->p_comm, error);
+#endif
+		PNBUF_PUT(path);
+ 		epp->ep_path = NULL;
+	}
 }
 
 /* XXX elsewhere */
@@ -1165,7 +1185,7 @@ execve_runproc(struct lwp *l, struct exe
 	if (error != 0)
 		goto exec_abort;
 
-	pathexec(epp, p, data->ed_pathstring);
+	pathexec(epp, l, data->ed_pathstring);
 
 	char * const newstack = STACK_GROW(vm->vm_minsaddr, epp->ep_ssize);
 



CVS import: KIENTZLE

2016-06-20 Thread Joerg Sonnenberger
Module Name:KIENTZLE
Committed By:   joerg
Date:   Mon Jun 20 17:08:28 UTC 2016

Update of /cvsroot/KIENTZLE
In directory ivanova.netbsd.org:/tmp/cvs-serv15584

Log Message:
Import libarchive-3.2.1:
- primarily bugfixes, including security issues
- support for multithreading in xz

Status:

Vendor Tag: libarchive-3-2-1
Release Tags:   pkgsrc/archivers/libarchive/files

N KIENTZLE/CMakeLists.txt
N KIENTZLE/COPYING
N KIENTZLE/INSTALL
N KIENTZLE/Makefile.am
N KIENTZLE/Makefile.in
N KIENTZLE/NEWS
N KIENTZLE/README
N KIENTZLE/aclocal.m4
N KIENTZLE/config.h.in
N KIENTZLE/configure
N KIENTZLE/configure.ac
N KIENTZLE/build/autogen.sh
N KIENTZLE/build/bump-version.sh
N KIENTZLE/build/clean.sh
N KIENTZLE/build/version
N KIENTZLE/build/autoconf/ax_append_compile_flags.m4
N KIENTZLE/build/autoconf/ax_append_flag.m4
N KIENTZLE/build/autoconf/ax_check_compile_flag.m4
N KIENTZLE/build/autoconf/ax_require_defined.m4
N KIENTZLE/build/autoconf/check_stdcall_func.m4
N KIENTZLE/build/autoconf/compile
N KIENTZLE/build/autoconf/config.guess
N KIENTZLE/build/autoconf/config.rpath
N KIENTZLE/build/autoconf/config.sub
N KIENTZLE/build/autoconf/depcomp
N KIENTZLE/build/autoconf/iconv.m4
N KIENTZLE/build/autoconf/install-sh
N KIENTZLE/build/autoconf/la_uid_t.m4
N KIENTZLE/build/autoconf/lib-ld.m4
N KIENTZLE/build/autoconf/lib-link.m4
N KIENTZLE/build/autoconf/lib-prefix.m4
N KIENTZLE/build/autoconf/ltmain.sh
N KIENTZLE/build/autoconf/missing
N KIENTZLE/build/autoconf/test-driver
N KIENTZLE/build/cmake/CheckFileOffsetBits.c
N KIENTZLE/build/cmake/CheckFileOffsetBits.cmake
N KIENTZLE/build/cmake/CheckFuncs.cmake
N KIENTZLE/build/cmake/CheckFuncs_stub.c.in
N KIENTZLE/build/cmake/CheckHeaderDirent.cmake
N KIENTZLE/build/cmake/CheckStructMember.cmake
N KIENTZLE/build/cmake/CheckTypeExists.cmake
N KIENTZLE/build/cmake/CreatePkgConfigFile.cmake
N KIENTZLE/build/cmake/FindLZMA.cmake
N KIENTZLE/build/cmake/FindLibGCC.cmake
N KIENTZLE/build/cmake/FindNettle.cmake
N KIENTZLE/build/cmake/FindPCREPOSIX.cmake
N KIENTZLE/build/cmake/LibarchiveCodeCoverage.cmake
N KIENTZLE/build/cmake/config.h.in
N KIENTZLE/build/pkgconfig/libarchive.pc.in
N KIENTZLE/cat/CMakeLists.txt
N KIENTZLE/cat/bsdcat.1
N KIENTZLE/cat/bsdcat.c
N KIENTZLE/cat/bsdcat.h
N KIENTZLE/cat/bsdcat_platform.h
N KIENTZLE/cat/cmdline.c
N KIENTZLE/cat/test/CMakeLists.txt
N KIENTZLE/cat/test/list.h
N KIENTZLE/cat/test/main.c
N KIENTZLE/cat/test/test.h
N KIENTZLE/cat/test/test_0.c
N KIENTZLE/cat/test/test_empty.gz.uu
N KIENTZLE/cat/test/test_empty.lz4.uu
N KIENTZLE/cat/test/test_empty.xz.uu
N KIENTZLE/cat/test/test_empty_gz.c
N KIENTZLE/cat/test/test_empty_lz4.c
N KIENTZLE/cat/test/test_empty_xz.c
N KIENTZLE/cat/test/test_error.c
N KIENTZLE/cat/test/test_error_mixed.c
N KIENTZLE/cat/test/test_expand.Z.uu
N KIENTZLE/cat/test/test_expand.bz2.uu
N KIENTZLE/cat/test/test_expand.gz.uu
N KIENTZLE/cat/test/test_expand.lz4.uu
N KIENTZLE/cat/test/test_expand.plain.uu
N KIENTZLE/cat/test/test_expand.xz.uu
N KIENTZLE/cat/test/test_expand_Z.c
N KIENTZLE/cat/test/test_expand_bz2.c
N KIENTZLE/cat/test/test_expand_gz.c
N KIENTZLE/cat/test/test_expand_lz4.c
N KIENTZLE/cat/test/test_expand_mixed.c
N KIENTZLE/cat/test/test_expand_plain.c
N KIENTZLE/cat/test/test_expand_xz.c
N KIENTZLE/cat/test/test_help.c
N KIENTZLE/cat/test/test_version.c
N KIENTZLE/contrib/README
N KIENTZLE/contrib/libarchive.1aix53.spec
N KIENTZLE/contrib/libarchive.spec
N KIENTZLE/contrib/libarchive_autodetect-st_lib_archive.m4
N KIENTZLE/contrib/untar.c
N KIENTZLE/contrib/android/Android.mk
N KIENTZLE/contrib/android/config/android.h
N KIENTZLE/contrib/android/config/linux_host.h
N KIENTZLE/contrib/android/config/windows_host.h
N KIENTZLE/contrib/android/include/Bcrypt.h
N KIENTZLE/contrib/android/include/Windows.h
N KIENTZLE/contrib/android/include/android_lf.h
N KIENTZLE/contrib/psota-benchmark/results.txt
N KIENTZLE/contrib/psota-benchmark/tcp.sh
N KIENTZLE/contrib/shar/shar.1
N KIENTZLE/contrib/shar/shar.c
N KIENTZLE/contrib/shar/tree.c
N KIENTZLE/contrib/shar/tree.h
N KIENTZLE/contrib/shar/tree_config.h
N KIENTZLE/cpio/CMakeLists.txt
N KIENTZLE/cpio/bsdcpio.1
N KIENTZLE/cpio/cmdline.c
N KIENTZLE/cpio/config_freebsd.h
N KIENTZLE/cpio/cpio.c
N KIENTZLE/cpio/cpio.h
N KIENTZLE/cpio/cpio_platform.h
N KIENTZLE/cpio/cpio_windows.c
N KIENTZLE/cpio/cpio_windows.h
N KIENTZLE/cpio/test/CMakeLists.txt
N KIENTZLE/cpio/test/list.h
N KIENTZLE/cpio/test/main.c
N KIENTZLE/cpio/test/test.h
N KIENTZLE/cpio/test/test_0.c
N KIENTZLE/cpio/test/test_basic.c
N KIENTZLE/cpio/test/test_cmdline.c
N KIENTZLE/cpio/test/test_extract.cpio.Z.uu
N KIENTZLE/cpio/test/test_extract.cpio.bz2.uu
N KIENTZLE/cpio/test/test_extract.cpio.grz.uu
N KIENTZLE/cpio/test/test_extract.cpio.gz.uu
N KIENTZLE/cpio/test/test_extract.cpio.lrz.uu
N KIENTZLE/cpio/test/test_extract.cpio.lz.uu
N KIENTZLE/cpio/test/test_extract.cpio.lz4.uu
N KIENTZLE/cpio/test/test_extract.cpio.lzma.uu
N KIENTZLE/cpio/test/test_extract.cpio.lzo.uu
N 

CVS commit: src/sys/dev/ic

2016-06-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun 20 14:18:30 UTC 2016

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

Log Message:
Fix a comment


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/ic/sl811hs.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/sl811hs.c
diff -u src/sys/dev/ic/sl811hs.c:1.84 src/sys/dev/ic/sl811hs.c:1.85
--- src/sys/dev/ic/sl811hs.c:1.84	Mon Jun 20 07:13:07 2016
+++ src/sys/dev/ic/sl811hs.c	Mon Jun 20 14:18:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sl811hs.c,v 1.84 2016/06/20 07:13:07 skrll Exp $	*/
+/*	$NetBSD: sl811hs.c,v 1.85 2016/06/20 14:18:30 skrll Exp $	*/
 
 /*
  * Not (c) 2007 Matthew Orgass
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.84 2016/06/20 07:13:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.85 2016/06/20 14:18:30 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_slhci.h"
@@ -1537,7 +1537,7 @@ slhci_intr(void *arg)
 	return ret;
 }
 
-/* called with main lock only held, returns with locks released. */
+/* called with interrupt lock only held. */
 void
 slhci_main(struct slhci_softc *sc)
 {



CVS commit: src/sys/dev/pci

2016-06-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 20 10:02:43 UTC 2016

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

Log Message:
 B260 "Slot Power Limit" ECN. PCIe 3.1 ECN. September 18, 2015.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/dev/pci/pci_subr.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.147 src/sys/dev/pci/pci_subr.c:1.148
--- src/sys/dev/pci/pci_subr.c:1.147	Wed May 11 05:12:57 2016
+++ src/sys/dev/pci/pci_subr.c	Mon Jun 20 10:02:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.147 2016/05/11 05:12:57 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.148 2016/06/20 10:02:43 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.147 2016/05/11 05:12:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.148 2016/06/20 10:02:43 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -2472,11 +2472,11 @@ pci_conf_print_pwrbdgt_base_power(uint8_
 
 	switch (reg) {
 	case 0xf0:
-		return "250W";
+		return "239W < x <= 250W";
 	case 0xf1:
-		return "275W";
+		return "250W < x <= 275W";
 	case 0xf2:
-		return "300W";
+		return "275W < x <= 300W";
 	default:
 		return "Unknown";
 	}



CVS commit: src/sys/net80211

2016-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 20 08:57:18 UTC 2016

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

Log Message:
Get rid of invalid KASSERT

The mbuf being checked is allocated in ieee80211_getmgtframe just above,
so checking NULL of its CTX is meaningless.

Pointed out by mlelstv@


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/net80211/ieee80211_output.c

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

Modified files:

Index: src/sys/net80211/ieee80211_output.c
diff -u src/sys/net80211/ieee80211_output.c:1.55 src/sys/net80211/ieee80211_output.c:1.56
--- src/sys/net80211/ieee80211_output.c:1.55	Mon Jun 20 08:30:59 2016
+++ src/sys/net80211/ieee80211_output.c	Mon Jun 20 08:57:18 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_output.c,v 1.55 2016/06/20 08:30:59 knakahara Exp $	*/
+/*	$NetBSD: ieee80211_output.c,v 1.56 2016/06/20 08:57:18 ozaki-r Exp $	*/
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.34 2005/08/10 16:22:29 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.55 2016/06/20 08:30:59 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.56 2016/06/20 08:57:18 ozaki-r Exp $");
 #endif
 
 #ifdef _KERNEL_OPT
@@ -184,9 +184,6 @@ ieee80211_mgmt_output(struct ieee80211co
 	M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT);
 	if (m == NULL)
 		return ENOMEM;
-#ifdef __FreeBSD__
-	KASSERT(M_GETCTX(m, struct ieee80211_node *) == NULL);
-#endif
 	M_SETCTX(m, ni);
 
 	wh = mtod(m, struct ieee80211_frame *);
@@ -1344,7 +1341,6 @@ ieee80211_send_probereq(struct ieee80211
 	M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT);
 	if (m == NULL)
 		return ENOMEM;
-	KASSERT(M_GETCTX(m, struct ieee80211_node *) == NULL);
 	M_SETCTX(m, ni);
 
 	wh = mtod(m, struct ieee80211_frame *);



CVS commit: src/sys/dev/pci

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 08:34:59 UTC 2016

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

Log Message:
wm(4) can enable IFEF_START_MPSAFE now.


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

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.414 src/sys/dev/pci/if_wm.c:1.415
--- src/sys/dev/pci/if_wm.c:1.414	Tue Jun 14 17:09:20 2016
+++ src/sys/dev/pci/if_wm.c	Mon Jun 20 08:34:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.414 2016/06/14 17:09:20 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.415 2016/06/20 08:34:59 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -85,7 +85,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.414 2016/06/14 17:09:20 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.415 2016/06/20 08:34:59 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2407,6 +2407,7 @@ alloc_retry:
 	strlcpy(ifp->if_xname, xname, IFNAMSIZ);
 	ifp->if_softc = sc;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+	ifp->if_extflags = IFEF_START_MPSAFE;
 	ifp->if_ioctl = wm_ioctl;
 	if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
 		ifp->if_start = wm_nq_start;
@@ -6080,6 +6081,8 @@ wm_start(struct ifnet *ifp)
 	struct wm_softc *sc = ifp->if_softc;
 	struct wm_txqueue *txq = >sc_queue[0].wmq_txq;
 
+	KASSERT(ifp->if_extflags & IFEF_START_MPSAFE);
+
 	mutex_enter(txq->txq_lock);
 	if (!sc->sc_stopping)
 		wm_start_locked(ifp);
@@ -6597,6 +6600,8 @@ wm_nq_start(struct ifnet *ifp)
 	struct wm_softc *sc = ifp->if_softc;
 	struct wm_txqueue *txq = >sc_queue[0].wmq_txq;
 
+	KASSERT(ifp->if_extflags & IFEF_START_MPSAFE);
+
 	mutex_enter(txq->txq_lock);
 	if (!sc->sc_stopping)
 		wm_nq_start_locked(ifp);



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 08:24:36 UTC 2016

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

Log Message:
introduce if_start_lock()

if_start_lock() calls ifp->if_start() holding KERNEL_LOCK if it is required.


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 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.210 src/sys/net/if.h:1.211
--- src/sys/net/if.h:1.210	Mon Jun 20 08:18:59 2016
+++ src/sys/net/if.h	Mon Jun 20 08:24:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.210 2016/06/20 08:18:59 knakahara Exp $	*/
+/*	$NetBSD: if.h,v 1.211 2016/06/20 08:24:36 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -406,6 +406,26 @@ if_output_lock(struct ifnet *cifp, struc
 		return ret;
 	}
 }
+
+static inline bool
+if_start_is_mpsafe(struct ifnet *ifp)
+{
+
+	return ((ifp->if_extflags & IFEF_START_MPSAFE) != 0);
+}
+
+static inline void
+if_start_lock(struct ifnet *ifp)
+{
+
+	if (if_start_is_mpsafe(ifp)) {
+		(*ifp->if_start)(ifp);
+	} else {
+		KERNEL_LOCK(1, NULL);
+		(*ifp->if_start)(ifp);
+		KERNEL_UNLOCK_ONE(NULL);
+	}
+}
 #endif /* _KERNEL */
 
 #define	IFFBITS \



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 08:18:59 UTC 2016

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

Log Message:
fix: i386 build failure


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 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.209 src/sys/net/if.h:1.210
--- src/sys/net/if.h:1.209	Mon Jun 20 06:41:15 2016
+++ src/sys/net/if.h	Mon Jun 20 08:18:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.209 2016/06/20 06:41:15 knakahara Exp $	*/
+/*	$NetBSD: if.h,v 1.210 2016/06/20 08:18:59 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -382,6 +382,7 @@ typedef struct ifnet {
 #define	IFEF_OUTPUT_MPSAFE	0x0001	/* if_output() can run parallel */
 #define	IFEF_START_MPSAFE	0x0002	/* if_start() can run parallel */
 
+#ifdef _KERNEL
 static inline bool
 if_output_is_mpsafe(struct ifnet *ifp)
 {
@@ -405,6 +406,7 @@ if_output_lock(struct ifnet *cifp, struc
 		return ret;
 	}
 }
+#endif /* _KERNEL */
 
 #define	IFFBITS \
 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS" \



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 08:14:41 UTC 2016

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

Log Message:
fix: should not assert IFEF_OUTPUT_MPSAFE in bridge_output()


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.127 src/sys/net/if_bridge.c:1.128
--- src/sys/net/if_bridge.c:1.127	Mon Jun 20 07:23:56 2016
+++ src/sys/net/if_bridge.c	Mon Jun 20 08:14:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.127 2016/06/20 07:23:56 knakahara Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.128 2016/06/20 08:14:41 knakahara Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.127 2016/06/20 07:23:56 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.128 2016/06/20 08:14:41 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -1428,6 +1428,12 @@ bridge_output(struct ifnet *ifp, struct 
 	struct bridge_softc *sc;
 	int s;
 
+	/*
+	 * bridge_output() is called from ether_output(), furthermore
+	 * ifp argument doesn't point to bridge(4). So, don't assert
+	 * IFEF_OUTPUT_MPSAFE here.
+	 */
+
 	if (m->m_len < ETHER_HDR_LEN) {
 		m = m_pullup(m, ETHER_HDR_LEN);
 		if (m == NULL)



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

2016-06-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Jun 20 08:14:06 UTC 2016

Modified Files:
src/sys/arch/x86/x86: intr.c

Log Message:
Prevent use after free.  Don't free an interrupt source still in use.

Ok: Kengo NAKAHARA


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/x86/x86/intr.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/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.91 src/sys/arch/x86/x86/intr.c:1.92
--- src/sys/arch/x86/x86/intr.c:1.91	Tue Nov 17 10:34:04 2015
+++ src/sys/arch/x86/x86/intr.c	Mon Jun 20 08:14:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.91 2015/11/17 10:34:04 hannken Exp $	*/
+/*	$NetBSD: intr.c,v 1.92 2016/06/20 08:14:06 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.91 2015/11/17 10:34:04 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.92 2016/06/20 08:14:06 hannken Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -612,6 +612,11 @@ intr_free_io_intrsource(const char *intr
 		return;
 	}
 
+	/* If the interrupt uses shared IRQ, don't free yet. */
+	if (isp->is_handlers != NULL) {
+		return;
+	}
+
 	intr_free_io_intrsource_direct(isp);
 }
 



CVS commit: src/libexec/ld.elf_so/arch/sparc64

2016-06-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jun 20 08:12:25 UTC 2016

Modified Files:
src/libexec/ld.elf_so/arch/sparc64: mdreloc.c

Log Message:
Fix a few bounds and instruction sequences generated in the PLT; exercised
by ASLR and verified to work with the aslr fixed random debug sysctls.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c

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

Modified files:

Index: src/libexec/ld.elf_so/arch/sparc64/mdreloc.c
diff -u src/libexec/ld.elf_so/arch/sparc64/mdreloc.c:1.57 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c:1.58
--- src/libexec/ld.elf_so/arch/sparc64/mdreloc.c:1.57	Mon Aug 25 20:40:53 2014
+++ src/libexec/ld.elf_so/arch/sparc64/mdreloc.c	Mon Jun 20 08:12:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mdreloc.c,v 1.57 2014/08/25 20:40:53 joerg Exp $	*/
+/*	$NetBSD: mdreloc.c,v 1.58 2016/06/20 08:12:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000 Eduardo Horvath.
@@ -32,7 +32,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.57 2014/08/25 20:40:53 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.58 2016/06/20 08:12:25 martin Exp $");
 #endif /* not lint */
 
 #include 
@@ -202,6 +202,7 @@ static const long reloc_target_bitmask[]
 #define	MOV17	0x9e106000	/*	or	%g1, 0, %o7 */
 #define	CALL	0x4000	/*	call	0 */
 #define	SLLX	0x83287000	/*	sllx	%g1, 0, %g1 */
+#define	NEG	0x8221	/*	neg	%g1 */
 #define	SETHIG5	0x0b00	/*	sethi	%hi(0), %g5 */
 #define	ORG5	0x82104005	/*	or	%g1, %g5, %g1 */
 
@@ -662,7 +663,7 @@ _rtld_relocate_plt_object(const Obj_Entr
 		 *	nop
 		 *
 		 */
-		where[1] = BAA | ((offset >> 2) & 0x3f);
+		where[1] = BAA | ((offset >> 2) & 0x7);
 		__asm volatile("iflush %0+4" : : "r" (where));
 	} else if (value < (1L<<32)) {
 		/* 
@@ -708,7 +709,8 @@ _rtld_relocate_plt_object(const Obj_Entr
 		__asm volatile("iflush %0+8" : : "r" (where));
 		__asm volatile("iflush %0+4" : : "r" (where));
 
-	} else if (offset <= (1L<<32) && (Elf_SOff)offset >= -((1L<<32) - 4)) {
+	} else if ((offset+8) <= (1L<<31) &&
+	(Elf_SOff)(offset+8) >= -((1L<<31) - 4)) {
 		/* 
 		 * We're within 32-bits -- we can use a direct call insn 
 		 *
@@ -724,14 +726,15 @@ _rtld_relocate_plt_object(const Obj_Entr
 		 *	nop
 		 *
 		 */
+		offset += 8;	/* call is at where[2], 8 byte further */
 		where[3] = MOV17;
-		where[2] = CALL	  | ((offset >> 4) & 0x3fff);
+		where[2] = CALL	  | ((-offset >> 2) & 0x3fff);
 		where[1] = MOV71;
 		__asm volatile("iflush %0+12" : : "r" (where));
 		__asm volatile("iflush %0+8" : : "r" (where));
 		__asm volatile("iflush %0+4" : : "r" (where));
 
-	} else if (offset < (1L<<44)) {
+	} else if ((Elf_SOff)value > 0 && value < (1L<<44)) {
 		/* 
 		 * We're within 44 bits.  We can generate this pattern:
 		 *
@@ -747,35 +750,38 @@ _rtld_relocate_plt_object(const Obj_Entr
 		 *	nop
 		 *
 		 */
-		where[4] = JMP   | LOVAL(offset, 0);
+		where[4] = JMP   | LOVAL(value, 0);
 		where[3] = SLLX  | 12;
-		where[2] = OR| (((offset) >> 12) & 0x1fff);
-		where[1] = SETHI | HIVAL(offset, 22);
+		where[2] = OR| (((value) >> 12) & 0x1fff);
+		where[1] = SETHI | HIVAL(value, 22);
 		__asm volatile("iflush %0+16" : : "r" (where));
 		__asm volatile("iflush %0+12" : : "r" (where));
 		__asm volatile("iflush %0+8" : : "r" (where));
 		__asm volatile("iflush %0+4" : : "r" (where));
 
-	} else if ((Elf_SOff)offset < 0 && (Elf_SOff)offset > -(1L<<44)) {
-		/* 
-		 * We're within 44 bits.  We can generate this pattern:
+	} else if ((Elf_SOff)value < 0 && (Elf_SOff)value > -(1L<<44)) {
+		/*
+		 *  We're within 44 bits.  We can generate this pattern:
 		 *
 		 * The resulting code in the jump slot is:
 		 *
 		 *	sethi	%hi(. - .PLT0), %g1
-		 *	sethi	%h44(-addr), %g1
-		 *	xor	%g1, %m44(-addr), %g1
-		 *	sllx	%g1, 12, %g1	
-		 *	jmp	%g1+%l44(addr)	
-		 *	nop
+		 *	sethi	%hi((-addr)>>12), %g1
+		 *	or	%g1, %lo((-addr)>>12), %g1
+		 *	neg	%g1
+		 *	sllx	%g1, 12, %g1
+		 *	jmp	%g1+(addr&0x0fff)
 		 *	nop
 		 *	nop
 		 *
 		 */
-		where[4] = JMP   | LOVAL(offset, 0);
-		where[3] = SLLX  | 12;
-		where[2] = XOR   | (((~offset) >> 12) & 0x1fff);
-		where[1] = SETHI | HIVAL(~offset, 22);
+		Elf_Addr neg = (~value+1)>>12;
+		where[5] = JMP   | (value & 0x0fff);
+		where[4] = SLLX  | 12;
+		where[3] = NEG;
+		where[2] = OR| (LOVAL(neg, 0)+1);
+		where[1] = SETHI | HIVAL(neg, 10);
+		__asm volatile("iflush %0+20" : : "r" (where));
 		__asm volatile("iflush %0+16" : : "r" (where));
 		__asm volatile("iflush %0+12" : : "r" (where));
 		__asm volatile("iflush %0+8" : : "r" (where));



CVS commit: src/sys/netinet

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 08:08:13 UTC 2016

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

Log Message:
fix: i386/ALL build failure


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/netinet/ip_carp.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/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.69 src/sys/netinet/ip_carp.c:1.70
--- src/sys/netinet/ip_carp.c:1.69	Mon Jun 20 06:46:38 2016
+++ src/sys/netinet/ip_carp.c	Mon Jun 20 08:08:13 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.69 2016/06/20 06:46:38 knakahara Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.70 2016/06/20 08:08:13 knakahara Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.69 2016/06/20 06:46:38 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.70 2016/06/20 08:08:13 knakahara Exp $");
 
 /*
  * TODO:
@@ -2112,7 +2112,7 @@ carp_output(struct ifnet *ifp, struct mb
 	KASSERT(KERNEL_LOCKED_P());
 
 	if (sc->sc_carpdev != NULL && sc->sc_state == MASTER) {
-		return if_output_lock(sc->sc_carpdev, ifp, m, sa, rt));
+		return if_output_lock(sc->sc_carpdev, ifp, m, sa, rt);
 	} else {
 		m_freem(m);
 		return (ENETUNREACH);



CVS commit: src/sys/dev/ic

2016-06-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun 20 07:13:07 UTC 2016

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

Log Message:
More debug.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/ic/sl811hs.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/sl811hs.c
diff -u src/sys/dev/ic/sl811hs.c:1.83 src/sys/dev/ic/sl811hs.c:1.84
--- src/sys/dev/ic/sl811hs.c:1.83	Mon Jun 20 07:12:00 2016
+++ src/sys/dev/ic/sl811hs.c	Mon Jun 20 07:13:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sl811hs.c,v 1.83 2016/06/20 07:12:00 skrll Exp $	*/
+/*	$NetBSD: sl811hs.c,v 1.84 2016/06/20 07:13:07 skrll Exp $	*/
 
 /*
  * Not (c) 2007 Matthew Orgass
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.83 2016/06/20 07:12:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.84 2016/06/20 07:13:07 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_slhci.h"
@@ -639,7 +639,7 @@ DDOLOGBUF(uint8_t *buf, unsigned int len
 	!!((r) & SL11_IER_USBA), 0);	\
 } while (0)
 
-#define DDLOGSTATUS(s)	do {		\
+#define DDOLOGSTATUS(s)	do {		\
 DDOLOG("STAT stall   =%d  nak =%d  overflow =%d  setup   =%d",	\
 	!!((s) & SL11_EPSTAT_STALL), !!((s) & SL11_EPSTAT_NAK),		\
 	!!((s) & SL11_EPSTAT_OVERFLOW), !!((s) & SL11_EPSTAT_SETUP));	\
@@ -648,7 +648,7 @@ DDOLOGBUF(uint8_t *buf, unsigned int len
 	!!((s) & SL11_EPSTAT_ERROR), !!((s) & SL11_EPSTAT_ACK));	\
 } while (0)
 
-#define DDLOGEPCTRL(r)	do {		\
+#define DDOLOGEPCTRL(r)	do {		\
 DDOLOG("CTRL preamble=%d  toggle  =%d  sof =%d  iso =%d",	\
 	!!((r) & SL11_EPCTRL_PREAMBLE), !!((r) & SL11_EPCTRL_DATATOGGLE),\
 	!!((r) & SL11_EPCTRL_SOF), !!((r) & SL11_EPCTRL_ISO));		\
@@ -657,7 +657,7 @@ DDOLOGBUF(uint8_t *buf, unsigned int len
 	!!((r) & SL11_EPCTRL_ENABLE), !!((r) & SL11_EPCTRL_ARM), 0);	\
 } while (0)
 
-#define DDLOGEPSTAT(r)	do {		\
+#define DDOLOGEPSTAT(r)	do {		\
 DDOLOG("STAT stall   =%d  nak =%d  overflow =%d  setup   =%d",	\
 	!!((r) & SL11_EPSTAT_STALL), !!((r) & SL11_EPSTAT_NAK),		\
 	!!((r) & SL11_EPSTAT_OVERFLOW), !!((r) & SL11_EPSTAT_SETUP));	\
@@ -677,9 +677,9 @@ DDOLOGBUF(uint8_t *buf, unsigned int len
 #define DDOLOGCTRL(x) ((void)0)
 #define DDOLOGISR(r) ((void)0)
 #define DDOLOGIER(r) ((void)0)
-#define DDLOGSTATUS(s) ((void)0)
-#define DDLOGEPCTRL(r) ((void)0)
-#define DDLOGEPSTAT(r) ((void)0)
+#define DDOLOGSTATUS(s) ((void)0)
+#define DDOLOGEPCTRL(r) ((void)0)
+#define DDOLOGEPSTAT(r) ((void)0)
 #endif /* SLHCI_DEBUG */
 
 #ifdef DIAGNOSTIC
@@ -2024,7 +2024,7 @@ slhci_abdone(struct slhci_softc *sc, int
 	if ((slhcidebug & SLHCI_D_NAK) ||
 	(status & SL11_EPSTAT_ERRBITS) != SL11_EPSTAT_NAK) {
 		DDOLOG("USB Status = %#.2x", status, 0, 0, 0);
-		DDLOGSTATUS(status);
+		DDOLOGSTATUS(status);
 	}
 #endif
 
@@ -2097,7 +2097,7 @@ slhci_abdone(struct slhci_softc *sc, int
 			DLOG(D_ERR, "Max retries reached! status %#x "
 			"xfer->ux_status %#x", status, xfer->ux_status, 0,
 			0);
-			DDLOGSTATUS(status);
+			DDOLOGSTATUS(status);
 
 			if (status == SL11_EPSTAT_OVERFLOW &&
 			ratecheck(>sc_overflow_warn_rate,
@@ -3330,7 +3330,7 @@ slhci_log_dumpreg(void)
 
 	r = slhci_read(ssc, SL11_E0CTRL);
 	DDOLOG("USB A Host Control = %#.2x", r, 0, 0, 0);
-	DDLOGEPCTRL(r);
+	DDOLOGEPCTRL(r);
 
 	aaddr = slhci_read(ssc, SL11_E0ADDR);
 	DDOLOG("USB A Base Address = %u", aaddr, 0,0,0);
@@ -3338,13 +3338,13 @@ slhci_log_dumpreg(void)
 	DDOLOG("USB A Length = %u", alen, 0,0,0);
 	r = slhci_read(ssc, SL11_E0STAT);
 	DDOLOG("USB A Status = %#.2x", r, 0,0,0);
-	DDLOGEPSTAT(r);
+	DDOLOGEPSTAT(r);
 
 	r = slhci_read(ssc, SL11_E0CONT);
 	DDOLOG("USB A Remaining or Overflow Length = %u", r, 0,0,0);
 	r = slhci_read(ssc, SL11_E1CTRL);
 	DDOLOG("USB B Host Control = %#.2x", r, 0,0,0);
-	DDLOGEPCTRL(r);
+	DDOLOGEPCTRL(r);
 
 	baddr = slhci_read(ssc, SL11_E1ADDR);
 	DDOLOG("USB B Base Address = %u", baddr, 0,0,0);
@@ -3352,7 +3352,7 @@ slhci_log_dumpreg(void)
 	DDOLOG("USB B Length = %u", blen, 0,0,0);
 	r = slhci_read(ssc, SL11_E1STAT);
 	DDOLOG("USB B Status = %#.2x", r, 0,0,0);
-	DDLOGEPSTAT(r);
+	DDOLOGEPSTAT(r);
 
 	r = slhci_read(ssc, SL11_E1CONT);
 	DDOLOG("USB B Remaining or Overflow Length = %u", r, 0,0,0);
@@ -3426,6 +3426,8 @@ slhci_print_intr(void)
 void
 slhci_log_sc(void)
 {
+	SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
+
 	struct slhci_transfers *t;
 	int i;
 
@@ -3436,9 +3438,9 @@ slhci_log_sc(void)
 	t->spipe[1], t->len[1]);
 
 	for (i=0; i<=Q_MAX; i++)
-		DDOLOG("Q %d: %p", i, gcq_first(>q[i]), 0,0);
+		DDOLOG("Q %d: %p", i, gcq_hq(>q[i]), 0,0);
 
-	DDOLOG("TIMED: %p", GCQ_ITEM(gcq_first(>to),
+	DDOLOG("TIMED: %p", GCQ_ITEM(gcq_hq(>to),
 	struct slhci_pipe, to), 0,0,0);
 
 	DDOLOG("frame=%d rootintr=%p", t->frame, t->rootintr, 0,0);
@@ -3449,13 +3451,13 @@ slhci_log_sc(void)
 void
 slhci_log_slreq(struct slhci_pipe *r)
 {
-	

CVS commit: src/sys/dev/ic

2016-06-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun 20 07:12:00 UTC 2016

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

Log Message:
Set ssc as early as possible


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/ic/sl811hs.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/sl811hs.c
diff -u src/sys/dev/ic/sl811hs.c:1.82 src/sys/dev/ic/sl811hs.c:1.83
--- src/sys/dev/ic/sl811hs.c:1.82	Sun Jun 19 07:38:08 2016
+++ src/sys/dev/ic/sl811hs.c	Mon Jun 20 07:12:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sl811hs.c,v 1.82 2016/06/19 07:38:08 skrll Exp $	*/
+/*	$NetBSD: sl811hs.c,v 1.83 2016/06/20 07:12:00 skrll Exp $	*/
 
 /*
  * Not (c) 2007 Matthew Orgass
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.82 2016/06/19 07:38:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.83 2016/06/20 07:12:00 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_slhci.h"
@@ -1153,6 +1153,10 @@ slhci_preinit(struct slhci_softc *sc, Po
 
 	t = >sc_transfers;
 
+#ifdef SLHCI_DEBUG
+	ssc = sc;
+#endif
+
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_USB);
 
@@ -1211,10 +1215,6 @@ slhci_attach(struct slhci_softc *sc)
 	sc->sc_cb_softintr = softint_establish(SOFTINT_NET,
 	slhci_callback_entry, sc);
 
-#ifdef SLHCI_DEBUG
-	ssc = sc;
-#endif
-
 	if (t->sltype == SLTYPE_SL811HS_R12)
 		rev = "(rev 1.2)";
 	else if (t->sltype == SLTYPE_SL811HS_R14)



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 07:06:06 UTC 2016

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

Log Message:
make bridge_output MP-safe, so that bridge(4) can enable IFEF_OUTPUT_MPSAFE.

making MP-scalable is future work.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.125 src/sys/net/if_bridge.c:1.126
--- src/sys/net/if_bridge.c:1.125	Fri Jun 10 13:31:44 2016
+++ src/sys/net/if_bridge.c	Mon Jun 20 07:06:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.125 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.126 2016/06/20 07:06:06 knakahara Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.125 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.126 2016/06/20 07:06:06 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -424,6 +424,7 @@ bridge_clone_create(struct if_clone *ifc
 
 	if_initname(ifp, ifc->ifc_name, unit);
 	ifp->if_softc = sc;
+	ifp->if_extflags = IFEF_OUTPUT_MPSAFE;
 	ifp->if_mtu = ETHERMTU;
 	ifp->if_ioctl = bridge_ioctl;
 	ifp->if_output = bridge_output;
@@ -1378,6 +1379,7 @@ bridge_enqueue(struct bridge_softc *sc, 
 	}
 
 #ifdef ALTQ
+	KERNEL_LOCK(1, NULL);
 	/*
 	 * If ALTQ is enabled on the member interface, do
 	 * classification; the queueing discipline might
@@ -1388,6 +1390,7 @@ bridge_enqueue(struct bridge_softc *sc, 
 		/* XXX IFT_ETHER */
 		altq_etherclassify(_ifp->if_snd, m);
 	}
+	KERNEL_UNLOCK_ONE(NULL);
 #endif /* ALTQ */
 
 	len = m->m_pkthdr.len;
@@ -1425,6 +1428,8 @@ bridge_output(struct ifnet *ifp, struct 
 	struct bridge_softc *sc;
 	int s;
 
+	KASSERT(ifp->if_extflags & IFEF_OUTPUT_MPSAFE);
+
 	if (m->m_len < ETHER_HDR_LEN) {
 		m = m_pullup(m, ETHER_HDR_LEN);
 		if (m == NULL)



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 07:01:45 UTC 2016

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

Log Message:
make ether_output() MP-safe, so that if_ether can enable IFEF_OUTPUT_MPSAFE.

making MP-scalable is future work.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/sys/net/if_ethersubr.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_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.223 src/sys/net/if_ethersubr.c:1.224
--- src/sys/net/if_ethersubr.c:1.223	Thu Jun 16 03:03:33 2016
+++ src/sys/net/if_ethersubr.c	Mon Jun 20 07:01:45 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.223 2016/06/16 03:03:33 ozaki-r Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.224 2016/06/20 07:01:45 knakahara Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.223 2016/06/16 03:03:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.224 2016/06/20 07:01:45 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -204,9 +204,7 @@ ether_output(struct ifnet * const ifp0, 
 	struct at_ifaddr *aa;
 #endif /* NETATALK */
 
-#ifndef NET_MPSAFE
-	KASSERT(KERNEL_LOCKED_P());
-#endif
+	KASSERT(ifp->if_extflags & IFEF_OUTPUT_MPSAFE);
 
 #ifdef MBUFTRACE
 	m_claimm(m, ifp->if_mowner);
@@ -238,13 +236,17 @@ ether_output(struct ifnet * const ifp0, 
 
 #ifdef INET
 	case AF_INET:
+		KERNEL_LOCK(1, NULL);
 		if (m->m_flags & M_BCAST)
 			(void)memcpy(edst, etherbroadcastaddr, sizeof(edst));
 		else if (m->m_flags & M_MCAST)
 			ETHER_MAP_IP_MULTICAST((dst)->sin_addr, edst);
 		else if ((error = arpresolve(ifp, rt, m, dst, edst,
-		sizeof(edst))) != 0)
+		sizeof(edst))) != 0) {
+			KERNEL_UNLOCK_ONE(NULL);
 			return error == EWOULDBLOCK ? 0 : error;
+		}
+		KERNEL_UNLOCK_ONE(NULL);
 		/* If broadcasting on a simplex interface, loopback a copy */
 		if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
 			mcopy = m_copy(m, 0, (int)M_COPYALL);
@@ -292,10 +294,12 @@ ether_output(struct ifnet * const ifp0, 
 #endif
 #ifdef NETATALK
 case AF_APPLETALK:
+		KERNEL_LOCK(1, NULL);
 		if (aarpresolve(ifp, m, (const struct sockaddr_at *)dst, edst)) {
 #ifdef NETATALKDEBUG
 			printf("aarpresolv failed\n");
 #endif /* NETATALKDEBUG */
+			KERNEL_UNLOCK_ONE(NULL);
 			return (0);
 		}
 		/*
@@ -303,8 +307,10 @@ ether_output(struct ifnet * const ifp0, 
 		 */
 		aa = (struct at_ifaddr *) at_ifawithnet(
 		(const struct sockaddr_at *)dst, ifp);
-		if (aa == NULL)
+		if (aa == NULL) {
+		KERNEL_UNLOCK_ONE(NULL);
 		goto bad;
+		}
 
 		/*
 		 * In the phase 2 case, we need to prepend an mbuf for the
@@ -325,6 +331,7 @@ ether_output(struct ifnet * const ifp0, 
 		} else {
 			etype = htons(ETHERTYPE_ATALK);
 		}
+		KERNEL_UNLOCK_ONE(NULL);
 		break;
 #endif /* NETATALK */
 	case pseudo_AF_HDRCMPLT:
@@ -349,6 +356,7 @@ ether_output(struct ifnet * const ifp0, 
 	}
 
 #ifdef MPLS
+	KERNEL_LOCK(1, NULL);
 	{
 		struct m_tag *mtag;
 		mtag = m_tag_find(m, PACKET_TAG_MPLS, NULL);
@@ -358,6 +366,7 @@ ether_output(struct ifnet * const ifp0, 
 			m_tag_delete(m, mtag);
 		}
 	}
+	KERNEL_UNLOCK_ONE(NULL);
 #endif
 
 	if (mcopy)
@@ -410,6 +419,7 @@ ether_output(struct ifnet * const ifp0, 
 #endif /* NCARP > 0 */
 
 #ifdef ALTQ
+	KERNEL_LOCK(1, NULL);
 	/*
 	 * If ALTQ is enabled on the parent interface, do
 	 * classification; the queueing discipline might not
@@ -418,6 +428,7 @@ ether_output(struct ifnet * const ifp0, 
 	 */
 	if (ALTQ_IS_ENABLED(>if_snd))
 		altq_etherclassify(>if_snd, m);
+	KERNEL_UNLOCK_ONE(NULL);
 #endif
 	return ifq_enqueue(ifp, m);
 
@@ -910,6 +921,7 @@ ether_ifattach(struct ifnet *ifp, const 
 {
 	struct ethercom *ec = (struct ethercom *)ifp;
 
+	ifp->if_extflags |= IFEF_OUTPUT_MPSAFE;
 	ifp->if_type = IFT_ETHER;
 	ifp->if_hdrlen = ETHER_HDR_LEN;
 	ifp->if_dlt = DLT_EN10MB;



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 06:52:44 UTC 2016

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

Log Message:
make looutput() MP-safe, so that lo(4) can enable IFEF_OUTPUT_MPSAFE.

making MP-scalable is future work.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/net/if_loop.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_loop.c
diff -u src/sys/net/if_loop.c:1.87 src/sys/net/if_loop.c:1.88
--- src/sys/net/if_loop.c:1.87	Fri Jun 10 13:27:16 2016
+++ src/sys/net/if_loop.c	Mon Jun 20 06:52:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_loop.c,v 1.87 2016/06/10 13:27:16 ozaki-r Exp $	*/
+/*	$NetBSD: if_loop.c,v 1.88 2016/06/20 06:52:44 knakahara Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.87 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.88 2016/06/20 06:52:44 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -157,6 +157,7 @@ loop_clone_create(struct if_clone *ifc, 
 
 	ifp->if_mtu = LOMTU;
 	ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST | IFF_RUNNING;
+	ifp->if_extflags = IFEF_OUTPUT_MPSAFE;
 	ifp->if_ioctl = loioctl;
 	ifp->if_output = looutput;
 #ifdef ALTQ
@@ -211,12 +212,12 @@ looutput(struct ifnet *ifp, struct mbuf 
 	struct ifqueue *ifq = NULL;
 	int s, isr = -1;
 	int csum_flags;
+	int error = 0;
 	size_t pktlen;
 
 	MCLAIM(m, ifp->if_mowner);
-#ifndef NET_MPSAFE
-	KASSERT(KERNEL_LOCKED_P());
-#endif
+
+	KERNEL_LOCK(1, NULL);
 
 	if ((m->m_flags & M_PKTHDR) == 0)
 		panic("looutput: no header mbuf");
@@ -226,8 +227,9 @@ looutput(struct ifnet *ifp, struct mbuf 
 
 	if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
 		m_freem(m);
-		return (rt->rt_flags & RTF_BLACKHOLE ? 0 :
+		error = (rt->rt_flags & RTF_BLACKHOLE ? 0 :
 			rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
+		goto out;
 	}
 
 	pktlen = m->m_pkthdr.len;
@@ -241,8 +243,6 @@ looutput(struct ifnet *ifp, struct mbuf 
 	 */
 	if ((ALTQ_IS_ENABLED(>if_snd) || TBR_IS_ENABLED(>if_snd)) &&
 	ifp->if_start == lostart) {
-		int error;
-
 		/*
 		 * If the queueing discipline needs packet classification,
 		 * do it before prepending the link headers.
@@ -250,12 +250,14 @@ looutput(struct ifnet *ifp, struct mbuf 
 		IFQ_CLASSIFY(>if_snd, m, dst->sa_family);
 
 		M_PREPEND(m, sizeof(uint32_t), M_DONTWAIT);
-		if (m == NULL)
-			return (ENOBUFS);
+		if (m == NULL) {
+			error = ENOBUFS;
+			goto out;
+		}
 		*(mtod(m, uint32_t *)) = dst->sa_family;
 
 		error = ifp->if_transmit(ifp, m);
-		return (error);
+		goto out;
 	}
 #endif /* ALTQ */
 
@@ -310,12 +312,13 @@ looutput(struct ifnet *ifp, struct mbuf 
 		printf("%s: can't handle af%d\n", ifp->if_xname,
 		dst->sa_family);
 		m_freem(m);
-		return (EAFNOSUPPORT);
+		error = EAFNOSUPPORT;
+		goto out;
 	}
 
 	s = splnet();
 	if (__predict_true(pktq)) {
-		int error = 0;
+		error = 0;
 
 		if (__predict_true(pktq_enqueue(pktq, m, 0))) {
 			ifp->if_ipackets++;
@@ -325,20 +328,23 @@ looutput(struct ifnet *ifp, struct mbuf 
 			error = ENOBUFS;
 		}
 		splx(s);
-		return error;
+		goto out;
 	}
 	if (IF_QFULL(ifq)) {
 		IF_DROP(ifq);
 		m_freem(m);
 		splx(s);
-		return (ENOBUFS);
+		error = ENOBUFS;
+		goto out;
 	}
 	IF_ENQUEUE(ifq, m);
 	schednetisr(isr);
 	ifp->if_ipackets++;
 	ifp->if_ibytes += m->m_pkthdr.len;
 	splx(s);
-	return (0);
+out:
+	KERNEL_UNLOCK_ONE(NULL);
+	return error;
 }
 
 #ifdef ALTQ



CVS commit: src/sys

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 06:46:38 UTC 2016

Modified Files:
src/sys/dist/pf/net: pf.c
src/sys/external/bsd/ipf/netinet: ip_fil_netbsd.c
src/sys/net: bpf.c if_ecosubr.c if_mpls.c if_pppoe.c if_srt.c ppp_tty.c
src/sys/net/agr: if_agr.c
src/sys/netatalk: aarp.c ddp_output.c
src/sys/netinet: if_arp.c ip_carp.c ip_flow.c ip_output.c
src/sys/netinet6: ip6_flow.c nd6.c

Log Message:
apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 
tunneling).


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/dist/pf/net/pf.c
cvs rdiff -u -r1.14 -r1.15 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
cvs rdiff -u -r1.198 -r1.199 src/sys/net/bpf.c
cvs rdiff -u -r1.46 -r1.47 src/sys/net/if_ecosubr.c
cvs rdiff -u -r1.23 -r1.24 src/sys/net/if_mpls.c
cvs rdiff -u -r1.108 -r1.109 src/sys/net/if_pppoe.c
cvs rdiff -u -r1.21 -r1.22 src/sys/net/if_srt.c
cvs rdiff -u -r1.60 -r1.61 src/sys/net/ppp_tty.c
cvs rdiff -u -r1.35 -r1.36 src/sys/net/agr/if_agr.c
cvs rdiff -u -r1.36 -r1.37 src/sys/netatalk/aarp.c
cvs rdiff -u -r1.18 -r1.19 src/sys/netatalk/ddp_output.c
cvs rdiff -u -r1.211 -r1.212 src/sys/netinet/if_arp.c
cvs rdiff -u -r1.68 -r1.69 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.71 -r1.72 src/sys/netinet/ip_flow.c
cvs rdiff -u -r1.256 -r1.257 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.26 -r1.27 src/sys/netinet6/ip6_flow.c
cvs rdiff -u -r1.195 -r1.196 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/dist/pf/net/pf.c
diff -u src/sys/dist/pf/net/pf.c:1.73 src/sys/dist/pf/net/pf.c:1.74
--- src/sys/dist/pf/net/pf.c:1.73	Fri Jun 10 13:27:15 2016
+++ src/sys/dist/pf/net/pf.c	Mon Jun 20 06:46:37 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pf.c,v 1.73 2016/06/10 13:27:15 ozaki-r Exp $	*/
+/*	$NetBSD: pf.c,v 1.74 2016/06/20 06:46:37 knakahara Exp $	*/
 /*	$OpenBSD: pf.c,v 1.552.2.1 2007/11/27 16:37:57 henning Exp $ */
 
 /*
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.73 2016/06/10 13:27:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.74 2016/06/20 06:46:37 knakahara Exp $");
 
 #include "pflog.h"
 
@@ -5381,7 +5381,7 @@ pf_route(struct mbuf **m, struct pf_rule
 		else if (m0->m_pkthdr.csum_flags & M_UDPV4_CSUM_OUT)
 			udpstat.udps_outhwcsum++;
 #endif /* !__NetBSD__ */
-		error = (*ifp->if_output)(ifp, m0, dst, NULL);
+		error = if_output_lock(ifp, ifp, m0, dst, NULL);
 		goto done;
 	}
 

Index: src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
diff -u src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.14 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.15
--- src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.14	Fri Jun 10 13:27:15 2016
+++ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c	Mon Jun 20 06:46:37 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_fil_netbsd.c,v 1.14 2016/06/10 13:27:15 ozaki-r Exp $	*/
+/*	$NetBSD: ip_fil_netbsd.c,v 1.15 2016/06/20 06:46:37 knakahara Exp $	*/
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -8,7 +8,7 @@
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.14 2016/06/10 13:27:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.15 2016/06/20 06:46:37 knakahara Exp $");
 #else
 static const char sccsid[] = "@(#)ip_fil.c	2.41 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp";
@@ -1228,9 +1228,7 @@ ipf_fastroute(mb_t *m0, mb_t **mpp, fr_i
 			ip->ip_sum = in_cksum(m, hlen);
 # endif /* M_CSUM_IPv4 */
 
-		KERNEL_LOCK(1, NULL);
-		error = (*ifp->if_output)(ifp, m, dst, rt);
-		KERNEL_UNLOCK_ONE(NULL);
+		error = if_output_lock(ifp, ifp, m, dst, rt);
 		goto done;
 	}
 

Index: src/sys/net/bpf.c
diff -u src/sys/net/bpf.c:1.198 src/sys/net/bpf.c:1.199
--- src/sys/net/bpf.c:1.198	Fri Jun 10 13:31:44 2016
+++ src/sys/net/bpf.c	Mon Jun 20 06:46:37 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.198 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: bpf.c,v 1.199 2016/06/20 06:46:37 knakahara Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.198 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.199 2016/06/20 06:46:37 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -723,7 +723,7 @@ bpf_write(struct file *fp, off_t *offp, 
 		mc = NULL;
 
 	s = splsoftnet();
-	error = (*ifp->if_output)(ifp, m, (struct sockaddr *) , NULL);
+	error = if_output_lock(ifp, ifp, m, (struct sockaddr *) , NULL);
 
 	if (mc != NULL) {
 		if (error == 0)

Index: src/sys/net/if_ecosubr.c
diff -u src/sys/net/if_ecosubr.c:1.46 src/sys/net/if_ecosubr.c:1.47
--- src/sys/net/if_ecosubr.c:1.46	Wed Apr 20 09:01:04 2016
+++ src/sys/net/if_ecosubr.c	Mon Jun 20 06:46:37 2016
@@ -1,4 +1,4 @@
-/*	

CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 06:41:15 UTC 2016

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

Log Message:
introduce if_output_lock()

if_output_lock() calls ifp->if_output() holding KERNEL_LOCK if it is required.


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 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.208 src/sys/net/if.h:1.209
--- src/sys/net/if.h:1.208	Mon Jun 20 06:35:05 2016
+++ src/sys/net/if.h	Mon Jun 20 06:41:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.208 2016/06/20 06:35:05 knakahara Exp $	*/
+/*	$NetBSD: if.h,v 1.209 2016/06/20 06:41:15 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -382,6 +382,30 @@ typedef struct ifnet {
 #define	IFEF_OUTPUT_MPSAFE	0x0001	/* if_output() can run parallel */
 #define	IFEF_START_MPSAFE	0x0002	/* if_start() can run parallel */
 
+static inline bool
+if_output_is_mpsafe(struct ifnet *ifp)
+{
+
+	return ((ifp->if_extflags & IFEF_OUTPUT_MPSAFE) != 0);
+}
+
+static inline int
+if_output_lock(struct ifnet *cifp, struct ifnet *ifp, struct mbuf *m,
+const struct sockaddr *dst, const struct rtentry *rt)
+{
+
+	if (if_output_is_mpsafe(cifp)) {
+		return (*cifp->if_output)(ifp, m, dst, rt);
+	} else {
+		int ret;
+
+		KERNEL_LOCK(1, NULL);
+		ret = (*cifp->if_output)(ifp, m, dst, rt);
+		KERNEL_UNLOCK_ONE(NULL);
+		return ret;
+	}
+}
+
 #define	IFFBITS \
 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS" \
 "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \



CVS commit: src/sys/net

2016-06-20 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 20 06:41:30 UTC 2016

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

Log Message:
Do psref_target_destroy after purging packets

Because purging packets may try to send packets, which requires psref yet.


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 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.341 src/sys/net/if.c:1.342
--- src/sys/net/if.c:1.341	Thu Jun 16 15:18:33 2016
+++ src/sys/net/if.c	Mon Jun 20 06:41:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.341 2016/06/16 15:18:33 riastradh Exp $	*/
+/*	$NetBSD: if.c,v 1.342 2016/06/20 06:41:30 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.341 2016/06/16 15:18:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.342 2016/06/20 06:41:30 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1054,10 +1054,6 @@ if_detach(struct ifnet *ifp)
 	pserialize_perform(ifnet_psz);
 	IFNET_UNLOCK();
 
-	/* Wait for all readers to drain before freeing.  */
-	psref_target_destroy(>if_psref, ifnet_psref_class);
-	PSLIST_ENTRY_DESTROY(ifp, if_pslist_entry);
-
 	mutex_obj_free(ifp->if_ioctl_lock);
 	ifp->if_ioctl_lock = NULL;
 
@@ -1226,6 +1222,10 @@ again:
 	xc = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
 	xc_wait(xc);
 
+	/* Wait for all readers to drain before freeing.  */
+	psref_target_destroy(>if_psref, ifnet_psref_class);
+	PSLIST_ENTRY_DESTROY(ifp, if_pslist_entry);
+
 	if (ifp->if_percpuq != NULL) {
 		if_percpuq_destroy(ifp->if_percpuq);
 		ifp->if_percpuq = NULL;



CVS commit: src/sys/net

2016-06-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Jun 20 06:35:06 UTC 2016

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

Log Message:
introduce if_extflags (was if__pad1)


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 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.207 src/sys/net/if.h:1.208
--- src/sys/net/if.h:1.207	Fri Jun 10 13:31:44 2016
+++ src/sys/net/if.h	Mon Jun 20 06:35:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.207 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.208 2016/06/20 06:35:05 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -242,7 +242,7 @@ typedef struct ifnet {
 	u_short	if_index;		/* numeric abbreviation for this if */
 	short	if_timer;		/* time 'til if_slowtimo called */
 	short	if_flags;		/* up/down, broadcast, etc. */
-	short	if__pad1;		/* be nice to m68k ports */
+	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
@@ -255,7 +255,7 @@ typedef struct ifnet {
 		(struct ifnet *, struct mbuf *);
 	void	(*if_start)		/* initiate output routine */
 		(struct ifnet *);
-	int	(*if_transmit)		/* output routine (direct) */
+	int	(*if_transmit)		/* output routine, must be MP-safe */
 		(struct ifnet *, struct mbuf *);
 	int	(*if_ioctl)		/* ioctl routine */
 		(struct ifnet *, u_long, void *);
@@ -379,6 +379,9 @@ typedef struct ifnet {
 #define	IFF_LINK2	0x4000		/* per link layer defined bit */
 #define	IFF_MULTICAST	0x8000		/* supports multicast */
 
+#define	IFEF_OUTPUT_MPSAFE	0x0001	/* if_output() can run parallel */
+#define	IFEF_START_MPSAFE	0x0002	/* if_start() can run parallel */
+
 #define	IFFBITS \
 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS" \
 "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \