CVS commit: src/sys

2017-02-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 22 07:46:01 UTC 2017

Modified Files:
src/sys/netinet6: in6_var.h ip6_input.c ip6_mroute.c ip6_output.c
mld6.c nd6.c
src/sys/netipsec: key.c

Log Message:
Stop using useless IN6_*_MULTI macros


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/netinet6/in6_var.h
cvs rdiff -u -r1.174 -r1.175 src/sys/netinet6/ip6_input.c
cvs rdiff -u -r1.117 -r1.118 src/sys/netinet6/ip6_mroute.c
cvs rdiff -u -r1.185 -r1.186 src/sys/netinet6/ip6_output.c
cvs rdiff -u -r1.81 -r1.82 src/sys/netinet6/mld6.c
cvs rdiff -u -r1.229 -r1.230 src/sys/netinet6/nd6.c
cvs rdiff -u -r1.101 -r1.102 src/sys/netipsec/key.c

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

Modified files:

Index: src/sys/netinet6/in6_var.h
diff -u src/sys/netinet6/in6_var.h:1.91 src/sys/netinet6/in6_var.h:1.92
--- src/sys/netinet6/in6_var.h:1.91	Mon Jan 16 15:44:47 2017
+++ src/sys/netinet6/in6_var.h	Wed Feb 22 07:46:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_var.h,v 1.91 2017/01/16 15:44:47 christos Exp $	*/
+/*	$NetBSD: in6_var.h,v 1.92 2017/02/22 07:46:00 ozaki-r Exp $	*/
 /*	$KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $	*/
 
 /*
@@ -680,14 +680,6 @@ in6_lookup_multi(struct in6_addr *addr, 
 	return in6m;
 }
 
-#define IN6_LOOKUP_MULTI(__addr, __ifp, __in6m)			\
-/* struct in6_addr __addr; */	\
-/* struct ifnet *__ifp; */	\
-/* struct in6_multi *__in6m; */	\
-do {\
-	(__in6m) = in6_lookup_multi(&(__addr), (__ifp));	\
-} while (/*CONSTCOND*/ 0)
-
 /*
  * Macro to step through all of the in6_multi records, one at a time.
  * The current position is remembered in "step", which the caller must
@@ -726,21 +718,6 @@ in6_first_multi(struct in6_multistep *st
 	return in6_next_multi(step);		
 }
 
-#define IN6_NEXT_MULTI(__step, __in6m)		\
-/* struct in6_multistep __step; */		\
-/* struct in6_multi *__in6m; */			\
-do {		\
-	(__in6m) = in6_next_multi(&(__step));	\
-} while (/*CONSTCOND*/ 0)
-
-#define IN6_FIRST_MULTI(__step, __in6m)		\
-/* struct in6_multistep __step; */		\
-/* struct in6_multi *__in6m */			\
-do {		\
-	(__in6m) = in6_first_multi(&(__step));	\
-} while (/*CONSTCOND*/ 0)
-
-
 #if 0
 /*
  * Macros for looking up the in6_multi_mship record for a given IP6 multicast

Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.174 src/sys/netinet6/ip6_input.c:1.175
--- src/sys/netinet6/ip6_input.c:1.174	Tue Feb 21 03:59:31 2017
+++ src/sys/netinet6/ip6_input.c	Wed Feb 22 07:46:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_input.c,v 1.174 2017/02/21 03:59:31 ozaki-r Exp $	*/
+/*	$NetBSD: ip6_input.c,v 1.175 2017/02/22 07:46:00 ozaki-r Exp $	*/
 /*	$KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.174 2017/02/21 03:59:31 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.175 2017/02/22 07:46:00 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -465,7 +465,7 @@ ip6_input(struct mbuf *m, struct ifnet *
 		 * See if we belong to the destination multicast group on the
 		 * arrival interface.
 		 */
-		IN6_LOOKUP_MULTI(ip6->ip6_dst, rcvif, in6m);
+		in6m = in6_lookup_multi(>ip6_dst, rcvif);
 		if (in6m)
 			ours = 1;
 		else if (!ip6_mrouter) {

Index: src/sys/netinet6/ip6_mroute.c
diff -u src/sys/netinet6/ip6_mroute.c:1.117 src/sys/netinet6/ip6_mroute.c:1.118
--- src/sys/netinet6/ip6_mroute.c:1.117	Tue Feb 14 03:05:06 2017
+++ src/sys/netinet6/ip6_mroute.c	Wed Feb 22 07:46:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_mroute.c,v 1.117 2017/02/14 03:05:06 ozaki-r Exp $	*/
+/*	$NetBSD: ip6_mroute.c,v 1.118 2017/02/22 07:46:00 ozaki-r Exp $	*/
 /*	$KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $	*/
 
 /*
@@ -117,7 +117,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.117 2017/02/14 03:05:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.118 2017/02/22 07:46:00 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1608,7 +1608,7 @@ phyint_send(struct ip6_hdr *ip6, struct 
 	 */
 	sockaddr_in6_init(, >ip6_dst, 0, 0, 0);
 
-	IN6_LOOKUP_MULTI(ip6->ip6_dst, ifp, in6m);
+	in6m = in6_lookup_multi(>ip6_dst, ifp);
 	if (in6m != NULL) {
 		ip6_mloopback(ifp, m,
 		satocsin6(rtcache_getdst()));

Index: src/sys/netinet6/ip6_output.c
diff -u src/sys/netinet6/ip6_output.c:1.185 src/sys/netinet6/ip6_output.c:1.186
--- src/sys/netinet6/ip6_output.c:1.185	Wed Feb 22 07:05:04 2017
+++ src/sys/netinet6/ip6_output.c	Wed Feb 22 07:46:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_output.c,v 1.185 2017/02/22 07:05:04 ozaki-r Exp $	*/
+/*	$NetBSD: ip6_output.c,v 1.186 2017/02/22 07:46:00 ozaki-r Exp $	*/
 /*	$KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.185 2017/02/22 07:05:04 

CVS commit: src/sys/netinet6

2017-02-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 22 07:05:47 UTC 2017

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

Log Message:
Get rid of unnecessary splsoftnet


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 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/netinet6/nd6_rtr.c
diff -u src/sys/netinet6/nd6_rtr.c:1.132 src/sys/netinet6/nd6_rtr.c:1.133
--- src/sys/netinet6/nd6_rtr.c:1.132	Wed Feb 22 03:02:55 2017
+++ src/sys/netinet6/nd6_rtr.c	Wed Feb 22 07:05:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_rtr.c,v 1.132 2017/02/22 03:02:55 ozaki-r Exp $	*/
+/*	$NetBSD: nd6_rtr.c,v 1.133 2017/02/22 07:05:47 ozaki-r Exp $	*/
 /*	$KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.132 2017/02/22 03:02:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.133 2017/02/22 07:05:47 ozaki-r Exp $");
 
 #include 
 #include 
@@ -463,7 +463,6 @@ defrouter_addreq(struct nd_defrouter *ne
 		struct sockaddr_in6 sin6;
 		struct sockaddr sa;
 	} def, mask, gate;
-	int s;
 	int error;
 
 	memset(, 0, sizeof(def));
@@ -478,14 +477,15 @@ defrouter_addreq(struct nd_defrouter *ne
 	gate.sin6.sin6_scope_id = 0;	/* XXX */
 #endif
 
-	s = splsoftnet();
+#ifndef NET_MPSAFE
+	KASSERT(mutex_owned(softnet_lock));
+#endif
 	error = rtrequest_newmsg(RTM_ADD, , , ,
 	RTF_GATEWAY);
 	if (error == 0) {
 		nd6_numroutes++;
 		newdr->installed = 1;
 	}
-	splx(s);
 	return;
 }
 
@@ -956,7 +956,7 @@ nd6_prelist_add(struct nd_prefixctl *prc
 	struct nd_prefix **newp)
 {
 	struct nd_prefix *newpr = NULL;
-	int i, s;
+	int i;
 	int error;
 	struct in6_ifextra *ext = prc->ndprc_ifp->if_afdata[AF_INET6];
 
@@ -996,10 +996,8 @@ nd6_prelist_add(struct nd_prefixctl *prc
 		newpr->ndpr_mask.s6_addr32[i];
 	}
 
-	s = splsoftnet();
 	/* link ndpr_entry to nd_prefix list */
 	ND_PREFIX_LIST_INSERT_HEAD(newpr);
-	splx(s);
 
 	/* ND_OPT_PI_FLAG_ONLINK processing */
 	if (newpr->ndpr_raf_onlink) {
@@ -1067,7 +1065,6 @@ void
 nd6_prelist_remove(struct nd_prefix *pr)
 {
 	struct nd_pfxrouter *pfr, *next;
-	int s;
 	struct in6_ifextra *ext = pr->ndpr_ifp->if_afdata[AF_INET6];
 
 	ND6_ASSERT_WLOCK();
@@ -1075,7 +1072,6 @@ nd6_prelist_remove(struct nd_prefix *pr)
 
 	nd6_invalidate_prefix(pr);
 
-	s = splsoftnet();
 	/* unlink ndpr_entry from nd_prefix list */
 	ND_PREFIX_LIST_REMOVE(pr);
 
@@ -1093,7 +1089,6 @@ nd6_prelist_remove(struct nd_prefix *pr)
 			"%s\n", pr->ndpr_ifp->if_xname);
 		}
 	}
-	splx(s);
 
 	free(pr, M_IP6NDP);
 
@@ -,16 +2217,16 @@ in6_init_address_ltimes(struct nd_prefix
 void
 nd6_rt_flush(struct in6_addr *gateway, struct ifnet *ifp)
 {
-	int s = splsoftnet();
+
+#ifndef NET_MPSAFE
+	KASSERT(mutex_owned(softnet_lock));
+#endif
 
 	/* We'll care only link-local addresses */
-	if (!IN6_IS_ADDR_LINKLOCAL(gateway)) {
-		splx(s);
+	if (!IN6_IS_ADDR_LINKLOCAL(gateway))
 		return;
-	}
 
 	rt_delete_matched_entries(AF_INET6, rt6_deleteroute_matcher, gateway);
-	splx(s);
 }
 
 static int



CVS commit: src/sys

2017-02-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 22 07:05:04 UTC 2017

Modified Files:
src/sys/netinet: in_pcb.h ip_output.c
src/sys/netinet6: in6_pcb.h ip6_output.c

Log Message:
Add assertions and comments for lock states of socket and pcb


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.271 -r1.272 src/sys/netinet/ip_output.c
cvs rdiff -u -r1.47 -r1.48 src/sys/netinet6/in6_pcb.h
cvs rdiff -u -r1.184 -r1.185 src/sys/netinet6/ip6_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/netinet/in_pcb.h
diff -u src/sys/netinet/in_pcb.h:1.61 src/sys/netinet/in_pcb.h:1.62
--- src/sys/netinet/in_pcb.h:1.61	Thu Dec  8 05:16:33 2016
+++ src/sys/netinet/in_pcb.h	Wed Feb 22 07:05:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.h,v 1.61 2016/12/08 05:16:33 ozaki-r Exp $	*/
+/*	$NetBSD: in_pcb.h,v 1.62 2017/02/22 07:05:04 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -128,6 +128,7 @@ struct inpcb {
 INP_PKTINFO)
 
 #define	sotoinpcb(so)		((struct inpcb *)(so)->so_pcb)
+#define	inplocked(inp)		solocked((inp)->inp_socket)
 
 #ifdef _KERNEL
 void	in_losing(struct inpcb *);

Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.271 src/sys/netinet/ip_output.c:1.272
--- src/sys/netinet/ip_output.c:1.271	Fri Feb 17 04:31:34 2017
+++ src/sys/netinet/ip_output.c	Wed Feb 22 07:05:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_output.c,v 1.271 2017/02/17 04:31:34 ozaki-r Exp $	*/
+/*	$NetBSD: ip_output.c,v 1.272 2017/02/22 07:05:04 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.271 2017/02/17 04:31:34 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.272 2017/02/22 07:05:04 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1058,6 +1058,8 @@ ip_ctloutput(int op, struct socket *so, 
 	int inpflags = inp->inp_flags;
 	int optval = 0, error = 0;
 
+	KASSERT(solocked(so));
+
 	if (sopt->sopt_level != IPPROTO_IP) {
 		if (sopt->sopt_level == SOL_SOCKET && sopt->sopt_name == SO_NOHEADER)
 			return 0;
@@ -1335,6 +1337,8 @@ ip_pcbopts(struct inpcb *inp, const stru
 	u_char *dp;
 	int cnt;
 
+	KASSERT(inplocked(inp));
+
 	/* Turn off any old options. */
 	if (inp->inp_options) {
 		m_free(inp->inp_options);
@@ -1773,6 +1777,8 @@ ip_getmoptions(struct ip_moptions *imo, 
 	uint8_t optval;
 	int error = 0;
 
+	/* imo is protected by solock or refereced only by the caller */
+
 	switch (sopt->sopt_name) {
 	case IP_MULTICAST_IF:
 		if (imo == NULL || imo->imo_multicast_if_index == 0)

Index: src/sys/netinet6/in6_pcb.h
diff -u src/sys/netinet6/in6_pcb.h:1.47 src/sys/netinet6/in6_pcb.h:1.48
--- src/sys/netinet6/in6_pcb.h:1.47	Thu Dec  8 05:16:34 2016
+++ src/sys/netinet6/in6_pcb.h	Wed Feb 22 07:05:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_pcb.h,v 1.47 2016/12/08 05:16:34 ozaki-r Exp $	*/
+/*	$NetBSD: in6_pcb.h,v 1.48 2017/02/22 07:05:04 ozaki-r Exp $	*/
 /*	$KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $	*/
 
 /*
@@ -107,6 +107,8 @@ struct	in6pcb {
 #define in6p_faddr	in6p_ip6.ip6_dst
 #define in6p_laddr	in6p_ip6.ip6_src
 
+#define	in6plocked(in6p)	solocked((in6p)->in6p_socket)
+
 /* states in inp_state: */
 #define	IN6P_ATTACHED		INP_ATTACHED
 #define	IN6P_BOUND		INP_BOUND

Index: src/sys/netinet6/ip6_output.c
diff -u src/sys/netinet6/ip6_output.c:1.184 src/sys/netinet6/ip6_output.c:1.185
--- src/sys/netinet6/ip6_output.c:1.184	Fri Feb 17 03:57:17 2017
+++ src/sys/netinet6/ip6_output.c	Wed Feb 22 07:05:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_output.c,v 1.184 2017/02/17 03:57:17 ozaki-r Exp $	*/
+/*	$NetBSD: ip6_output.c,v 1.185 2017/02/22 07:05:04 ozaki-r Exp $	*/
 /*	$KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.184 2017/02/17 03:57:17 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.185 2017/02/22 07:05:04 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1359,6 +1359,7 @@ ip6_ctloutput(int op, struct socket *so,
 	int error, optval;
 	int level, optname;
 
+	KASSERT(solocked(so));
 	KASSERT(sopt != NULL);
 
 	level = sopt->sopt_level;
@@ -2073,6 +2074,8 @@ ip6_pcbopts(struct ip6_pktopts **pktopt,
 	struct mbuf *m;
 	int error = 0;
 
+	KASSERT(solocked(so));
+
 	/* turn off any old options. */
 	if (opt) {
 #ifdef DIAGNOSTIC
@@ -2467,6 +2470,8 @@ ip6_setmoptions(const struct sockopt *so
 	struct ip6_moptions *im6o = in6p->in6p_moptions;
 	struct in6_multi_mship *imm;
 
+	KASSERT(in6plocked(in6p));
+
 	if (im6o == NULL) {
 		/*
 		 * No multicast option buffer attached to the pcb;



CVS commit: src/doc

2017-02-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 22 04:44:16 UTC 2017

Modified Files:
src/doc: TODO.smpnet

Log Message:
Add l2tp(4)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/doc/TODO.smpnet

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

Modified files:

Index: src/doc/TODO.smpnet
diff -u src/doc/TODO.smpnet:1.3 src/doc/TODO.smpnet:1.4
--- src/doc/TODO.smpnet:1.3	Mon Feb 13 04:01:11 2017
+++ src/doc/TODO.smpnet	Wed Feb 22 04:44:16 2017
@@ -1,4 +1,4 @@
-$NetBSD: TODO.smpnet,v 1.3 2017/02/13 04:01:11 ozaki-r Exp $
+$NetBSD: TODO.smpnet,v 1.4 2017/02/22 04:44:16 ozaki-r Exp $
 
 MP-safe components
 ==
@@ -6,6 +6,7 @@ MP-safe components
  - bridge(4)
  - bpf(4)
  - gif(4)
+ - l2tp(4)
  - npf(7)
  - pfil(9)
  - pppoe(4)



CVS commit: src/sys/netinet6

2017-02-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 22 03:41:54 UTC 2017

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

Log Message:
Use kmem istead of malloc


To generate a diff of this commit:
cvs rdiff -u -r1.228 -r1.229 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.228 src/sys/netinet6/nd6.c:1.229
--- src/sys/netinet6/nd6.c:1.228	Wed Feb 22 03:02:55 2017
+++ src/sys/netinet6/nd6.c	Wed Feb 22 03:41:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.228 2017/02/22 03:02:55 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.c,v 1.229 2017/02/22 03:41:54 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.228 2017/02/22 03:02:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.229 2017/02/22 03:41:54 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.22
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -163,7 +163,7 @@ nd6_ifattach(struct ifnet *ifp)
 {
 	struct nd_ifinfo *nd;
 
-	nd = (struct nd_ifinfo *)malloc(sizeof(*nd), M_IP6NDP, M_WAITOK|M_ZERO);
+	nd = kmem_zalloc(sizeof(*nd), KM_SLEEP);
 
 	nd->initialized = 1;
 
@@ -202,7 +202,7 @@ nd6_ifdetach(struct ifnet *ifp, struct i
 	/* Ensure all IPv6 addresses are purged before calling nd6_purge */
 	if_purgeaddrs(ifp, AF_INET6, in6_purgeaddr);
 	nd6_purge(ifp, ext);
-	free(ext->nd_ifinfo, M_IP6NDP);
+	kmem_free(ext->nd_ifinfo, sizeof(struct nd_ifinfo));
 }
 
 void
@@ -2508,6 +2508,7 @@ nd6_sysctl(
 	void *p;
 	size_t ol;
 	int error;
+	size_t bufsize = 0;
 
 	error = 0;
 
@@ -2517,10 +2518,11 @@ nd6_sysctl(
 		return EINVAL;
 	ol = oldlenp ? *oldlenp : 0;
 
-	if (oldp) {
-		p = malloc(*oldlenp, M_TEMP, M_WAITOK);
+	if (oldp && *oldlenp > 0) {
+		p = kmem_alloc(*oldlenp, KM_SLEEP);
 		if (p == NULL)
 			return ENOMEM;
+		bufsize = *oldlenp;
 	} else
 		p = NULL;
 	switch (name) {
@@ -2544,7 +2546,7 @@ nd6_sysctl(
 		break;
 	}
 	if (p)
-		free(p, M_TEMP);
+		kmem_free(p, bufsize);
 
 	return error;
 }



CVS commit: src/tests/net/ndp

2017-02-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 22 03:03:37 UTC 2017

Modified Files:
src/tests/net/ndp: t_ra.sh

Log Message:
Add tests for expiration of default router and prefix entries


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/tests/net/ndp/t_ra.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/ndp/t_ra.sh
diff -u src/tests/net/ndp/t_ra.sh:1.24 src/tests/net/ndp/t_ra.sh:1.25
--- src/tests/net/ndp/t_ra.sh:1.24	Fri Jan 13 08:11:01 2017
+++ src/tests/net/ndp/t_ra.sh	Wed Feb 22 03:03:37 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ra.sh,v 1.24 2017/01/13 08:11:01 ozaki-r Exp $
+#	$NetBSD: t_ra.sh,v 1.25 2017/02/22 03:03:37 ozaki-r Exp $
 #
 # Copyright (c) 2015 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -94,6 +94,29 @@ shmif0:\
 _EOF
 }
 
+create_rtadvdconfig_rltime()
+{
+	local time=$1
+
+	cat << _EOF > ${CONFIG}
+shmif0:\
+	:mtu#1300:maxinterval#4:mininterval#3:rltime#$time:
+_EOF
+	$DEBUG && cat ${CONFIG}
+}
+
+create_rtadvdconfig_vltime()
+{
+	local addr=$1
+	local time=$2
+
+	cat << _EOF > ${CONFIG}
+shmif0:\
+	:mtu#1300:maxinterval#4:mininterval#3:addr="$addr":vltime#$time:
+_EOF
+	$DEBUG && cat ${CONFIG}
+}
+
 start_rtadvd()
 {
 	local sock=$1
@@ -689,6 +712,136 @@ ra_temporary_address_cleanup()
 	cleanup
 }
 
+atf_test_case ra_defrouter_expiration cleanup
+ra_defrouter_expiration_head()
+{
+
+	atf_set "descr" "Tests for default router expiration"
+	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_defrouter_expiration_body()
+{
+	local expire_time=5
+
+	rump_server_fs_start $RUMPSRV netinet6
+	rump_server_start $RUMPCLI netinet6
+
+	setup_shmif0 ${RUMPSRV} ${IP6SRV}
+	setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+	init_server $RUMPSRV
+
+	create_rtadvdconfig_rltime $expire_time
+
+	export RUMP_SERVER=${RUMPCLI}
+	atf_check -s exit:0 -o match:'0.->.1' \
+	rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+	unset RUMP_SERVER
+
+	start_rtadvd $RUMPSRV $PIDFILE
+	sleep $WAITTIME
+
+	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+	export RUMP_SERVER=${RUMPCLI}
+
+	# Terminate rtadvd to prevent new RA messages from coming
+	# Note that ifconfig down; kill -TERM doesn't work
+	kill -KILL `cat ${PIDFILE}`
+
+	# Wait until the default routers and prefix entries are expired
+	sleep $expire_time
+
+	$DEBUG && dump_entries
+
+	# Give nd6_timer a chance to sweep default routers and prefix entries
+	sleep 2
+
+	$DEBUG && dump_entries
+	atf_check -s exit:0 -o not-match:'if=shmif0' rump.ndp -r
+	atf_check -s exit:0 -o match:'No advertising router' rump.ndp -p
+	atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
+	atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
+	atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
+	atf_check -s exit:0 -o match:'fc00:1:' rump.ifconfig shmif0 inet6
+	unset RUMP_SERVER
+
+	rump_server_destroy_ifaces
+}
+
+ra_defrouter_expiration_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+atf_test_case ra_prefix_expiration cleanup
+ra_prefix_expiration_head()
+{
+
+	atf_set "descr" "Tests for prefix expiration"
+	atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_prefix_expiration_body()
+{
+	local expire_time=5
+
+	rump_server_fs_start $RUMPSRV netinet6
+	rump_server_start $RUMPCLI netinet6
+
+	setup_shmif0 ${RUMPSRV} ${IP6SRV}
+	setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+	init_server $RUMPSRV
+
+	create_rtadvdconfig_vltime "${IP6SRV_PREFIX}:" $expire_time
+
+	export RUMP_SERVER=${RUMPCLI}
+	atf_check -s exit:0 -o match:'0.->.1' \
+	rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+	unset RUMP_SERVER
+
+	start_rtadvd $RUMPSRV $PIDFILE
+	sleep $WAITTIME
+
+	check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+	export RUMP_SERVER=${RUMPCLI}
+
+	# Terminate rtadvd to prevent new RA messages from coming
+	# Note that ifconfig down; kill -TERM doesn't work
+	kill -KILL `cat ${PIDFILE}`
+
+	# Wait until the default routers and prefix entries are expired
+	sleep $expire_time
+
+	$DEBUG && dump_entries
+
+	# Give nd6_timer a chance to sweep default routers and prefix entries
+	sleep 2
+
+	$DEBUG && dump_entries
+	atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r
+	atf_check -s exit:0 -o empty rump.ndp -p
+	atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
+	atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
+	atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
+	atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6
+	unset RUMP_SERVER
+
+	rump_server_destroy_ifaces
+}
+
+ra_prefix_expiration_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 atf_init_test_cases()
 {
 
@@ -700,4 +853,6 @@ atf_init_test_cases()
 	atf_add_test_case ra_multiple_routers_single_prefix
 	atf_add_test_case ra_multiple_routers_maxifprefixes
 	atf_add_test_case ra_temporary_address
+	atf_add_test_case ra_defrouter_expiration
+	

CVS commit: src/sys/netinet6

2017-02-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Feb 22 03:02:55 UTC 2017

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

Log Message:
Fix prefix invalidation via nd6_timer

We cannot remove a prefix there. Instead just invalidate it; the prefix
will be removed when purging an associated address. This is the same as
the original behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.227 -r1.228 src/sys/netinet6/nd6.c
cvs rdiff -u -r1.82 -r1.83 src/sys/netinet6/nd6.h
cvs rdiff -u -r1.131 -r1.132 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/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.227 src/sys/netinet6/nd6.c:1.228
--- src/sys/netinet6/nd6.c:1.227	Tue Feb 14 03:05:06 2017
+++ src/sys/netinet6/nd6.c	Wed Feb 22 03:02:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.227 2017/02/14 03:05:06 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.c,v 1.228 2017/02/22 03:02:55 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.227 2017/02/14 03:05:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.228 2017/02/22 03:02:55 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -715,13 +715,12 @@ nd6_timer_work(struct work *wk, void *ar
 		 */
 		if (pr->ndpr_vltime != ND6_INFINITE_LIFETIME &&
 		time_uptime - pr->ndpr_lastupdate > pr->ndpr_vltime) {
-
 			/*
-			 * address expiration and prefix expiration are
-			 * separate.  NEVER perform in6_purgeaddr here.
+			 * Just invalidate the prefix here. Removing it
+			 * will be done when purging an associated address.
 			 */
-
-			nd6_prelist_remove(pr);
+			KASSERT(pr->ndpr_refcnt > 0);
+			nd6_invalidate_prefix(pr);
 		}
 	}
 	ND6_UNLOCK();

Index: src/sys/netinet6/nd6.h
diff -u src/sys/netinet6/nd6.h:1.82 src/sys/netinet6/nd6.h:1.83
--- src/sys/netinet6/nd6.h:1.82	Tue Feb 14 03:05:06 2017
+++ src/sys/netinet6/nd6.h	Wed Feb 22 03:02:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.h,v 1.82 2017/02/14 03:05:06 ozaki-r Exp $	*/
+/*	$NetBSD: nd6.h,v 1.83 2017/02/22 03:02:55 ozaki-r Exp $	*/
 /*	$KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $	*/
 
 /*
@@ -469,6 +469,7 @@ void nd6_defrouter_select(void);
 void nd6_defrtrlist_del(struct nd_defrouter *, struct in6_ifextra *);
 void nd6_prefix_unref(struct nd_prefix *);
 void nd6_prelist_remove(struct nd_prefix *);
+void nd6_invalidate_prefix(struct nd_prefix *);
 void nd6_pfxlist_onlink_check(void);
 struct nd_defrouter *nd6_defrouter_lookup(const struct in6_addr *, struct ifnet *);
 void nd6_rt_flush(struct in6_addr *, struct ifnet *);

Index: src/sys/netinet6/nd6_rtr.c
diff -u src/sys/netinet6/nd6_rtr.c:1.131 src/sys/netinet6/nd6_rtr.c:1.132
--- src/sys/netinet6/nd6_rtr.c:1.131	Mon Jan 16 15:44:47 2017
+++ src/sys/netinet6/nd6_rtr.c	Wed Feb 22 03:02:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_rtr.c,v 1.131 2017/01/16 15:44:47 christos Exp $	*/
+/*	$NetBSD: nd6_rtr.c,v 1.132 2017/02/22 03:02:55 ozaki-r Exp $	*/
 /*	$KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.131 2017/01/16 15:44:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.132 2017/02/22 03:02:55 ozaki-r Exp $");
 
 #include 
 #include 
@@ -1035,14 +1035,11 @@ nd6_prefix_unref(struct nd_prefix *pr)
 }
 
 void
-nd6_prelist_remove(struct nd_prefix *pr)
+nd6_invalidate_prefix(struct nd_prefix *pr)
 {
-	struct nd_pfxrouter *pfr, *next;
-	int e, s;
-	struct in6_ifextra *ext = pr->ndpr_ifp->if_afdata[AF_INET6];
+	int e;
 
 	ND6_ASSERT_WLOCK();
-	KASSERT(pr->ndpr_refcnt == 0);
 
 	/* make sure to invalidate the prefix until it is really freed. */
 	pr->ndpr_vltime = 0;
@@ -1064,6 +1061,19 @@ nd6_prelist_remove(struct nd_prefix *pr)
 		pr->ndpr_plen, if_name(pr->ndpr_ifp), e);
 		/* what should we do? */
 	}
+}
+
+void
+nd6_prelist_remove(struct nd_prefix *pr)
+{
+	struct nd_pfxrouter *pfr, *next;
+	int s;
+	struct in6_ifextra *ext = pr->ndpr_ifp->if_afdata[AF_INET6];
+
+	ND6_ASSERT_WLOCK();
+	KASSERT(pr->ndpr_refcnt == 0);
+
+	nd6_invalidate_prefix(pr);
 
 	s = splsoftnet();
 	/* unlink ndpr_entry from nd_prefix list */



CVS commit: src/lib

2017-02-21 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Feb 22 02:58:31 UTC 2017

Modified Files:
src/lib: Makefile

Log Message:
GC deprecated logic. GCC 4.8 is not in tree any more.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/lib/Makefile

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

Modified files:

Index: src/lib/Makefile
diff -u src/lib/Makefile:1.249 src/lib/Makefile:1.250
--- src/lib/Makefile:1.249	Wed Feb  8 03:44:41 2017
+++ src/lib/Makefile	Wed Feb 22 02:58:31 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.249 2017/02/08 03:44:41 kamil Exp $
+#	$NetBSD: Makefile,v 1.250 2017/02/22 02:58:31 maya Exp $
 #	from: @(#)Makefile	5.25.1.1 (Berkeley) 5/7/91
 
 .include 
@@ -83,10 +83,6 @@ SUBDIR+=	../external/gpl2/libmalloc
 .if (${MKGCC} != "no")
 SUBDIR+=	../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libobjc
 SUBDIR+=	../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libgomp
-. if ${HAVE_GCC} == 48
-SUBDIR+=	../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libmudflap
-SUBDIR+=	../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libmudflapth
-. endif
 # Should probably move GMP, MPFR and MPC builds into the GCC >= 4.5
 # specific build area, but we get better parallelism this way.
 # We don't build compat versions of these.



CVS commit: src/etc/mtree

2017-02-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Feb 22 02:42:53 UTC 2017

Modified Files:
src/etc/mtree: NetBSD.dist.tests

Log Message:
Add new directory usr/tests/kernel/arch/x86 in mtree

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/etc/mtree/NetBSD.dist.tests

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

Modified files:

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.142 src/etc/mtree/NetBSD.dist.tests:1.143
--- src/etc/mtree/NetBSD.dist.tests:1.142	Tue Feb 21 10:40:30 2017
+++ src/etc/mtree/NetBSD.dist.tests	Wed Feb 22 02:42:53 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.142 2017/02/21 10:40:30 kre Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.143 2017/02/22 02:42:53 kamil Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -49,6 +49,7 @@
 ./usr/libdata/debug/usr/tests/kernel/arch
 ./usr/libdata/debug/usr/tests/kernel/arch/amd64
 ./usr/libdata/debug/usr/tests/kernel/arch/i386
+./usr/libdata/debug/usr/tests/kernel/arch/x86
 ./usr/libdata/debug/usr/tests/kernel/kqueue
 ./usr/libdata/debug/usr/tests/kernel/kqueue/read
 ./usr/libdata/debug/usr/tests/kernel/kqueue/write
@@ -232,6 +233,7 @@
 ./usr/tests/kernel/arch
 ./usr/tests/kernel/arch/amd64
 ./usr/tests/kernel/arch/i386
+./usr/tests/kernel/arch/x86
 ./usr/tests/kernel/kqueue
 ./usr/tests/kernel/kqueue/read
 ./usr/tests/kernel/kqueue/write



CVS commit: src/tests/usr.bin/pkill

2017-02-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Feb 21 21:22:46 UTC 2017

Modified Files:
src/tests/usr.bin/pkill: t_pgrep.sh

Log Message:
Ugh... fix a last minute fix that went horribly wrong!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/pkill/t_pgrep.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/usr.bin/pkill/t_pgrep.sh
diff -u src/tests/usr.bin/pkill/t_pgrep.sh:1.1 src/tests/usr.bin/pkill/t_pgrep.sh:1.2
--- src/tests/usr.bin/pkill/t_pgrep.sh:1.1	Tue Feb 21 10:40:30 2017
+++ src/tests/usr.bin/pkill/t_pgrep.sh	Tue Feb 21 21:22:45 2017
@@ -1,4 +1,4 @@
-# $NetBSD: t_pgrep.sh,v 1.1 2017/02/21 10:40:30 kre Exp $
+# $NetBSD: t_pgrep.sh,v 1.2 2017/02/21 21:22:45 kre Exp $
 #
 # Copyright (c) 2016 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -35,9 +35,9 @@ pr50934_body() {
 
 	cat > t.c <<'!'
 #include 
-int
 #include 
 
+int
 main(int argc, char **argv)
 {
 	sleep(2);



CVS commit: src/sys/dev

2017-02-21 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Feb 21 20:23:37 UTC 2017

Modified Files:
src/sys/dev: audio.c

Log Message:
Ensure we still have a virtual channel after sleeping on sc_lock.

Addresses PR kern/51746: Panics from audio.


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/sys/dev/audio.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/audio.c
diff -u src/sys/dev/audio.c:1.306 src/sys/dev/audio.c:1.307
--- src/sys/dev/audio.c:1.306	Tue Feb 14 09:41:29 2017
+++ src/sys/dev/audio.c	Tue Feb 21 20:23:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.306 2017/02/14 09:41:29 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.307 2017/02/21 20:23:37 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.306 2017/02/14 09:41:29 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.307 2017/02/21 20:23:37 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -339,7 +339,8 @@ static void	audio_softintr_wr(void *);
 
 static int	audio_enter(dev_t, krw_t, struct audio_softc **);
 static void	audio_exit(struct audio_softc *);
-static int	audio_waitio(struct audio_softc *, kcondvar_t *);
+static int	audio_waitio(struct audio_softc *, kcondvar_t *,
+			 struct virtual_channel *);
 
 int audioclose(struct file *);
 int audioread(struct file *, off_t *, struct uio *, kauth_cred_t, int);
@@ -1516,8 +1517,10 @@ audio_exit(struct audio_softc *sc)
  * Wait for I/O to complete, releasing device lock.
  */
 static int
-audio_waitio(struct audio_softc *sc, kcondvar_t *chan)
+audio_waitio(struct audio_softc *sc, kcondvar_t *chan, struct virtual_channel *vc)
 {
+	struct audio_chan *vchan;
+	bool found = false;
 	int error;
 
 	KASSERT(mutex_owned(sc->sc_lock));
@@ -1526,6 +1529,16 @@ audio_waitio(struct audio_softc *sc, kco
 	/* Wait for pending I/O to complete. */
 	error = cv_wait_sig(chan, sc->sc_lock);
 
+	found = false;
+	SIMPLEQ_FOREACH(vchan, >sc_audiochan, entries) {
+		if (vchan->vc == vc) {
+			found = true;
+			break;
+		}
+	}
+	if (found == false)
+		error = EIO;
+
 	return error;
 }
 
@@ -2325,7 +2338,7 @@ audio_drain(struct audio_softc *sc, stru
 			audio_stream_get_used(>sc_mpr.s),
 			cb->drops));
 		mutex_exit(sc->sc_intr_lock);
-		error = audio_waitio(sc, >sc_wchan);
+		error = audio_waitio(sc, >sc_wchan, vc);
 		mutex_enter(sc->sc_intr_lock);
 		if (sc->sc_dying)
 			error = EIO;
@@ -2476,7 +2489,7 @@ audio_read(struct audio_softc *sc, struc
 	 vc->sc_mpr.stamp, vc->sc_wstamp));
 if (ioflag & IO_NDELAY)
 	return EWOULDBLOCK;
-error = audio_waitio(sc, >sc_rchan);
+error = audio_waitio(sc, >sc_rchan, vc);
 if (sc->sc_dying)
 	error = EIO;
 if (error)
@@ -2504,7 +2517,7 @@ audio_read(struct audio_softc *sc, struc
 			if (ioflag & IO_NDELAY)
 return EWOULDBLOCK;
 			DPRINTFN(2, ("audio_read: sleep used=%d\n", used));
-			error = audio_waitio(sc, >sc_rchan);
+			error = audio_waitio(sc, >sc_rchan, vc);
 			if (sc->sc_dying)
 error = EIO;
 			if (error)
@@ -2832,7 +2845,7 @@ audio_write(struct audio_softc *sc, stru
 			mutex_exit(sc->sc_intr_lock);
 			if (ioflag & IO_NDELAY)
 return EWOULDBLOCK;
-			error = audio_waitio(sc, >sc_wchan);
+			error = audio_waitio(sc, >sc_wchan, vc);
 			if (sc->sc_dying)
 error = EIO;
 			if (error)



CVS commit: src/share/man/man9

2017-02-21 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Feb 21 19:53:49 UTC 2017

Modified Files:
src/share/man/man9: ieee80211_radiotap.9

Log Message:
Fix PR standards/51989: the extension bit extends the presence bitmap
by 32 bits, not 64.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/ieee80211_radiotap.9

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

Modified files:

Index: src/share/man/man9/ieee80211_radiotap.9
diff -u src/share/man/man9/ieee80211_radiotap.9:1.15 src/share/man/man9/ieee80211_radiotap.9:1.16
--- src/share/man/man9/ieee80211_radiotap.9:1.15	Tue Mar 18 18:20:40 2014
+++ src/share/man/man9/ieee80211_radiotap.9	Tue Feb 21 19:53:49 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: ieee80211_radiotap.9,v 1.15 2014/03/18 18:20:40 riastradh Exp $
+.\" $NetBSD: ieee80211_radiotap.9,v 1.16 2017/02/21 19:53:49 dyoung Exp $
 .\"
 .\" Copyright (c) 2004	Bruce M. Simpson ,
 .\"			Darron Broad .
@@ -218,7 +218,7 @@ This bit is reserved for any future exte
 structure.
 A driver sets
 .Dv IEEE80211_RADIOTAP_EXT
-to extend the it_present bitmap by another 64 bits.
+to extend the it_present bitmap by another 32 bits.
 The bitmap can be extended by multiples of 32 bits to 96, 128, 160
 bits or longer, by setting
 .Dv IEEE80211_RADIOTAP_EXT



CVS commit: src/lib/libc/gen

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 19:53:20 UTC 2017

Modified Files:
src/lib/libc/gen: popen.3

Log Message:
Use Fn for function name.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/gen/popen.3

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

Modified files:

Index: src/lib/libc/gen/popen.3
diff -u src/lib/libc/gen/popen.3:1.20 src/lib/libc/gen/popen.3:1.21
--- src/lib/libc/gen/popen.3:1.20	Wed Jan 21 08:35:31 2015
+++ src/lib/libc/gen/popen.3	Tue Feb 21 19:53:20 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: popen.3,v 1.20 2015/01/21 08:35:31 wiz Exp $
+.\"	$NetBSD: popen.3,v 1.21 2017/02/21 19:53:20 abhinav Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -57,15 +57,15 @@ a process by creating an IPC connection,
 forking,
 and invoking the shell.
 Historically,
-.Nm popen
+.Fn popen
 was implemented with a unidirectional pipe;
 hence many implementations of
-.Nm popen
+.Fn popen
 only allow the
 .Fa type
 argument to specify reading or writing, not both.
 Since
-.Nm popen
+.Fn popen
 is now implemented using sockets, the
 .Fa type
 may request a bidirectional data flow.



CVS commit: src/lib/libc/stdio

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 18:47:40 UTC 2017

Modified Files:
src/lib/libc/stdio: printf.3

Log Message:
Insert comma between two Nm entries.
Replace Nm with Fn to refer a function.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/lib/libc/stdio/printf.3

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

Modified files:

Index: src/lib/libc/stdio/printf.3
diff -u src/lib/libc/stdio/printf.3:1.65 src/lib/libc/stdio/printf.3:1.66
--- src/lib/libc/stdio/printf.3:1.65	Thu Nov 19 10:03:26 2015
+++ src/lib/libc/stdio/printf.3	Tue Feb 21 18:47:40 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: printf.3,v 1.65 2015/11/19 10:03:26 pgoyette Exp $
+.\"	$NetBSD: printf.3,v 1.66 2017/02/21 18:47:40 abhinav Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -39,7 +39,7 @@
 .Sh NAME
 .Nm printf ,
 .Nm fprintf ,
-.Nm dprintf
+.Nm dprintf ,
 .Nm sprintf ,
 .Nm snprintf ,
 .Nm snprintf_ss ,
@@ -937,7 +937,7 @@ conversions, as well as other nonsensica
 are not standard; such combinations should be avoided.
 .Pp
 The
-.Nm
+.Fn printf
 family of functions do not correctly handle multibyte characters in the
 .Fa format
 argument.



CVS commit: src/usr.sbin/syslogd

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 18:36:39 UTC 2017

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
Remove duplicate word from the sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/syslogd/syslog.conf.5

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/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.23 src/usr.sbin/syslogd/syslog.conf.5:1.24
--- src/usr.sbin/syslogd/syslog.conf.5:1.23	Tue Feb 21 18:28:28 2017
+++ src/usr.sbin/syslogd/syslog.conf.5	Tue Feb 21 18:36:39 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslog.conf.5,v 1.23 2017/02/21 18:28:28 abhinav Exp $
+.\"	$NetBSD: syslog.conf.5,v 1.24 2017/02/21 18:36:39 abhinav Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -511,7 +511,7 @@ message containing hashes of previous me
 .Pp
 To detect later manipulation one has to keep a copy of the key used for
 signing (otherwise an attacker could alter the logs and sign them with his
-his own key).
+own key).
 If TLS is used with a DSA key then the same key will be used for signing.
 This is the recommended setup because it makes it easy to have copies of
 the certificate (with the public key) in backups.



CVS commit: src/usr.sbin/syslogd

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 18:28:28 UTC 2017

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
Fix typos.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/syslogd/syslog.conf.5

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/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.22 src/usr.sbin/syslogd/syslog.conf.5:1.23
--- src/usr.sbin/syslogd/syslog.conf.5:1.22	Tue Jan  5 00:41:30 2016
+++ src/usr.sbin/syslogd/syslog.conf.5	Tue Feb 21 18:28:28 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslog.conf.5,v 1.22 2016/01/05 00:41:30 khorben Exp $
+.\"	$NetBSD: syslog.conf.5,v 1.23 2017/02/21 18:28:28 abhinav Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -330,7 +330,7 @@ program on the named host.
 After the closing bracket a colon
 .Pq Sq \&:
 and a port or service name may be appended.
-Additional options are configured in parantheses in the form of key="value".
+Additional options are configured in parentheses in the form of key="value".
 Recognized keywords are
 .Ar subject ,
 .Ar fingerprint ,
@@ -476,7 +476,7 @@ and the hashes of the certificates given
 On any match the client is authenticated.
 .Sh BUFFERING
 .Xr syslogd 8
-is able to buffer temporary not writeable messages in memory.
+is able to buffer temporary not writable messages in memory.
 To limit the memory consumed for this buffering the following optons may be
 given:
 .Bl -ohang
@@ -590,7 +590,7 @@ mail.*	/var/log/maillog
 
 # Log all messages of level info or higher to another
 # machine using TLS with an alternative portname and a
-# fingerprint for athentication
+# fingerprint for authentication
 *.info			@[logserver]:1234(fingerprint="SHA1:01:02:...")
 
 # Root and Eric get alert and higher messages.



CVS commit: src/lib/libc/gen

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 18:22:15 UTC 2017

Modified Files:
src/lib/libc/gen: syslog.3

Log Message:
Fix spelling of "parenthesis".


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/gen/syslog.3

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

Modified files:

Index: src/lib/libc/gen/syslog.3
diff -u src/lib/libc/gen/syslog.3:1.29 src/lib/libc/gen/syslog.3:1.30
--- src/lib/libc/gen/syslog.3:1.29	Mon Jul 25 19:42:50 2011
+++ src/lib/libc/gen/syslog.3	Tue Feb 21 18:22:15 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslog.3,v 1.29 2011/07/25 19:42:50 njoly Exp $
+.\"	$NetBSD: syslog.3,v 1.30 2017/02/21 18:22:15 abhinav Exp $
 .\"	$OpenBSD: syslog.3,v 1.25 2005/07/22 03:16:58 jaredy Exp $
 .\"
 .\" Copyright (c) 1985, 1991, 1993
@@ -511,7 +511,7 @@ A
 must only contain up to 32 ASCII characters.
 A
 .Fa sdfmt
-has strict rules for paranthesis and character quoting.
+has strict rules for parenthesis and character quoting.
 If the
 .Fa msgfmt
 contains UTF-8 characters, then it has to start with a Byte Order Mark.



CVS commit: src/lib/libc/sys

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 18:01:38 UTC 2017

Modified Files:
src/lib/libc/sys: dup.2

Log Message:
Use .Fn to refer functions instead of .Nm.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/sys/dup.2

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

Modified files:

Index: src/lib/libc/sys/dup.2
diff -u src/lib/libc/sys/dup.2:1.31 src/lib/libc/sys/dup.2:1.32
--- src/lib/libc/sys/dup.2:1.31	Tue Feb 21 17:56:21 2017
+++ src/lib/libc/sys/dup.2	Tue Feb 21 18:01:38 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dup.2,v 1.31 2017/02/21 17:56:21 abhinav Exp $
+.\"	$NetBSD: dup.2,v 1.32 2017/02/21 18:01:38 abhinav Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -77,13 +77,13 @@ call must be issued.
 (This is not generally possible for pipes and sockets.)
 .Pp
 The
-.Nm dup
+.Fn dup
 call chooses the new descriptor: it is the lowest-numbered descriptor
 not currently in use.
 The
-.Nm dup2
+.Fn dup2
 and
-.Nm dup3
+.Fn dup3
 calls allow the caller to choose the new descriptor by passing
 .Fa newfd ,
 which must be within the range of valid descriptors.



CVS commit: src/lib/libc/sys

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 17:56:21 UTC 2017

Modified Files:
src/lib/libc/sys: dup.2

Log Message:
Fix spelling of "includes".


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/sys/dup.2

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

Modified files:

Index: src/lib/libc/sys/dup.2
diff -u src/lib/libc/sys/dup.2:1.30 src/lib/libc/sys/dup.2:1.31
--- src/lib/libc/sys/dup.2:1.30	Wed Dec 25 02:49:52 2013
+++ src/lib/libc/sys/dup.2	Tue Feb 21 17:56:21 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: dup.2,v 1.30 2013/12/25 02:49:52 wiz Exp $
+.\"	$NetBSD: dup.2,v 1.31 2017/02/21 17:56:21 abhinav Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -117,7 +117,7 @@ and can to some extent be adjusted with
 .Pp
 The
 .Fn dup3
-call includs an additional
+call includes an additional
 .Fa flags
 argument supporting a subset of the
 .Xr open 2



CVS commit: src/crypto/external/bsd/heimdal/lib/libasn1

2017-02-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 21 16:07:17 UTC 2017

Modified Files:
src/crypto/external/bsd/heimdal/lib/libasn1: Makefile

Log Message:
reproduced also on the regular (not -m32) build.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/crypto/external/bsd/heimdal/lib/libasn1/Makefile

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

Modified files:

Index: src/crypto/external/bsd/heimdal/lib/libasn1/Makefile
diff -u src/crypto/external/bsd/heimdal/lib/libasn1/Makefile:1.4 src/crypto/external/bsd/heimdal/lib/libasn1/Makefile:1.5
--- src/crypto/external/bsd/heimdal/lib/libasn1/Makefile:1.4	Fri Feb 10 23:56:37 2017
+++ src/crypto/external/bsd/heimdal/lib/libasn1/Makefile	Tue Feb 21 11:07:17 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2017/02/11 04:56:37 christos Exp $
+# $NetBSD: Makefile,v 1.5 2017/02/21 16:07:17 christos Exp $
 
 USE_FORT?= yes	# network protocol library
 
@@ -81,6 +81,5 @@ SUBDIR=	asn1_compile
 # function orders and since the profile code uses the function
 # number for label generation, we end up with one of two different
 # label orders. Disabling ASLR or optimization fixes it.
-# This happens only with -m32...
 COPTS.asn1_krb5_asn1.c+=-O0
 .endif



CVS commit: src/usr.sbin/powerd

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 15:15:20 UTC 2017

Modified Files:
src/usr.sbin/powerd: powerd.8

Log Message:
Fix spelling of "occurs".


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/powerd/powerd.8

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/powerd/powerd.8
diff -u src/usr.sbin/powerd/powerd.8:1.25 src/usr.sbin/powerd/powerd.8:1.26
--- src/usr.sbin/powerd/powerd.8:1.25	Tue Nov  6 19:08:45 2012
+++ src/usr.sbin/powerd/powerd.8	Tue Feb 21 15:15:19 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: powerd.8,v 1.25 2012/11/06 19:08:45 dholland Exp $
+.\"	$NetBSD: powerd.8,v 1.26 2017/02/21 15:15:19 abhinav Exp $
 .\"
 .\" Copyright (c) 2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -141,7 +141,7 @@ This script is called when an event occu
 .It Em sensor_fan
 This script is called when an event occurs on a fan sensor.
 .It Em sensor_indicator
-This script is called when an event ocurrs on a indicator/integer sensor.
+This script is called when an event occurs on a indicator/integer sensor.
 .It Em sensor_power
 This script is called when an event occurs on a power sensor (W/Ampere).
 .It Em sensor_resistance



CVS commit: src/sys/external/bsd/drm2

2017-02-21 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Feb 21 14:19:40 UTC 2017

Modified Files:
src/sys/external/bsd/drm2/dist/include/drm: drmP.h
src/sys/external/bsd/drm2/pci: drm_pci.c

Log Message:
drmkms_pci: use MSI if available.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/dist/include/drm/drmP.h
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/pci/drm_pci.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/external/bsd/drm2/dist/include/drm/drmP.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.11 src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.12
--- src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.11	Wed Apr 29 04:38:55 2015
+++ src/sys/external/bsd/drm2/dist/include/drm/drmP.h	Tue Feb 21 14:19:39 2017
@@ -1268,6 +1268,7 @@ struct drm_device {
 	bool irq_enabled;		/**< True if irq handler is enabled */
 #ifdef __NetBSD__
 	struct drm_bus_irq_cookie *irq_cookie;
+	pci_intr_handle_t *intr_handles;
 #endif
 	__volatile__ long context_flag;	/**< Context swapping flag */
 	int last_context;		/**< Last current context */

Index: src/sys/external/bsd/drm2/pci/drm_pci.c
diff -u src/sys/external/bsd/drm2/pci/drm_pci.c:1.13 src/sys/external/bsd/drm2/pci/drm_pci.c:1.14
--- src/sys/external/bsd/drm2/pci/drm_pci.c:1.13	Wed Apr 29 04:38:55 2015
+++ src/sys/external/bsd/drm2/pci/drm_pci.c	Tue Feb 21 14:19:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_pci.c,v 1.13 2015/04/29 04:38:55 riastradh Exp $	*/
+/*	$NetBSD: drm_pci.c,v 1.14 2017/02/21 14:19:40 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.13 2015/04/29 04:38:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.14 2017/02/21 14:19:40 nonaka Exp $");
 
 #include 
 #include 
@@ -232,16 +232,17 @@ drm_pci_irq_install(struct drm_device *d
 struct drm_bus_irq_cookie **cookiep)
 {
 	const struct pci_attach_args *const pa = drm_pci_attach_args(dev);
-	pci_intr_handle_t ih;
 	const char *intrstr;
 	void *ih_cookie;
 	char intrbuf[PCI_INTRSTR_LEN];
 
-	if (pci_intr_map(pa, ))
+	if (pci_intr_alloc(pa, >intr_handles, NULL, 0))
 		return -ENOENT;
 
-	intrstr = pci_intr_string(pa->pa_pc, ih, intrbuf, sizeof(intrbuf));
-	ih_cookie = pci_intr_establish(pa->pa_pc, ih, IPL_DRM, handler, arg);
+	intrstr = pci_intr_string(pa->pa_pc, dev->intr_handles[0], intrbuf,
+	sizeof(intrbuf));
+	ih_cookie = pci_intr_establish(pa->pa_pc, dev->intr_handles[0],
+	IPL_DRM, handler, arg);
 	if (ih_cookie == NULL) {
 		aprint_error_dev(dev->dev,
 		"couldn't establish interrupt at %s (%s)\n",
@@ -262,6 +263,7 @@ drm_pci_irq_uninstall(struct drm_device 
 	const struct pci_attach_args *pa = drm_pci_attach_args(dev);
 
 	pci_intr_disestablish(pa->pa_pc, (void *)cookie);
+	pci_intr_release(pa->pa_pc, dev->intr_handles, 1);
 }
 
 static const char *



CVS commit: src/usr.bin/pkill

2017-02-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Feb 21 13:09:56 UTC 2017

Modified Files:
src/usr.bin/pkill: pkill.c

Log Message:
PR bin/50934 -- avoid core dump if a process being examined has set
its argv[0] to NULL.

XXX Needs pullups netbsd-7-0 and netbsd-7 (bug was introduced after
netbsd-6 and never pulled up, so no netbsd-6 pullups required.)


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/pkill/pkill.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.bin/pkill/pkill.c
diff -u src/usr.bin/pkill/pkill.c:1.30 src/usr.bin/pkill/pkill.c:1.31
--- src/usr.bin/pkill/pkill.c:1.30	Fri Jan  9 12:45:32 2015
+++ src/usr.bin/pkill/pkill.c	Tue Feb 21 13:09:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pkill.c,v 1.30 2015/01/09 12:45:32 prlw1 Exp $	*/
+/*	$NetBSD: pkill.c,v 1.31 2017/02/21 13:09:56 kre Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: pkill.c,v 1.30 2015/01/09 12:45:32 prlw1 Exp $");
+__RCSID("$NetBSD: pkill.c,v 1.31 2017/02/21 13:09:56 kre Exp $");
 #endif /* !lint */
 
 #include 
@@ -296,8 +296,10 @@ main(int argc, char **argv)
 	pargv[0]);
 	pargv++;
 }
-			} else
+			} else if (pargv[0] != NULL)
 strlcpy(buf, pargv[0], sizeof(buf));
+			else
+strlcpy(buf, kp->p_comm, sizeof(buf));
 
 			rv = regexec(, buf, 1, , 0);
 			if (rv == 0) {



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-21 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Feb 21 10:53:37 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: TODO.efiboot
src/sys/arch/i386/stand/efiboot/bootia32: Makefile efibootia32.c
Added Files:
src/sys/arch/i386/stand/efiboot/bootia32: startprog32.S

Log Message:
fix to be able to boot amd64 kernel from 32bit efiboot (booia32.efi).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/TODO.efiboot
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootia32/Makefile \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/TODO.efiboot
diff -u src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.1 src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.2
--- src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.1	Sat Feb 11 10:33:44 2017
+++ src/sys/arch/i386/stand/efiboot/TODO.efiboot	Tue Feb 21 10:53:37 2017
@@ -3,7 +3,6 @@
  * boot from CD/DVD (bootable from CD/DVD, but root fs not found.)
  * load boot.cfg from EFI system partition (FAT32)
  * fix module_init(). need to allocate memory for modules.
- * bootia32.efi can load kernel, but can't start kernel
 
 - kernel
  * handle UEFI variables (/dev/efivar)

Index: src/sys/arch/i386/stand/efiboot/bootia32/Makefile
diff -u src/sys/arch/i386/stand/efiboot/bootia32/Makefile:1.1 src/sys/arch/i386/stand/efiboot/bootia32/Makefile:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/Makefile:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/Makefile	Tue Feb 21 10:53:37 2017
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.1 2017/01/24 11:09:14 nonaka Exp $
+#	$NetBSD: Makefile,v 1.2 2017/02/21 10:53:37 nonaka Exp $
 
 PROG=		bootia32.efi
 OBJFMT=		pei-i386
 
-EXTRA_SOURCES=	efibootia32.c
+EXTRA_SOURCES=	efibootia32.c startprog32.S
 
 CPUFLAGS=	-march=i686 -mtune=i686
 GNUEFIARCH=	ia32
Index: src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
diff -u src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.1 src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c	Tue Feb 21 10:53:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootia32.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: efibootia32.c,v 1.2 2017/02/21 10:53:37 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -32,18 +32,40 @@
 
 struct x86_boot_params boot_params;
 
+void startprog32_start(physaddr_t, uint32_t, uint32_t *, physaddr_t,
+physaddr_t, physaddr_t, u_long, void *);
+extern void (*startprog32)(physaddr_t, uint32_t, uint32_t *, physaddr_t,
+physaddr_t, physaddr_t, u_long, void *);
+extern u_int startprog32_size;
+
 void
 efi_md_init(void)
 {
-	/* Nothing to do */
+	EFI_STATUS status;
+	EFI_PHYSICAL_ADDRESS addr = EFI_ALLOCATE_MAX_ADDRESS;
+	u_int sz = EFI_SIZE_TO_PAGES(startprog32_size);
+
+	status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress,
+	EfiLoaderData, sz, );
+	if (EFI_ERROR(status))
+		Panic(L"%a: AllocatePages() failed: %d page(s): %r",
+		__func__, sz, status);
+	startprog32 = (void *)(u_long)addr;
+	CopyMem(startprog32, startprog32_start, startprog32_size);
 }
 
+/* ARGSUSED */
 void
 startprog(physaddr_t entry, uint32_t argc, uint32_t *argv, physaddr_t sp)
 {
-	Panic(L"%a: not implemented", __func__);
+
+	(*startprog32)(entry, argc, argv,
+	(physaddr_t)startprog32 + startprog32_size,
+	efi_kernel_start, efi_kernel_start + efi_loadaddr,
+	efi_kernel_size, startprog32);
 }
 
+/* ARGSUSED */
 void
 multiboot(physaddr_t entry, physaddr_t header, physaddr_t sp)
 {

Added files:

Index: src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S
diff -u /dev/null src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S:1.1
--- /dev/null	Tue Feb 21 10:53:37 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S	Tue Feb 21 10:53:37 2017
@@ -0,0 +1,243 @@
+/*	$NetBSD: startprog32.S,v 1.1 2017/02/21 10:53:37 nonaka Exp $	*/
+/*	NetBSD: startprog.S,v 1.4 2016/12/04 08:21:08 maxv Exp	*/
+
+/*
+ * Ported to boot 386BSD by Julian Elischer (jul...@tfs.com) Sept 1992
+ *
+ * Mach Operating System
+ * Copyright (c) 1992, 1991 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON 

CVS commit: src

2017-02-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Feb 21 10:40:30 UTC 2017

Modified Files:
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests
src/tests/usr.bin: Makefile
Added Files:
src/tests/usr.bin/pkill: Makefile t_pgrep.sh

Log Message:
PR bin/50934

Add a test program for the bug described in this PR.
This is the first pkill/pgrep/prenice test (more would be good!)

This test has been confirmed to work once the bug described in the PR
has been fixed, so the test is not marked "expected to fail" even
though initially that is what should happen.

Note: the test cana also fail if the system running the tests happens
to be running processes with names that match the patterns searched for
by the test, other than the test program itself.  This is expected to be
unlikely.


To generate a diff of this commit:
cvs rdiff -u -r1.722 -r1.723 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.141 -r1.142 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/pkill/Makefile \
src/tests/usr.bin/pkill/t_pgrep.sh

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.722 src/distrib/sets/lists/tests/mi:1.723
--- src/distrib/sets/lists/tests/mi:1.722	Mon Feb 20 03:14:42 2017
+++ src/distrib/sets/lists/tests/mi	Tue Feb 21 10:40:30 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.722 2017/02/20 03:14:42 kamil Exp $
+# $NetBSD: mi,v 1.723 2017/02/21 10:40:30 kre Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3812,6 +3812,10 @@
 ./usr/tests/usr.bin/netpgpverify/Atffile		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/netpgpverify/Kyuafile		tests-usr.bin-tests	compattestfile,atf,kyua
 ./usr/tests/usr.bin/netpgpverify/t_netpgpverify		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/pkill			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/pkill/Atffile		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/pkill/Kyuafile		tests-usr.bin-tests	compattestfile,atf,kyua
+./usr/tests/usr.bin/pkill/t_pgrep		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/prtests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/pr/Atffile			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/pr/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.141 src/etc/mtree/NetBSD.dist.tests:1.142
--- src/etc/mtree/NetBSD.dist.tests:1.141	Mon Feb 20 03:14:42 2017
+++ src/etc/mtree/NetBSD.dist.tests	Tue Feb 21 10:40:30 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.141 2017/02/20 03:14:42 kamil Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.142 2017/02/21 10:40:30 kre Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -407,6 +407,7 @@
 ./usr/tests/usr.bin/mixerctl
 ./usr/tests/usr.bin/mkdep
 ./usr/tests/usr.bin/nbperf
+./usr/tests/usr.bin/pkill
 ./usr/tests/usr.bin/pr
 ./usr/tests/usr.bin/rump_server
 ./usr/tests/usr.bin/sdiff

Index: src/tests/usr.bin/Makefile
diff -u src/tests/usr.bin/Makefile:1.23 src/tests/usr.bin/Makefile:1.24
--- src/tests/usr.bin/Makefile:1.23	Mon Jan  2 15:40:09 2017
+++ src/tests/usr.bin/Makefile	Tue Feb 21 10:40:30 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2017/01/02 15:40:09 christos Exp $
+#	$NetBSD: Makefile,v 1.24 2017/02/21 10:40:30 kre Exp $
 #
 
 .include 
@@ -7,8 +7,8 @@ TESTSDIR=   ${TESTSBASE}/usr.bin
 
 TESTS_SUBDIRS=	awk basename bzip2 cc cmp config cut \
 		diff dirname find gdb grep gzip id \
-		infocmp jot ld m4 make mixerctl mkdep \
-		nbperf netpgpverify pr rump_server shmif_dumpbus sdiff \
+		infocmp jot ld m4 make mixerctl mkdep nbperf netpgpverify \
+		pkill pr rump_server shmif_dumpbus sdiff \
 		sed sort tmux tr unifdef uniq vmstat xlint
 
 .include 

Added files:

Index: src/tests/usr.bin/pkill/Makefile
diff -u /dev/null src/tests/usr.bin/pkill/Makefile:1.1
--- /dev/null	Tue Feb 21 10:40:30 2017
+++ src/tests/usr.bin/pkill/Makefile	Tue Feb 21 10:40:30 2017
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2017/02/21 10:40:30 kre Exp $
+
+.include 
+
+TESTSDIR=	${TESTSBASE}/usr.bin/pkill
+TESTS_SH=	t_pgrep
+
+.include 
Index: src/tests/usr.bin/pkill/t_pgrep.sh
diff -u /dev/null src/tests/usr.bin/pkill/t_pgrep.sh:1.1
--- /dev/null	Tue Feb 21 10:40:30 2017
+++ src/tests/usr.bin/pkill/t_pgrep.sh	Tue Feb 21 10:40:30 2017
@@ -0,0 +1,75 @@
+# $NetBSD: t_pgrep.sh,v 1.1 2017/02/21 10:40:30 kre Exp $
+#
+# Copyright (c) 2016 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of 

CVS commit: src/usr.bin/look

2017-02-21 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Tue Feb 21 09:23:31 UTC 2017

Modified Files:
src/usr.bin/look: look.c

Log Message:
Properly check mmap(2) return value. We can end up with a segmentation
fault if the user does not provide a regular file as look(1) file
argument.

Kindly reviewed by 


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/look/look.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.bin/look/look.c
diff -u src/usr.bin/look/look.c:1.16 src/usr.bin/look/look.c:1.17
--- src/usr.bin/look/look.c:1.16	Thu Feb 23 22:57:53 2012
+++ src/usr.bin/look/look.c	Tue Feb 21 09:23:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: look.c,v 1.16 2012/02/23 22:57:53 joerg Exp $	*/
+/*	$NetBSD: look.c,v 1.17 2017/02/21 09:23:31 leot Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)look.c	8.2 (Berkeley) 5/4/95";
 #endif
-__RCSID("$NetBSD: look.c,v 1.16 2012/02/23 22:57:53 joerg Exp $");
+__RCSID("$NetBSD: look.c,v 1.17 2017/02/21 09:23:31 leot Exp $");
 #endif /* not lint */
 
 /*
@@ -147,7 +147,7 @@ main(int argc, char *argv[])
 		err(2, "%s", file);
 	}
 	if ((front = mmap(NULL, len,
-	PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0)) == NULL)
+	PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0)) == MAP_FAILED)
 		err(2, "%s", file);
 	back = front + len;
 	exit(look(string, front, back));



CVS commit: src/tests/kernel/arch/amd64

2017-02-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Feb 21 08:40:16 UTC 2017

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

Log Message:
Add new tests dbregs_dr*_dont_inherit_execve in arch/amd64

Added tests:
 - dbregs_dr0_dont_inherit_execve
 - dbregs_dr1_dont_inherit_execve
 - dbregs_dr2_dont_inherit_execve
 - dbregs_dr3_dont_inherit_execve
 - dbregs_dr6_dont_inherit_execve
 - dbregs_dr7_dont_inherit_execve

Debug Registers must no be inherited after exec() call.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/tests/kernel/arch/amd64/t_ptrace_wait.c

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

Modified files:

Index: src/tests/kernel/arch/amd64/t_ptrace_wait.c
diff -u src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.23 src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.24
--- src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.23	Mon Feb 20 06:48:49 2017
+++ src/tests/kernel/arch/amd64/t_ptrace_wait.c	Tue Feb 21 08:40:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.23 2017/02/20 06:48:49 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.24 2017/02/21 08:40:16 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.23 2017/02/20 06:48:49 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.24 2017/02/21 08:40:16 kamil Exp $");
 
 #include 
 #include 
@@ -6678,6 +6678,624 @@ ATF_TC_BODY(dbregs_dr7_dont_inherit_lwp,
 }
 #endif
 
+#if defined(HAVE_DBREGS)
+ATF_TC(dbregs_dr0_dont_inherit_execve);
+ATF_TC_HEAD(dbregs_dr0_dont_inherit_execve, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Verify that execve(2) is intercepted by tracer and Debug "
+	"Register 0 is reset");
+}
+
+ATF_TC_BODY(dbregs_dr0_dont_inherit_execve, tc)
+{
+	const int sigval = SIGTRAP;
+	pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	size_t i;
+	struct dbreg r1;
+	struct dbreg r2;
+
+	struct ptrace_siginfo info;
+	memset(, 0, sizeof(info));
+
+	printf("Before forking process PID=%d\n", getpid());
+	ATF_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		printf("Before calling execve(2) from child\n");
+		execlp("/bin/echo", "/bin/echo", NULL);
+
+		FORKEE_ASSERT(0 && "Not reached");
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Call GETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, , 0) != -1);
+
+	printf("State of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	r1.dr[0] = (long)(intptr_t)check_happy;
+	printf("Set DR0 (r1.dr[0]) to new value %#lx\n", r1.dr[0]);
+
+	printf("New state of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	printf("Call SETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_SETDBREGS, child, , 0) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+	ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
+
+	printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+	printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+	info.psi_siginfo.si_errno);
+
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC);
+
+	printf("Call GETDBREGS for the child process after execve(2)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, , 0) != -1);
+
+	printf("State of the debug registers (r2):\n");
+	for (i = 0; i < __arraycount(r2.dr); i++)
+		printf("r2[%zu]=%#lx\n", i, r2.dr[i]);
+
+	printf("Assert that (r1) and (r2) are not the same\n");
+	ATF_REQUIRE(memcmp(, , sizeof(r1)) != 0);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+