CVS commit: src/tests/net/net

2016-11-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov  7 05:44:48 UTC 2016

Modified Files:
src/tests/net/net: t_ping6_opts.sh

Log Message:
Add tests for combination use of -g option and hops optional argument


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/net/net/t_ping6_opts.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/net/t_ping6_opts.sh
diff -u src/tests/net/net/t_ping6_opts.sh:1.3 src/tests/net/net/t_ping6_opts.sh:1.4
--- src/tests/net/net/t_ping6_opts.sh:1.3	Mon Nov  7 05:25:37 2016
+++ src/tests/net/net/t_ping6_opts.sh	Mon Nov  7 05:44:48 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ping6_opts.sh,v 1.3 2016/11/07 05:25:37 ozaki-r Exp $
+#	$NetBSD: t_ping6_opts.sh,v 1.4 2016/11/07 05:44:48 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -398,6 +398,23 @@ ping6_opts_hops_body()
 	$IP6SRCGW2 $IP6DST
 	check_echo_request_pkt_with_macaddr_and_rthdr0 \
 	$my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+	# ping6 -g  hops
+	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+	-g $IP6SRCGW $IP6SRCGW $IP6DST
+	check_echo_request_pkt_with_macaddr_and_rthdr0 \
+	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
+
+	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+	-g $IP6SRCGW2 $IP6SRCGW2 $IP6DST
+	check_echo_request_pkt_with_macaddr_and_rthdr0 \
+	$my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+	# ping6 -g  hops, but different nexthops (is it valid?)
+	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+	-g $IP6SRCGW $IP6SRCGW2 $IP6DST
+	check_echo_request_pkt_with_macaddr_and_rthdr0 \
+	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
 }
 
 ping6_opts_hops_cleanup()



CVS commit: src/tests/net

2016-11-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov  7 05:25:37 UTC 2016

Modified Files:
src/tests/net/arp: t_arp.sh t_dad.sh
src/tests/net/icmp: t_icmp6_redirect.sh t_icmp_redirect.sh
src/tests/net/if_pppoe: t_pppoe.sh
src/tests/net/if_tap: t_tap.sh
src/tests/net/if_tun: t_tun.sh
src/tests/net/mcast: t_mcast.sh
src/tests/net/ndp: t_dad.sh t_ndp.sh t_ra.sh
src/tests/net/net: t_forwarding.sh t_ipaddress.sh t_ipv6_lifetime.sh
t_ipv6address.sh t_mtudisc.sh t_ping6_opts.sh
src/tests/net/route: t_change.sh t_flags.sh t_flags6.sh t_route.sh

Log Message:
Accept DEBUG environment variable

By doing so, we can easily turn DEBUG on/off without modifying
the ATF scripts.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/net/arp/t_arp.sh
cvs rdiff -u -r1.8 -r1.9 src/tests/net/arp/t_dad.sh
cvs rdiff -u -r1.4 -r1.5 src/tests/net/icmp/t_icmp6_redirect.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/net/icmp/t_icmp_redirect.sh
cvs rdiff -u -r1.9 -r1.10 src/tests/net/if_pppoe/t_pppoe.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/net/if_tap/t_tap.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/net/if_tun/t_tun.sh
cvs rdiff -u -r1.2 -r1.3 src/tests/net/mcast/t_mcast.sh
cvs rdiff -u -r1.8 -r1.9 src/tests/net/ndp/t_dad.sh
cvs rdiff -u -r1.13 -r1.14 src/tests/net/ndp/t_ndp.sh
cvs rdiff -u -r1.4 -r1.5 src/tests/net/ndp/t_ra.sh
cvs rdiff -u -r1.15 -r1.16 src/tests/net/net/t_forwarding.sh
cvs rdiff -u -r1.4 -r1.5 src/tests/net/net/t_ipaddress.sh \
src/tests/net/net/t_ipv6_lifetime.sh
cvs rdiff -u -r1.9 -r1.10 src/tests/net/net/t_ipv6address.sh
cvs rdiff -u -r1.2 -r1.3 src/tests/net/net/t_mtudisc.sh \
src/tests/net/net/t_ping6_opts.sh
cvs rdiff -u -r1.8 -r1.9 src/tests/net/route/t_change.sh \
src/tests/net/route/t_flags6.sh
cvs rdiff -u -r1.11 -r1.12 src/tests/net/route/t_flags.sh
cvs rdiff -u -r1.7 -r1.8 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.17 src/tests/net/arp/t_arp.sh:1.18
--- src/tests/net/arp/t_arp.sh:1.17	Tue Aug 23 16:03:45 2016
+++ src/tests/net/arp/t_arp.sh	Mon Nov  7 05:25:36 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_arp.sh,v 1.17 2016/08/23 16:03:45 christos Exp $
+#	$NetBSD: t_arp.sh,v 1.18 2016/11/07 05:25:36 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,7 +36,7 @@ IP4DST=10.0.1.2
 IP4DST_PROXYARP1=10.0.1.3
 IP4DST_PROXYARP2=10.0.1.4
 
-DEBUG=false
+DEBUG=${DEBUG:-false}
 TIMEOUT=1
 
 atf_test_case arp_cache_expiration_5s cleanup

Index: src/tests/net/arp/t_dad.sh
diff -u src/tests/net/arp/t_dad.sh:1.8 src/tests/net/arp/t_dad.sh:1.9
--- src/tests/net/arp/t_dad.sh:1.8	Wed Sep 14 16:00:10 2016
+++ src/tests/net/arp/t_dad.sh	Mon Nov  7 05:25:36 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_dad.sh,v 1.8 2016/09/14 16:00:10 christos Exp $
+#	$NetBSD: t_dad.sh,v 1.9 2016/11/07 05:25:36 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -32,7 +32,7 @@ HIJACKING="env LD_PRELOAD=/usr/lib/libru
 SOCKLOCAL=unix://commsock1
 SOCKPEER=unix://commsock2
 
-DEBUG=false
+DEBUG=${DEBUG:-false}
 
 atf_test_case dad_basic cleanup
 atf_test_case dad_duplicated cleanup

Index: src/tests/net/icmp/t_icmp6_redirect.sh
diff -u src/tests/net/icmp/t_icmp6_redirect.sh:1.4 src/tests/net/icmp/t_icmp6_redirect.sh:1.5
--- src/tests/net/icmp/t_icmp6_redirect.sh:1.4	Thu Oct 20 09:51:15 2016
+++ src/tests/net/icmp/t_icmp6_redirect.sh	Mon Nov  7 05:25:36 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_icmp6_redirect.sh,v 1.4 2016/10/20 09:51:15 ozaki-r Exp $
+#	$NetBSD: t_icmp6_redirect.sh,v 1.5 2016/11/07 05:25:36 ozaki-r Exp $
 #
 # Copyright (c) 2015 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -44,7 +44,7 @@ IP6IF0_GW2=fc00:1::3
 
 REDIRECT_TIMEOUT=5
 
-DEBUG=true
+DEBUG=${DEBUG:-true}
 
 get_lladdr()
 {

Index: src/tests/net/icmp/t_icmp_redirect.sh
diff -u src/tests/net/icmp/t_icmp_redirect.sh:1.3 src/tests/net/icmp/t_icmp_redirect.sh:1.4
--- src/tests/net/icmp/t_icmp_redirect.sh:1.3	Wed Aug 10 22:17:44 2016
+++ src/tests/net/icmp/t_icmp_redirect.sh	Mon Nov  7 05:25:36 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_icmp_redirect.sh,v 1.3 2016/08/10 22:17:44 kre Exp $
+#	$NetBSD: t_icmp_redirect.sh,v 1.4 2016/11/07 05:25:36 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,7 +36,7 @@ BUS=bus1
 BUS2=bus2
 REDIRECT_TIMEOUT=5
 
-DEBUG=false
+DEBUG=${DEBUG:-false}
 
 atf_test_case icmp_redirect_timeout cleanup
 

Index: src/tests/net/if_pppoe/t_pppoe.sh
diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.9 src/tests/net/if_pppoe/t_pppoe.sh:1.10
--- src/tests/net/if_pppoe/t_pppoe.sh:1.9	Thu Oct 27 09:59:17 2016
+++ src/tests/net/if_pppoe/t_pppoe.sh	Mon Nov  7 05:25:36 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_pppoe.sh,v 1.9 2016/10/27 09:59:17 knakahara Exp $

CVS commit: src/tests/net/net

2016-11-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov  7 04:43:14 UTC 2016

Modified Files:
src/tests/net/net: t_ping6_opts.sh

Log Message:
Add tests of ping6 hops optional argument (Type 0 Routing Headers)

Note that ping6 with the argument can send packets with routing headers
but the kernel doesn't support receiving the packets so that ping6 fails.
Nevertheless, we can test whether sent packets are correct or not.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/net/net/t_ping6_opts.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/net/t_ping6_opts.sh
diff -u src/tests/net/net/t_ping6_opts.sh:1.1 src/tests/net/net/t_ping6_opts.sh:1.2
--- src/tests/net/net/t_ping6_opts.sh:1.1	Mon Oct 31 10:38:25 2016
+++ src/tests/net/net/t_ping6_opts.sh	Mon Nov  7 04:43:14 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ping6_opts.sh,v 1.1 2016/10/31 10:38:25 ozaki-r Exp $
+#	$NetBSD: t_ping6_opts.sh,v 1.2 2016/11/07 04:43:14 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -160,6 +160,20 @@ check_echo_request_pkt_with_macaddr()
 	atf_check -s exit:0 -o match:"$pkt" cat ./out
 }
 
+check_echo_request_pkt_with_macaddr_and_rthdr0()
+{
+	local pkt=
+
+	pkt="$1 > $2, .+ $3 > $4:"
+	pkt="$pkt srcrt \\(len=2, type=0, segleft=1, \\[0\\]$5\\)"
+	pkt="$pkt .+ echo request"
+
+	extract_new_packets $BUS_SRCGW > ./out
+	$DEBUG && echo $pkt
+	$DEBUG && cat ./out
+	atf_check -s exit:0 -o match:"$pkt" cat ./out
+}
+
 dump()
 {
 
@@ -333,10 +347,71 @@ ping6_opts_gateway_cleanup()
 	cleanup
 }
 
+atf_test_case ping6_opts_hops cleanup
+ping6_opts_hops_head()
+{
+
+	atf_set "descr" "tests of ping6 hops (Type 0 Routing Header)"
+	atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_hops_body()
+{
+	local my_macaddr=
+	local gw_shmif0_macaddr=
+	local gw_shmif2_macaddr=
+
+	setup6
+	setup_forwarding6
+
+	my_macaddr=$(get_macaddr ${SOCKSRC} shmif0)
+	gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0)
+
+	export RUMP_SERVER=$SOCKSRC
+	atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+	check_echo_request_pkt_with_macaddr \
+	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+	export RUMP_SERVER=$SOCKFWD
+	atf_check -s exit:0 rump.ifconfig shmif2 create
+	atf_check -s exit:0 rump.ifconfig shmif2 linkstr $BUS_SRCGW
+	atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2
+	atf_check -s exit:0 rump.ifconfig -w 10
+	gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2)
+
+	export RUMP_SERVER=$SOCKSRC
+	atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+	check_echo_request_pkt_with_macaddr \
+	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+	# ping6 hops
+
+	# ping6 fails expectedly because the kernel doesn't support
+	# to receive packets with type 0 routing headers, but we can
+	# check whether a sent packet is correct.
+	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+	$IP6SRCGW $IP6DST
+	check_echo_request_pkt_with_macaddr_and_rthdr0 \
+	$my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
+
+	atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+	$IP6SRCGW2 $IP6DST
+	check_echo_request_pkt_with_macaddr_and_rthdr0 \
+	$my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+}
+
+ping6_opts_hops_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
 atf_init_test_cases()
 {
 
 	atf_add_test_case ping6_opts_sourceaddr
 	atf_add_test_case ping6_opts_interface
 	atf_add_test_case ping6_opts_gateway
+	atf_add_test_case ping6_opts_hops
 }



CVS commit: src/share/man/man3

2016-11-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Nov  7 03:12:54 UTC 2016

Modified Files:
src/share/man/man3: bits.3

Log Message:
These have been able to handle uintmax-width masks since creation.

XXX pullup-6
XXX pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/share/man/man3/bits.3

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/man3/bits.3
diff -u src/share/man/man3/bits.3:1.16 src/share/man/man3/bits.3:1.17
--- src/share/man/man3/bits.3:1.16	Tue Mar 18 18:20:39 2014
+++ src/share/man/man3/bits.3	Mon Nov  7 03:12:54 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bits.3,v 1.16 2014/03/18 18:20:39 riastradh Exp $
+.\"	$NetBSD: bits.3,v 1.17 2016/11/07 03:12:54 riastradh Exp $
 .\"
 .\" Copyright (c) 2006, 2010 David Young.  All rights reserved.
 .\"
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 17, 2012
+.Dd November 6, 2016
 .Dt BITS 3
 .Os
 .Sh NAME
@@ -146,8 +146,3 @@ contributed the macro names
 .Fn SHIFTIN
 and
 .Fn SHIFTOUT .
-.Sh BUGS
-.Fn __BIT
-and
-.Fn __BITS
-can only express 32-bit bitmasks.



CVS commit: src/tests/net/if

2016-11-06 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Nov  7 02:59:29 UTC 2016

Modified Files:
src/tests/net/if: t_compat.c

Log Message:
Mark this test as "expected failure" since rump doesn't include the
COMPAT_43 code.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/net/if/t_compat.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/net/if/t_compat.c
diff -u src/tests/net/if/t_compat.c:1.1 src/tests/net/if/t_compat.c:1.2
--- src/tests/net/if/t_compat.c:1.1	Sun Nov  7 19:53:42 2010
+++ src/tests/net/if/t_compat.c	Mon Nov  7 02:59:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_compat.c,v 1.1 2010/11/07 19:53:42 pooka Exp $	*/
+/*	$NetBSD: t_compat.c,v 1.2 2016/11/07 02:59:29 pgoyette Exp $	*/
 
 #include 
 #include 
@@ -65,6 +65,8 @@ ATF_TC_BODY(OOSIOCGIFBRDADDR, tc)
 	sprintf(ifreq.ifr_name, "shmif%d", ifnum);
 	netcfg_rump_if(ifreq.ifr_name, "1.7.64.10", "255.255.0.0");
 
+	atf_tc_expect_fail("rump does not include COMPAT_43");
+
 	/* query kernel for iface bcast */
 RL(fd = rump_sys_socket(AF_INET, SOCK_DGRAM, 0));
 RL(rump_sys_ioctl(fd, OOSIOCGIFBRDADDR, ));



CVS commit: src/tests/lib/libc/sys

2016-11-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Nov  7 02:23:43 UTC 2016

Modified Files:
src/tests/lib/libc/sys: t_wait_noproc.c

Log Message:
Enable the wait3 test in t_wait_noproc_wnohang (through t_wait_noproc)

This test has set expected failure like other functions in the wait(2)
family and is linked with PR standards/51606.

The PR is labeled as:
wait4() (and friends) with WNOHANG and no children does not error

Originally, this test was accidently disabled in the WNOHANG checks. This
was noted by Robert Elz.

Sponsored by .


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_wait_noproc.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/lib/libc/sys/t_wait_noproc.c
diff -u src/tests/lib/libc/sys/t_wait_noproc.c:1.1 src/tests/lib/libc/sys/t_wait_noproc.c:1.2
--- src/tests/lib/libc/sys/t_wait_noproc.c:1.1	Sun Nov  6 15:03:30 2016
+++ src/tests/lib/libc/sys/t_wait_noproc.c	Mon Nov  7 02:23:43 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wait_noproc.c,v 1.1 2016/11/06 15:03:30 kamil Exp $ */
+/* $NetBSD: t_wait_noproc.c,v 1.2 2016/11/07 02:23:43 kamil Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_wait_noproc.c,v 1.1 2016/11/06 15:03:30 kamil Exp $");
+__RCSID("$NetBSD: t_wait_noproc.c,v 1.2 2016/11/07 02:23:43 kamil Exp $");
 
 #include 
 #include 
@@ -94,7 +94,6 @@ ATF_TC_BODY(waitid, tc)
 	ATF_REQUIRE(errno == ECHILD);
 }
 
-#if TWAIT_OPTION == 0
 ATF_TC(wait3);
 ATF_TC_HEAD(wait3, tc)
 {
@@ -104,11 +103,14 @@ ATF_TC_HEAD(wait3, tc)
 
 ATF_TC_BODY(wait3, tc)
 {
+#if TWAIT_OPTION
+	/* wait4() (and friends) with WNOHANG and no children does not error */
+	atf_tc_expect_fail("PR standards/51606");
+#endif
 	errno = 0;
-	ATF_REQUIRE(wait3(NULL, 0, NULL) == -1);
+	ATF_REQUIRE(wait3(NULL, TWAIT_OPTION, NULL) == -1);
 	ATF_REQUIRE(errno == ECHILD);
 }
-#endif
 
 ATF_TC(wait4);
 ATF_TC_HEAD(wait4, tc)
@@ -156,9 +158,7 @@ ATF_TP_ADD_TCS(tp)
 #endif
 	ATF_TP_ADD_TC(tp, waitpid);
 	ATF_TP_ADD_TC(tp, waitid);
-#if TWAIT_OPTION == 0
 	ATF_TP_ADD_TC(tp, wait3);
-#endif
 	ATF_TP_ADD_TC(tp, wait4);
 	ATF_TP_ADD_TC(tp, wait6);
 



CVS commit: src/sys/netinet6

2016-11-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov  7 01:55:17 UTC 2016

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

Log Message:
Pull routing header handling out of ip6_output

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 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/netinet6/ip6_output.c
diff -u src/sys/netinet6/ip6_output.c:1.176 src/sys/netinet6/ip6_output.c:1.177
--- src/sys/netinet6/ip6_output.c:1.176	Mon Nov  7 01:05:39 2016
+++ src/sys/netinet6/ip6_output.c	Mon Nov  7 01:55:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_output.c,v 1.176 2016/11/07 01:05:39 ozaki-r Exp $	*/
+/*	$NetBSD: ip6_output.c,v 1.177 2016/11/07 01:55:17 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.176 2016/11/07 01:05:39 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.177 2016/11/07 01:55:17 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -136,11 +136,50 @@ static int ip6_splithdr(struct mbuf *, s
 static int ip6_getpmtu(struct rtentry *, struct ifnet *, u_long *, int *);
 static int copypktopts(struct ip6_pktopts *, struct ip6_pktopts *, int);
 static int ip6_ifaddrvalid(const struct in6_addr *);
+static int ip6_handle_rthdr(struct ip6_rthdr *, struct ip6_hdr *);
 
 #ifdef RFC2292
 static int ip6_pcbopts(struct ip6_pktopts **, struct socket *, struct sockopt *);
 #endif
 
+static int
+ip6_handle_rthdr(struct ip6_rthdr *rh, struct ip6_hdr *ip6)
+{
+	struct ip6_rthdr0 *rh0;
+	struct in6_addr *addr;
+	struct sockaddr_in6 sa;
+	int error = 0;
+
+	switch (rh->ip6r_type) {
+	case IPV6_RTHDR_TYPE_0:
+		 rh0 = (struct ip6_rthdr0 *)rh;
+		 addr = (struct in6_addr *)(rh0 + 1);
+
+		 /*
+		  * construct a sockaddr_in6 form of the first hop.
+		  *
+		  * XXX we may not have enough information about its scope zone;
+		  * there is no standard API to pass the information from the
+		  * application.
+		  */
+		 sockaddr_in6_init(, addr, 0, 0, 0);
+		 error = sa6_embedscope(, ip6_use_defzone);
+		 if (error != 0)
+			 break;
+		 (void)memmove([0], [1],
+		 sizeof(struct in6_addr) * (rh0->ip6r0_segleft - 1));
+		 addr[rh0->ip6r0_segleft - 1] = ip6->ip6_dst;
+		 ip6->ip6_dst = sa.sin6_addr;
+		 /* XXX */
+		 in6_clearscope(addr + rh0->ip6r0_segleft - 1);
+		 break;
+	default:	/* is it possible? */
+		 error = EINVAL;
+	}
+
+	return error;
+}
+
 /*
  * IP6 output. The packet in mbuf chain m contains a skeletal IP6
  * header (with pri, len, nxt, hlim, src, dst).
@@ -375,45 +414,14 @@ ip6_output(
 	 */
 	if (exthdrs.ip6e_rthdr) {
 		struct ip6_rthdr *rh;
-		struct ip6_rthdr0 *rh0;
-		struct in6_addr *addr;
-		struct sockaddr_in6 sa;
 
 		rh = (struct ip6_rthdr *)(mtod(exthdrs.ip6e_rthdr,
 		struct ip6_rthdr *));
-		finaldst = ip6->ip6_dst;
-		switch (rh->ip6r_type) {
-		case IPV6_RTHDR_TYPE_0:
-			 rh0 = (struct ip6_rthdr0 *)rh;
-			 addr = (struct in6_addr *)(rh0 + 1);
+		finaldst = ip6->ip6_dst; /* need to save for pmtu */
 
-			 /*
-			  * construct a sockaddr_in6 form of
-			  * the first hop.
-			  *
-			  * XXX: we may not have enough
-			  * information about its scope zone;
-			  * there is no standard API to pass
-			  * the information from the
-			  * application.
-			  */
-			 sockaddr_in6_init(, addr, 0, 0, 0);
-			 if ((error = sa6_embedscope(,
-			 ip6_use_defzone)) != 0) {
- goto bad;
-			 }
-			 ip6->ip6_dst = sa.sin6_addr;
-			 (void)memmove([0], [1],
-			 sizeof(struct in6_addr) *
-			 (rh0->ip6r0_segleft - 1));
-			 addr[rh0->ip6r0_segleft - 1] = finaldst;
-			 /* XXX */
-			 in6_clearscope(addr + rh0->ip6r0_segleft - 1);
-			 break;
-		default:	/* is it possible? */
-			 error = EINVAL;
-			 goto bad;
-		}
+		error = ip6_handle_rthdr(rh, ip6);
+		if (error != 0)
+			goto bad;
 	}
 
 	/* Source address validation */



CVS commit: src/sys/netinet6

2016-11-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov  7 01:05:39 UTC 2016

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

Log Message:
Tidy up ip6_getpmtu

Pull rtcache thing out of ip6_getpmtu; that isn't an essential
of the function. Add comments inspired by FreeBSD.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.175 -r1.176 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/netinet6/ip6_output.c
diff -u src/sys/netinet6/ip6_output.c:1.175 src/sys/netinet6/ip6_output.c:1.176
--- src/sys/netinet6/ip6_output.c:1.175	Tue Sep 20 14:30:13 2016
+++ src/sys/netinet6/ip6_output.c	Mon Nov  7 01:05:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_output.c,v 1.175 2016/09/20 14:30:13 roy Exp $	*/
+/*	$NetBSD: ip6_output.c,v 1.176 2016/11/07 01:05:39 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.175 2016/09/20 14:30:13 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.176 2016/11/07 01:05:39 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -133,8 +133,7 @@ static int ip6_insertfraghdr(struct mbuf
 	struct ip6_frag **);
 static int ip6_insert_jumboopt(struct ip6_exthdrs *, u_int32_t);
 static int ip6_splithdr(struct mbuf *, struct ip6_exthdrs *);
-static int ip6_getpmtu(struct route *, struct route *, struct ifnet *,
-const struct in6_addr *, u_long *, int *);
+static int ip6_getpmtu(struct rtentry *, struct ifnet *, u_long *, int *);
 static int copypktopts(struct ip6_pktopts *, struct ip6_pktopts *, int);
 static int ip6_ifaddrvalid(const struct in6_addr *);
 
@@ -170,7 +169,7 @@ ip6_output(
 	int hlen, tlen, len, off;
 	bool tso;
 	struct route ip6route;
-	struct rtentry *rt = NULL;
+	struct rtentry *rt = NULL, *rt_pmtu;
 	const struct sockaddr_in6 *dst;
 	struct sockaddr_in6 src_sa, dst_sa;
 	int error = 0;
@@ -661,8 +660,24 @@ ip6_output(
 		*ifpp = ifp;
 
 	/* Determine path MTU. */
-	if ((error = ip6_getpmtu(ro_pmtu, ro, ifp, , ,
-	)) != 0)
+	/*
+	 * ro_pmtu represent final destination while
+	 * ro might represent immediate destination.
+	 * Use ro_pmtu destination since MTU might differ.
+	 */
+	if (ro_pmtu != ro) {
+		union {
+			struct sockaddr		dst;
+			struct sockaddr_in6	dst6;
+		} u;
+
+		/* ro_pmtu may not have a cache */
+		sockaddr_in6_init(, , 0, 0, 0);
+		rt_pmtu = rtcache_lookup(ro_pmtu, );
+	} else
+		rt_pmtu = rtcache_validate(ro_pmtu);
+	error = ip6_getpmtu(rt_pmtu, ifp, , );
+	if (error != 0)
 		goto bad;
 
 	/*
@@ -1232,25 +1247,13 @@ ip6_insertfraghdr(struct mbuf *m0, struc
 }
 
 static int
-ip6_getpmtu(struct route *ro_pmtu, struct route *ro, struct ifnet *ifp,
-const struct in6_addr *dst, u_long *mtup, int *alwaysfragp)
+ip6_getpmtu(struct rtentry *rt, struct ifnet *ifp, u_long *mtup,
+int *alwaysfragp)
 {
-	struct rtentry *rt;
 	u_int32_t mtu = 0;
 	int alwaysfrag = 0;
 	int error = 0;
 
-	if (ro_pmtu != ro) {
-		union {
-			struct sockaddr		dst;
-			struct sockaddr_in6	dst6;
-		} u;
-
-		/* The first hop and the final destination may differ. */
-		sockaddr_in6_init(, dst, 0, 0, 0);
-		rt = rtcache_lookup(ro_pmtu, );
-	} else
-		rt = rtcache_validate(ro_pmtu);
 	if (rt != NULL) {
 		u_int32_t ifmtu;
 
@@ -1830,6 +1833,11 @@ else 	\
 			u_long pmtu = 0;
 			struct ip6_mtuinfo mtuinfo;
 			struct route *ro = >in6p_route;
+			struct rtentry *rt;
+			union {
+struct sockaddr		dst;
+struct sockaddr_in6	dst6;
+			} u;
 
 			if (!(so->so_state & SS_ISCONNECTED))
 return (ENOTCONN);
@@ -1838,8 +1846,9 @@ else 	\
 			 * routing, or optional information to specify
 			 * the outgoing interface.
 			 */
-			error = ip6_getpmtu(ro, NULL, NULL,
-			>in6p_faddr, , NULL);
+			sockaddr_in6_init(, >in6p_faddr, 0, 0, 0);
+			rt = rtcache_lookup(ro, );
+			error = ip6_getpmtu(rt, NULL, , NULL);
 			if (error)
 break;
 			if (pmtu > IPV6_MAXPACKET)



CVS commit: src

2016-11-06 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Nov  7 00:54:48 UTC 2016

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/net/net: Makefile
Added Files:
src/tests/net/net: t_mtudisc6.sh

Log Message:
Add basic tests for IPv6 Path MTU Discovery


To generate a diff of this commit:
cvs rdiff -u -r1.694 -r1.695 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.17 -r1.18 src/tests/net/net/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/net/net/t_mtudisc6.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.694 src/distrib/sets/lists/tests/mi:1.695
--- src/distrib/sets/lists/tests/mi:1.694	Sun Nov  6 17:09:19 2016
+++ src/distrib/sets/lists/tests/mi	Mon Nov  7 00:54:48 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.694 2016/11/06 17:09:19 alnsn Exp $
+# $NetBSD: mi,v 1.695 2016/11/07 00:54:48 ozaki-r Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3249,6 +3249,7 @@
 ./usr/tests/net/net/t_ipv6address		tests-net-tests		atf,rump
 ./usr/tests/net/net/t_ipv6_lifetime		tests-net-tests		atf,rump
 ./usr/tests/net/net/t_mtudisc			tests-net-tests		atf,rump
+./usr/tests/net/net/t_mtudisc6			tests-net-tests		atf,rump
 ./usr/tests/net/net/t_ping6_opts		tests-net-tests		atf,rump
 ./usr/tests/net/net/t_pktinfo			tests-net-tests		compattestfile,atf
 ./usr/tests/net/net/t_raw			tests-net-tests		atf,rump

Index: src/tests/net/net/Makefile
diff -u src/tests/net/net/Makefile:1.17 src/tests/net/net/Makefile:1.18
--- src/tests/net/net/Makefile:1.17	Mon Oct 31 10:38:25 2016
+++ src/tests/net/net/Makefile	Mon Nov  7 00:54:48 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2016/10/31 10:38:25 ozaki-r Exp $
+# $NetBSD: Makefile,v 1.18 2016/11/07 00:54:48 ozaki-r Exp $
 #
 
 .include 
@@ -16,6 +16,7 @@ TESTS_SH+=	t_ipaddress
 TESTS_SH+=	t_ipv6address
 TESTS_SH+=	t_ipv6_lifetime
 TESTS_SH+=	t_mtudisc
+TESTS_SH+=	t_mtudisc6
 TESTS_SH+=	t_ping6_opts
 .endif
 

Added files:

Index: src/tests/net/net/t_mtudisc6.sh
diff -u /dev/null src/tests/net/net/t_mtudisc6.sh:1.1
--- /dev/null	Mon Nov  7 00:54:48 2016
+++ src/tests/net/net/t_mtudisc6.sh	Mon Nov  7 00:54:48 2016
@@ -0,0 +1,232 @@
+#	$NetBSD: t_mtudisc6.sh,v 1.1 2016/11/07 00:54:48 ozaki-r Exp $
+#
+# Copyright (c) 2016 Internet Initiative Japan 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 conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet"
+inetserver="$inetserver -lrumpnet_netinet6 -lrumpnet_shmif"
+inetserver="$inetserver -lrumpdev"
+HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
+
+SOCKLOCAL=unix://commsock1
+SOCKGATEWAY=unix://commsock2
+SOCKREMOTE=unix://commsock3
+HTTPD_PID=httpd.pid
+HTML_FILE=index.html
+
+DEBUG=${DEBUG:-false}
+
+atf_test_case mtudisc6_basic cleanup
+
+mtudisc6_basic_head()
+{
+
+	atf_set "descr" "Tests for IPv6 Path MTU Dicorvery basic behavior"
+	atf_set "require.progs" "rump_server"
+}
+
+setup_server()
+{
+	local sock=$1
+	local if=$2
+	local bus=$3
+	local ip=$4
+
+	export RUMP_SERVER=$sock
+
+	atf_check -s exit:0 rump.ifconfig $if create
+	atf_check -s exit:0 rump.ifconfig $if linkstr $bus
+	atf_check -s exit:0 rump.ifconfig $if inet6 $ip
+	atf_check -s exit:0 rump.ifconfig $if up
+	atf_check -s exit:0 rump.ifconfig -w 10
+
+	$DEBUG && rump.ifconfig $if
+}
+
+extract_new_packets()
+{
+	local bus=$1
+	local old=./old
+
+	if [ ! -f $old ]; then
+		old=/dev/null
+	fi
+
+	shmif_dumpbus -p - $bus 2>/dev/null| \
+	tcpdump -n -e -r - 2>/dev/null > ./new
+	diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > 

CVS commit: src/external/gpl3/binutils.old/dist/bfd

2016-11-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Nov  6 23:46:02 UTC 2016

Modified Files:
src/external/gpl3/binutils.old/dist/bfd: elf32-ppc.c elf64-ppc.c

Log Message:
Merge r1.10 from the main in-tree binutils version:
More detailed error messages for text relocations on ppc code. Tested by
joerg@


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c

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

Modified files:

Index: src/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c
diff -u src/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c:1.3 src/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c:1.4
--- src/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c:1.3	Wed Oct 26 17:08:38 2016
+++ src/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c	Sun Nov  6 23:46:01 2016
@@ -5483,7 +5483,7 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUT
 /* Return true if we have dynamic relocs that apply to read-only sections.  */
 
 static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h)
+readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf, bfd_boolean warn)
 {
   struct elf_dyn_relocs *p;
 
@@ -5494,7 +5494,16 @@ readonly_dynrelocs (struct elf_link_hash
   if (s != NULL
 	  && ((s->flags & (SEC_READONLY | SEC_ALLOC))
 	  == (SEC_READONLY | SEC_ALLOC)))
-	return TRUE;
+	{
+	  struct bfd_link_info *info = (struct bfd_link_info *) inf;
+
+	  if (warn && ((info->warn_shared_textrel && bfd_link_pic (info))
+	  || info->error_textrel))
+	info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"),
+p->sec->owner, h->root.root.string,
+p->sec);
+	  return TRUE;
+	}
 }
   return FALSE;
 }
@@ -5568,7 +5577,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf
 	  && h->type != STT_GNU_IFUNC
 	  && !htab->is_vxworks
 	  && !ppc_elf_hash_entry (h)->has_sda_refs
-	  && !readonly_dynrelocs (h))
+	  && !readonly_dynrelocs (h, info, FALSE))
 	{
 	  h->pointer_equality_needed = 0;
 	  h->non_got_ref = 0;
@@ -5588,7 +5597,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf
 		   && h->type != STT_GNU_IFUNC
 		   && !htab->is_vxworks
 		   && !ppc_elf_hash_entry (h)->has_sda_refs
-		   && !readonly_dynrelocs (h))
+		   && !readonly_dynrelocs (h, info, FALSE))
 	h->non_got_ref = 0;
 	}
   h->protected_def = 0;
@@ -5665,7 +5674,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf
   && !ppc_elf_hash_entry (h)->has_sda_refs
   && !htab->is_vxworks
   && !h->def_regular
-  && !readonly_dynrelocs (h))
+  && !readonly_dynrelocs (h, info, FALSE))
 {
   h->non_got_ref = 0;
   return TRUE;
@@ -6175,7 +6184,7 @@ maybe_set_textrel (struct elf_link_hash_
   if (h->root.type == bfd_link_hash_indirect)
 return TRUE;
 
-  if (readonly_dynrelocs (h))
+  if (readonly_dynrelocs (h, info, TRUE))
 {
   ((struct bfd_link_info *) info)->flags |= DF_TEXTREL;
 

Index: src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c
diff -u src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c:1.4 src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c:1.5
--- src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c:1.4	Sun Nov  6 23:44:44 2016
+++ src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c	Sun Nov  6 23:46:02 2016
@@ -7103,7 +7103,7 @@ ppc64_elf_func_desc_adjust (bfd *obfd AT
 /* Return true if we have dynamic relocs that apply to read-only sections.  */
 
 static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h)
+readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf, bfd_boolean warn)
 {
   struct ppc_link_hash_entry *eh;
   struct elf_dyn_relocs *p;
@@ -7114,7 +7114,16 @@ readonly_dynrelocs (struct elf_link_hash
   asection *s = p->sec->output_section;
 
   if (s != NULL && (s->flags & SEC_READONLY) != 0)
-	return TRUE;
+	{
+	  struct bfd_link_info *info = (struct bfd_link_info *) inf;
+
+	  if (warn && ((info->warn_shared_textrel && bfd_link_pic (info))
+	  || info->error_textrel))
+	info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"),
+p->sec->owner, h->root.root.string,
+p->sec);
+	  return TRUE;
+	}
 }
   return FALSE;
 }
@@ -7166,7 +7175,7 @@ ppc64_elf_adjust_dynamic_symbol (struct 
 	 be used instead.  */
 	  if (h->pointer_equality_needed
 	  && h->type != STT_GNU_IFUNC
-	  && !readonly_dynrelocs (h))
+	  && !readonly_dynrelocs (h, info, FALSE))
 	{
 	  h->pointer_equality_needed = 0;
 	  h->non_got_ref = 0;
@@ -7184,7 +7193,7 @@ ppc64_elf_adjust_dynamic_symbol (struct 
 	  else if (!h->ref_regular_nonweak
 		   && h->non_got_ref
 		   && h->type != STT_GNU_IFUNC
-		   && !readonly_dynrelocs (h))
+		   && !readonly_dynrelocs (h, info, FALSE))
 	h->non_got_ref = 0;
 
 	  /* If 

CVS commit: src/external/gpl3/binutils.old/dist/bfd

2016-11-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Nov  6 23:44:44 UTC 2016

Modified Files:
src/external/gpl3/binutils.old/dist/bfd: elf64-ppc.c

Log Message:
Merge r1.11 from the main in-tree binutils version:
Tail calls can use the PLT without a nop after the branch. Since the
callee won't return to the next instruction anyway, it wouldn't work
anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c

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

Modified files:

Index: src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c
diff -u src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c:1.3 src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c:1.4
--- src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c:1.3	Wed Oct 26 17:08:38 2016
+++ src/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c	Sun Nov  6 23:44:44 2016
@@ -14056,6 +14056,11 @@ ppc64_elf_relocate_section (bfd *output_
 			  can_plt_call = TRUE;
 			}
 		}
+		  else
+		{
+		  /* Tail calls don't need to worry about restoring TOC. */
+		  can_plt_call = TRUE;
+		}
 		}
 
 	  if (!can_plt_call && h != NULL)



CVS commit: src/sys/dev/pci

2016-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  6 21:51:31 UTC 2016

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

Log Message:
msk_init is too heavyweight and loses link. Provide a specialized way to
enter and exit promiscuous mode so that we don't lose seconds of traffic
each time we run tcpdump.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/pci/if_msk.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_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.51 src/sys/dev/pci/if_msk.c:1.52
--- src/sys/dev/pci/if_msk.c:1.51	Fri Jun 10 09:27:14 2016
+++ src/sys/dev/pci/if_msk.c	Sun Nov  6 16:51:31 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.51 2016/06/10 13:27:14 ozaki-r Exp $ */
+/* $NetBSD: if_msk.c,v 1.52 2016/11/06 21:51:31 christos Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.42 2007/01/17 02:43:02 krw Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.51 2016/06/10 13:27:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.52 2016/11/06 21:51:31 christos Exp $");
 
 #include 
 #include 
@@ -624,7 +624,7 @@ out:
 		}
 	}
 
-	return (error);
+	return error;
 }
 
 /*
@@ -688,29 +688,53 @@ msk_jfree(struct mbuf *m, void *buf, siz
 int
 msk_ioctl(struct ifnet *ifp, u_long cmd, void *data)
 {
-	struct sk_if_softc *sc_if = ifp->if_softc;
-	int s, error = 0;
+	struct sk_if_softc *sc = ifp->if_softc;
+	int s, error;
 
 	s = splnet();
 
 	DPRINTFN(2, ("msk_ioctl ETHER\n"));
-	error = ether_ioctl(ifp, cmd, data);
+	switch (cmd) {
+	case SIOCSIFFLAGS:
+		if ((error = ifioctl_common(ifp, cmd, data)) != 0)
+			break;
 
-	if (error == ENETRESET) {
-		error = 0;
-		if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI)
-			;
-		else if (ifp->if_flags & IFF_RUNNING) {
-			/*
-			 * Multicast list has changed; set the hardware
-			 * filter accordingly.
-			 */
-			msk_setmulti(sc_if);
+		switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
+		case IFF_RUNNING:
+			msk_stop(ifp, 1);
+			break;
+		case IFF_UP:
+			msk_init(ifp);
+			break;
+		case IFF_UP | IFF_RUNNING:
+			if ((ifp->if_flags ^ sc->sk_if_flags) == IFF_PROMISC) {
+msk_setpromisc(sc);
+msk_setmulti(sc);
+			} else
+msk_init(ifp);
+			break;
 		}
+		sc->sk_if_flags = ifp->if_flags;
+		break;
+	default:
+		error = ether_ioctl(ifp, cmd, data);
+		if (error == ENETRESET) {
+			error = 0;
+			if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI)
+;
+			else if (ifp->if_flags & IFF_RUNNING) {
+/*
+ * Multicast list has changed; set the hardware
+ * filter accordingly.
+ */
+msk_setmulti(sc);
+			}
+		}
+		break;
 	}
 
 	splx(s);
-	return (error);
+	return error;
 }
 
 void



CVS commit: src/tests/kernel

2016-11-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Nov  6 21:47:53 UTC 2016

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

Log Message:
Run the attach_pid1 test (from t_ptrace) in unprivileged mode

Add in ATF_TC_HEAD() of attach_pid1 the following code to run it as
non-root: atf_tc_set_md_var(tc, "require.user", "unprivileged");

Solution pointed out by Nicolas Joly.

Sponsored by .


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/kernel/t_ptrace.c

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

Modified files:

Index: src/tests/kernel/t_ptrace.c
diff -u src/tests/kernel/t_ptrace.c:1.11 src/tests/kernel/t_ptrace.c:1.12
--- src/tests/kernel/t_ptrace.c:1.11	Sun Nov  6 16:24:16 2016
+++ src/tests/kernel/t_ptrace.c	Sun Nov  6 21:47:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace.c,v 1.11 2016/11/06 16:24:16 kamil Exp $	*/
+/*	$NetBSD: t_ptrace.c,v 1.12 2016/11/06 21:47:53 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace.c,v 1.11 2016/11/06 16:24:16 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace.c,v 1.12 2016/11/06 21:47:53 kamil Exp $");
 
 #include 
 #include 
@@ -641,13 +641,12 @@ ATF_TC_HEAD(attach_pid1, tc)
 {
 	atf_tc_set_md_var(tc, "descr",
 	"Assert that a debugger cannot attach to PID 1 (as non-root)");
+
+	atf_tc_set_md_var(tc, "require.user", "unprivileged");
 }
 
 ATF_TC_BODY(attach_pid1, tc)
 {
-	if (getuid() == 0)
-		atf_tc_skip("Test must be run as non-root");
-
 	errno = 0;
 	ATF_REQUIRE(ptrace(PT_ATTACH, 1, NULL, 0) == -1);
 	ATF_REQUIRE(errno == EPERM);



CVS commit: src/tests/dev/cgd

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 21:29:54 UTC 2016

Modified Files:
src/tests/dev/cgd: Makefile

Log Message:
Don't build t_cgd_aes if ${MKCRYPTO} == "no".


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/dev/cgd/Makefile

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

Modified files:

Index: src/tests/dev/cgd/Makefile
diff -u src/tests/dev/cgd/Makefile:1.3 src/tests/dev/cgd/Makefile:1.4
--- src/tests/dev/cgd/Makefile:1.3	Sun Nov  6 10:54:42 2016
+++ src/tests/dev/cgd/Makefile	Sun Nov  6 21:29:54 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2016/11/06 10:54:42 alnsn Exp $
+#	$NetBSD: Makefile,v 1.4 2016/11/06 21:29:54 alnsn Exp $
 #
 
 .include 
@@ -8,15 +8,17 @@ FILES=		paramsfile
 FILESDIR=	${TESTSDIR}
 
 TESTS_SH=	t_cgd
+
+.if ${MKCRYPTO} != "no"
 TESTS_C=	t_cgd_aes
 
+WARNS=	4
 CPPFLAGS+=	-D_KERNTYPES
 LDADD+=	-lrumpdev -lrumpdev_disk -lrumpdev_cgd -lrumpkern_crypto -lrumpvfs
 LDADD+=	-lrump
 LDADD+=	-lrumpuser
 LDADD+=	-lrump -lutil
 LDADD+=	-lpthread
-
-WARNS=	4
+.endif
 
 .include 



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

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 17:09:19 UTC 2016

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

Log Message:
Add "crypto" category to t_cgd_aes.


To generate a diff of this commit:
cvs rdiff -u -r1.693 -r1.694 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.693 src/distrib/sets/lists/tests/mi:1.694
--- src/distrib/sets/lists/tests/mi:1.693	Sun Nov  6 15:03:30 2016
+++ src/distrib/sets/lists/tests/mi	Sun Nov  6 17:09:19 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.693 2016/11/06 15:03:30 kamil Exp $
+# $NetBSD: mi,v 1.694 2016/11/06 17:09:19 alnsn Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1366,7 +1366,7 @@
 ./usr/tests/dev/cgd/h_img2cgd/h_img2cgd		tests-obsolete		obsolete
 ./usr/tests/dev/cgd/paramsfile			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/cgd/t_cgd			tests-fs-tests		compattestfile,atf
-./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		compattestfile,atf,rump
+./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		atf,compattestfile,crypto,rump
 ./usr/tests/dev/clock_subr			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Atffile		tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Kyuafile		tests-fs-tests		compattestfile,atf,kyua



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

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 17:07:50 UTC 2016

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

Log Message:
Debug file for t_cgd_aes.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/distrib/sets/lists/debug/mi

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.171 src/distrib/sets/lists/debug/mi:1.172
--- src/distrib/sets/lists/debug/mi:1.171	Sun Nov  6 15:03:30 2016
+++ src/distrib/sets/lists/debug/mi	Sun Nov  6 17:07:50 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.171 2016/11/06 15:03:30 kamil Exp $
+# $NetBSD: mi,v 1.172 2016/11/06 17:07:50 alnsn Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -1591,6 +1591,7 @@
 ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_xcbcmac.debug		tests-crypto-debug	debug,atf,crypto,compattestfile
 ./usr/libdata/debug/usr/tests/dev/audio/h_pad.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/cgd/h_img2cgd/h_img2cgd.debug			tests-obsolete	obsolete,compattestfile
+./usr/libdata/debug/usr/tests/dev/cgd/t_cgd_aes.debug			tests-fs-debug		atf,compattestfile,crypto,debug,rump
 ./usr/libdata/debug/usr/tests/dev/clock_subr/t_clock_subr.debug		tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/md/h_mdserv.debug	tests-fs-debug	debug,atf,rump
 ./usr/libdata/debug/usr/tests/dev/scsipi/t_cd.debug			tests-fs-debug		debug,atf,rump



CVS commit: src/tests/kernel

2016-11-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Nov  6 16:24:16 UTC 2016

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

Log Message:
Add new tests attach_pid0 and attach_pid1 to t_ptrace

attach_pid0 asserts that it is not valid to attach PID 0 as it is a special
kernel process.

assert_pid1 asserts that non-root user cannot attach to PID 1 as it is the
/dev/init process. This tests is skipped if run as root.

Sponsored by .


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/kernel/t_ptrace.c

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

Modified files:

Index: src/tests/kernel/t_ptrace.c
diff -u src/tests/kernel/t_ptrace.c:1.10 src/tests/kernel/t_ptrace.c:1.11
--- src/tests/kernel/t_ptrace.c:1.10	Sat Nov  5 15:52:35 2016
+++ src/tests/kernel/t_ptrace.c	Sun Nov  6 16:24:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace.c,v 1.10 2016/11/05 15:52:35 kamil Exp $	*/
+/*	$NetBSD: t_ptrace.c,v 1.11 2016/11/06 16:24:16 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace.c,v 1.10 2016/11/05 15:52:35 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace.c,v 1.11 2016/11/06 16:24:16 kamil Exp $");
 
 #include 
 #include 
@@ -622,6 +622,37 @@ ATF_TC_BODY(attach1, tc)
 	ATF_REQUIRE(close(fds_totracer[1]) == 0);
 }
 
+ATF_TC(attach_pid0);
+ATF_TC_HEAD(attach_pid0, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Assert that a debugger cannot attach to PID 0");
+}
+
+ATF_TC_BODY(attach_pid0, tc)
+{
+	errno = 0;
+	ATF_REQUIRE(ptrace(PT_ATTACH, 0, NULL, 0) == -1);
+	ATF_REQUIRE(errno == EPERM);
+}
+
+ATF_TC(attach_pid1);
+ATF_TC_HEAD(attach_pid1, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Assert that a debugger cannot attach to PID 1 (as non-root)");
+}
+
+ATF_TC_BODY(attach_pid1, tc)
+{
+	if (getuid() == 0)
+		atf_tc_skip("Test must be run as non-root");
+
+	errno = 0;
+	ATF_REQUIRE(ptrace(PT_ATTACH, 1, NULL, 0) == -1);
+	ATF_REQUIRE(errno == EPERM);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, traceme1);
@@ -629,6 +660,8 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, traceme3);
 	ATF_TP_ADD_TC(tp, traceme4);
 	ATF_TP_ADD_TC(tp, attach1);
+	ATF_TP_ADD_TC(tp, attach_pid0);
+	ATF_TP_ADD_TC(tp, attach_pid1);
 
 	return atf_no_error();
 }



CVS commit: src/tests/lib/libc/sys

2016-11-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Nov  6 15:04:14 UTC 2016

Modified Files:
src/tests/lib/libc/sys: Makefile t_wait.c

Log Message:
Add new tests: tests/lib/libc/sys/t_wait_noproc and t_wait_noproc_wnohang

The t_wait_noproc test checks whether wait(2)-family of functions return
error and set ECHILD for lack of childs.

The t_wait_noproc_wnohang adds to options (except wait(2), wait3(2)) new
parameter WNOHANG and verifies that error is still signaled and errno set
to ECHILD.

Currently t_wait_noproc_wnohang reports failures, these have been marked as
expected and referenced to PR standards/51606.

The problem report is authored by Robert Elz, and the initial regression
has been notified by Nicolas Joly.

Remove redundant test in tests/lib/libc/sys/t_wait for wait6(2) with no
WNOHANG specified.

Sponsored by .


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/t_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/lib/libc/sys/Makefile
diff -u src/tests/lib/libc/sys/Makefile:1.43 src/tests/lib/libc/sys/Makefile:1.44
--- src/tests/lib/libc/sys/Makefile:1.43	Sat Jul 30 11:03:54 2016
+++ src/tests/lib/libc/sys/Makefile	Sun Nov  6 15:04:14 2016
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.43 2016/07/30 11:03:54 njoly Exp $
+# $NetBSD: Makefile,v 1.44 2016/11/06 15:04:14 kamil Exp $
 
 MKMAN=	no
 
@@ -67,6 +67,8 @@ TESTS_C+=		t_ucontext
 TESTS_C+=		t_umask
 TESTS_C+=		t_unlink
 TESTS_C+=		t_wait
+TESTS_C+=		t_wait_noproc
+TESTS_C+=		t_wait_noproc_wnohang
 TESTS_C+=		t_write
 
 SRCS.t_mprotect=	t_mprotect.c ${SRCS_EXEC_PROT}

Index: src/tests/lib/libc/sys/t_wait.c
diff -u src/tests/lib/libc/sys/t_wait.c:1.6 src/tests/lib/libc/sys/t_wait.c:1.7
--- src/tests/lib/libc/sys/t_wait.c:1.6	Sun Nov  6 02:28:57 2016
+++ src/tests/lib/libc/sys/t_wait.c	Sun Nov  6 15:04:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wait.c,v 1.6 2016/11/06 02:28:57 kamil Exp $ */
+/* $NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_wait.c,v 1.6 2016/11/06 02:28:57 kamil Exp $");
+__RCSID("$NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $");
 
 #include 
 #include 
@@ -60,22 +60,6 @@ ATF_TC_BODY(wait6_invalid, tc)
 	&& errno == EINVAL);
 }
 
-ATF_TC(wait6_noproc);
-ATF_TC_HEAD(wait6_noproc, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	"Test that wait6(2) returns ECHILD with for no processes");
-}
-
-ATF_TC_BODY(wait6_noproc, tc)
-{
-	siginfo_t si;
-	struct wrusage wru;
-	int st;
-	ATF_REQUIRE(wait6(P_ALL, 0, , WEXITED, , ) == -1
-	&& errno == ECHILD);
-}
-
 ATF_TC(wait6_exited);
 ATF_TC_HEAD(wait6_exited, tc)
 {
@@ -311,7 +295,6 @@ ATF_TP_ADD_TCS(tp)
 {
 
 	ATF_TP_ADD_TC(tp, wait6_invalid);
-	ATF_TP_ADD_TC(tp, wait6_noproc);
 	ATF_TP_ADD_TC(tp, wait6_exited);
 	ATF_TP_ADD_TC(tp, wait6_terminated);
 	ATF_TP_ADD_TC(tp, wait6_coredumped);



CVS commit: src

2016-11-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Nov  6 15:03:31 UTC 2016

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
Added Files:
src/tests/lib/libc/sys: t_wait_noproc.c t_wait_noproc_wnohang.c

Log Message:
Add new tests: tests/lib/libc/sys/t_wait_noproc and t_wait_noproc_wnohang

The t_wait_noproc test checks whether wait(2)-family of functions return
error and set ECHILD for lack of childs.

The t_wait_noproc_wnohang adds to options (except wait(2), wait3(2)) new
parameter WNOHANG and verifies that error is still signaled and errno set
to ECHILD.

Currently t_wait_noproc_wnohang reports failures, these have been marked as
expected and referenced to PR standards/51606.

The problem report is authored by Robert Elz, and the initial regression
has been notified by Nicolas Joly.

Remove redundant test in tests/lib/libc/sys/t_wait for wait6(2) with no
WNOHANG specified.

Sponsored by .


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.692 -r1.693 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_wait_noproc.c \
src/tests/lib/libc/sys/t_wait_noproc_wnohang.c

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/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.170 src/distrib/sets/lists/debug/mi:1.171
--- src/distrib/sets/lists/debug/mi:1.170	Wed Nov  2 12:51:22 2016
+++ src/distrib/sets/lists/debug/mi	Sun Nov  6 15:03:30 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.170 2016/11/02 12:51:22 kamil Exp $
+# $NetBSD: mi,v 1.171 2016/11/06 15:03:30 kamil Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2063,6 +2063,8 @@
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_umask.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_unlink.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait.debug			tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait_noproc.debug		tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/sys/t_wait_noproc_wnohang.debug	tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/sys/t_write.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/t_cdb.debug			tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/t_cerror.debug			tests-obsolete		obsolete,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.692 src/distrib/sets/lists/tests/mi:1.693
--- src/distrib/sets/lists/tests/mi:1.692	Sun Nov  6 10:54:42 2016
+++ src/distrib/sets/lists/tests/mi	Sun Nov  6 15:03:30 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.692 2016/11/06 10:54:42 alnsn Exp $
+# $NetBSD: mi,v 1.693 2016/11/06 15:03:30 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2735,6 +2735,8 @@
 ./usr/tests/lib/libc/sys/t_umask		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_unlink		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_wait			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/sys/t_wait_noproc		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/sys/t_wait_noproc_wnohang	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/sys/t_write		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/t_atexit			tests-obsolete		obsolete
 ./usr/tests/lib/libc/t_cdb			tests-lib-tests		compattestfile,atf

Added files:

Index: src/tests/lib/libc/sys/t_wait_noproc.c
diff -u /dev/null src/tests/lib/libc/sys/t_wait_noproc.c:1.1
--- /dev/null	Sun Nov  6 15:03:31 2016
+++ src/tests/lib/libc/sys/t_wait_noproc.c	Sun Nov  6 15:03:30 2016
@@ -0,0 +1,166 @@
+/* $NetBSD: t_wait_noproc.c,v 1.1 2016/11/06 15:03:30 kamil 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 conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE 

CVS commit: [nick-nhusb] src/sys/dev/usb

2016-11-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov  6 11:50:54 UTC 2016

Modified Files:
src/sys/dev/usb [nick-nhusb]: ucom.c

Log Message:
Reduce the scope of the softc lock further and track device state via
sc_state.

All ucom methods apart from ucom_{read,write} are called without the
softc lock held.

ucom_close is called on last close only to match ucom_open being called
on first open only.

Fix ucom_detach where refcnt wasn't being decremented.

More DEBUG.

XXX still not sure where tty_lock needs to be held.


To generate a diff of this commit:
cvs rdiff -u -r1.108.2.30 -r1.108.2.31 src/sys/dev/usb/ucom.c

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

Modified files:

Index: src/sys/dev/usb/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.108.2.30 src/sys/dev/usb/ucom.c:1.108.2.31
--- src/sys/dev/usb/ucom.c:1.108.2.30	Sun Nov  6 09:36:53 2016
+++ src/sys/dev/usb/ucom.c	Sun Nov  6 11:50:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $	*/
+/*	$NetBSD: ucom.c,v 1.108.2.31 2016/11/06 11:50:54 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.31 2016/11/06 11:50:54 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.1
 #ifndef UCOM_DEBUG
 #define ucomdebug 0
 #else
-int ucomdebug = 0;
+int ucomdebug = 10;
 
 SYSCTL_SETUP(sysctl_hw_ucom_setup, "sysctl hw.ucom setup")
 {
@@ -181,8 +181,13 @@ struct ucom_softc {
 	u_char			sc_tx_stopped;
 	int			sc_swflags;
 
-	u_char			sc_opening;	/* lock during open */
-	u_char			sc_closing;	/* lock during close */
+	enum ucom_state {
+	UCOM_DEAD,
+	UCOM_ATTACHED,
+	UCOM_OPENING,
+	UCOM_CLOSING,
+	UCOM_OPEN
+	}			sc_state;
 	int			sc_refcnt;
 	bool			sc_dying;	/* disconnecting */
 
@@ -191,7 +196,7 @@ struct ucom_softc {
 	krndsource_t		sc_rndsource;	/* random source */
 
 	kmutex_t		sc_lock;
-	kcondvar_t		sc_opencv;
+	kcondvar_t		sc_statecv;
 	kcondvar_t		sc_detachcv;
 };
 
@@ -291,14 +296,13 @@ ucom_attach(device_t parent, device_t se
 	sc->sc_mcr = 0;
 	sc->sc_tx_stopped = 0;
 	sc->sc_swflags = 0;
-	sc->sc_opening = 0;
-	sc->sc_closing = 0;
 	sc->sc_refcnt = 0;
 	sc->sc_dying = false;
+	sc->sc_state = UCOM_DEAD;
 
 	sc->sc_si = softint_establish(SOFTINT_USB, ucom_softintr, sc);
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
-	cv_init(>sc_opencv, "ucomopen");
+	cv_init(>sc_statecv, "ucomstate");
 	cv_init(>sc_detachcv, "ucomdtch");
 
 	SIMPLEQ_INIT(>sc_ibuff_empty);
@@ -384,6 +388,9 @@ ucom_attach(device_t parent, device_t se
 
 	if (!pmf_device_register(self, NULL, NULL))
 		aprint_error_dev(self, "couldn't establish power handler\n");
+
+	sc->sc_state = UCOM_ATTACHED;
+
 	return;
 
 fail_2:
@@ -434,6 +441,18 @@ ucom_detach(device_t self, int flags)
 		usbd_abort_pipe(sc->sc_bulkout_pipe);
 
 	mutex_enter(>sc_lock);
+
+	/* wait for open/close to finish */
+	while (sc->sc_state == UCOM_OPENING || sc->sc_state == UCOM_CLOSING) {
+		int error = cv_wait_sig(>sc_statecv, >sc_lock);
+
+		if (error) {
+			mutex_exit(>sc_lock);
+			return error;
+		}
+	}
+
+	sc->sc_refcnt--;
 	while (sc->sc_refcnt > 0) {
 		/* Wake up anyone waiting */
 		if (tp != NULL) {
@@ -494,7 +513,7 @@ ucom_detach(device_t self, int flags)
 	rnd_detach_source(>sc_rndsource);
 
 	mutex_destroy(>sc_lock);
-	cv_destroy(>sc_opencv);
+	cv_destroy(>sc_statecv);
 	cv_destroy(>sc_detachcv);
 
 	return 0;
@@ -544,7 +563,7 @@ ucomopen(dev_t dev, int flag, int mode, 
 {
 	const int unit = UCOMUNIT(dev);
 	struct ucom_softc * const sc = device_lookup_private(_cd, unit);
-	int error;
+	int error = 0;
 
 	UCOMHIST_FUNC(); UCOMHIST_CALLED();
 
@@ -553,6 +572,7 @@ ucomopen(dev_t dev, int flag, int mode, 
 
 	mutex_enter(>sc_lock);
 	if (sc->sc_dying) {
+		DPRINTF("... dying", 0, 0, 0, 0);
 		mutex_exit(>sc_lock);
 		return EIO;
 	}
@@ -575,29 +595,36 @@ ucomopen(dev_t dev, int flag, int mode, 
 	 * Wait while the device is initialized by the
 	 * first opener or cleaned up by the last closer.
 	 */
-	while (sc->sc_opening || sc->sc_closing) {
-		error = cv_wait_sig(>sc_opencv, >sc_lock);
+	while (sc->sc_state == UCOM_OPENING || sc->sc_state == UCOM_CLOSING) {
+		error = cv_wait_sig(>sc_statecv, >sc_lock);
+
+		if (sc->sc_dying)
+			error = EIO;
 
 		if (error) {
 			mutex_exit(>sc_lock);
 			return error;
 		}
 	}
+	enum ucom_state state = sc->sc_state;
 
-	sc->sc_opening = 1;
+	KASSERTMSG(state == UCOM_OPEN || state == UCOM_ATTACHED,
+	"state is %d", state);
 
+	bool cleanup = false;
+	/* If this is the first open then perform the initialisation */
 	if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
+		KASSERT(state == UCOM_ATTACHED);
 		tp->t_dev = dev;
+		cleanup = true;
+		sc->sc_state = UCOM_OPENING;
 
+		

CVS commit: src

2016-11-06 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Sun Nov  6 10:54:42 UTC 2016

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/dev/cgd: Makefile
Added Files:
src/tests/dev/cgd: t_cgd_aes.c

Log Message:
Add tests for not-yet-committed cgd algorithm AES-XTS.

The tests are marked as expected failures.


To generate a diff of this commit:
cvs rdiff -u -r1.691 -r1.692 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.2 -r1.3 src/tests/dev/cgd/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/dev/cgd/t_cgd_aes.c

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.691 src/distrib/sets/lists/tests/mi:1.692
--- src/distrib/sets/lists/tests/mi:1.691	Wed Nov  2 12:51:22 2016
+++ src/distrib/sets/lists/tests/mi	Sun Nov  6 10:54:42 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.691 2016/11/02 12:51:22 kamil Exp $
+# $NetBSD: mi,v 1.692 2016/11/06 10:54:42 alnsn Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1366,6 +1366,7 @@
 ./usr/tests/dev/cgd/h_img2cgd/h_img2cgd		tests-obsolete		obsolete
 ./usr/tests/dev/cgd/paramsfile			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/cgd/t_cgd			tests-fs-tests		compattestfile,atf
+./usr/tests/dev/cgd/t_cgd_aes			tests-fs-tests		compattestfile,atf,rump
 ./usr/tests/dev/clock_subr			tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Atffile		tests-fs-tests		compattestfile,atf
 ./usr/tests/dev/clock_subr/Kyuafile		tests-fs-tests		compattestfile,atf,kyua

Index: src/tests/dev/cgd/Makefile
diff -u src/tests/dev/cgd/Makefile:1.2 src/tests/dev/cgd/Makefile:1.3
--- src/tests/dev/cgd/Makefile:1.2	Tue Dec 14 17:48:31 2010
+++ src/tests/dev/cgd/Makefile	Sun Nov  6 10:54:42 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2010/12/14 17:48:31 pooka Exp $
+#	$NetBSD: Makefile,v 1.3 2016/11/06 10:54:42 alnsn Exp $
 #
 
 .include 
@@ -8,5 +8,15 @@ FILES=		paramsfile
 FILESDIR=	${TESTSDIR}
 
 TESTS_SH=	t_cgd
+TESTS_C=	t_cgd_aes
+
+CPPFLAGS+=	-D_KERNTYPES
+LDADD+=	-lrumpdev -lrumpdev_disk -lrumpdev_cgd -lrumpkern_crypto -lrumpvfs
+LDADD+=	-lrump
+LDADD+=	-lrumpuser
+LDADD+=	-lrump -lutil
+LDADD+=	-lpthread
+
+WARNS=	4
 
 .include 

Added files:

Index: src/tests/dev/cgd/t_cgd_aes.c
diff -u /dev/null src/tests/dev/cgd/t_cgd_aes.c:1.1
--- /dev/null	Sun Nov  6 10:54:42 2016
+++ src/tests/dev/cgd/t_cgd_aes.c	Sun Nov  6 10:54:42 2016
@@ -0,0 +1,1452 @@
+/*	$NetBSD: t_cgd_aes.c,v 1.1 2016/11/06 10:54:42 alnsn Exp $	*/
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alexander Nasonov.
+ *
+ * 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 conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in
+ *the documentation and/or other materials provided with the
+ *distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include "../../h_macros.h"
+
+#define SECSIZE 512
+
+struct testvec {
+	unsigned int blkno;
+	const uint8_t *ptxt;	/* PlainText  */
+	const uint8_t *ctxt;	/* CipherText */
+};
+
+/*
+ * 256 bits key from IEEE 1619/D16, NUL terminated.
+ */
+static const char aes_xts_256_key[33] = {
+	0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
+	0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
+	0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
+	0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95,
+	0
+};
+
+/*
+ * 512 bits key from IEEE 1619/D16, NUL terminated.
+ */
+static const char aes_xts_512_key[65] = {
+	0x27, 0x18, 

CVS commit: [nick-nhusb] src/sys/dev/usb

2016-11-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov  6 09:36:53 UTC 2016

Modified Files:
src/sys/dev/usb [nick-nhusb]: ucom.c

Log Message:
Add #include "opt_usb.h"


To generate a diff of this commit:
cvs rdiff -u -r1.108.2.29 -r1.108.2.30 src/sys/dev/usb/ucom.c

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

Modified files:

Index: src/sys/dev/usb/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.108.2.29 src/sys/dev/usb/ucom.c:1.108.2.30
--- src/sys/dev/usb/ucom.c:1.108.2.29	Wed Nov  2 08:41:00 2016
+++ src/sys/dev/usb/ucom.c	Sun Nov  6 09:36:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.108.2.29 2016/11/02 08:41:00 skrll Exp $	*/
+/*	$NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.29 2016/11/02 08:41:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.108.2.30 2016/11/06 09:36:53 skrll Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_usb.h"
+#endif
 
 #include 
 #include 



CVS commit: src/share/man/man4

2016-11-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Nov  6 09:16:39 UTC 2016

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

Log Message:
Fix xref.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/inphy.4

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

Modified files:

Index: src/share/man/man4/inphy.4
diff -u src/share/man/man4/inphy.4:1.7 src/share/man/man4/inphy.4:1.8
--- src/share/man/man4/inphy.4:1.7	Sun Nov  6 02:27:34 2016
+++ src/share/man/man4/inphy.4	Sun Nov  6 09:16:38 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: inphy.4,v 1.7 2016/11/06 02:27:34 msaitoh Exp $
+.\"	$NetBSD: inphy.4,v 1.8 2016/11/06 09:16:38 wiz Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -51,5 +51,5 @@ device cannot detect link and link-speed
 .Xr ifmedia 4 ,
 .Xr intro 4 ,
 .Xr mii 4 ,
-.Xr wm 8 ,
+.Xr wm 4 ,
 .Xr ifconfig 8