CVS commit: src/tests/net/route

2022-09-19 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Sep 20 02:25:07 UTC 2022

Modified Files:
src/tests/net/route: t_route.sh

Log Message:
tests: add tests for automatic route deletions on an address removal


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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/route/t_route.sh
diff -u src/tests/net/route/t_route.sh:1.14 src/tests/net/route/t_route.sh:1.15
--- src/tests/net/route/t_route.sh:1.14	Mon Dec 18 04:11:46 2017
+++ src/tests/net/route/t_route.sh	Tue Sep 20 02:25:07 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: t_route.sh,v 1.14 2017/12/18 04:11:46 ozaki-r Exp $
+#	$NetBSD: t_route.sh,v 1.15 2022/09/20 02:25:07 knakahara Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -539,6 +539,156 @@ route_command_add6_cleanup()
 	cleanup
 }
 
+test_route_address_removal()
+{
+
+	rump_server_start $SOCKHOST netinet6
+
+	export RUMP_SERVER=${SOCKHOST}
+	rump_server_add_iface $SOCKHOST shmif0 $BUS
+
+	#
+	# 1. test auto removal of a route that depends a removing address
+	#
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr1/$prefix
+	atf_check -s exit:0 -o match:"add net $alt_net(/$prefix)?: gateway $addrgw" \
+	rump.route -n add -$af -net $alt_net/$prefix $addrgw
+	$DEBUG && rump.netstat -nr -f $af
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr1 delete
+	$DEBUG && rump.netstat -nr -f $af
+
+	# The route should be deleted on the address removal
+	atf_check -s not-exit:0 -e match:"writing to routing socket: not in table" \
+	rump.route -n get -$af $alt_addr
+
+	#
+	# 2. test auto update of a route that depends a removing address where
+	#there is another address with the same prefix sharing a connected
+	#route
+	#
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr1/$prefix
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr2/$prefix alias
+	atf_check -s exit:0 -o match:"add net $alt_net(/$prefix)?: gateway $addrgw" \
+	rump.route -n add -$af -net $alt_net/$prefix $addrgw
+	$DEBUG && rump.netstat -nr -f $af
+
+	atf_check -s exit:0 -o match:"local addr: $addr1" \
+	rump.route -n get -$af $addrgw
+	atf_check -s exit:0 -o match:"local addr: $addr1" \
+	rump.route -n get -$af $alt_addr
+
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr1 delete
+	$DEBUG && rump.netstat -nr -f $af
+
+	# local addr (rt_ifa) of the connected route should be changed
+	# on the address removal
+	atf_check -s exit:0 -o match:"local addr: $addr2" \
+	rump.route -n get -$af $addrgw
+	# local addr (rt_ifa) of the related route should be changed
+	# on the address removal too
+	atf_check -s exit:0 -o match:"local addr: $addr2" \
+	rump.route -n get -$af $alt_addr
+
+	# cleanup
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr2 delete
+
+	#
+	# 3. test auto update of a route that depends a removing address where
+	#there is another address with a different (short) prefix
+	#
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr1/$prefix
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr2/$prefix_short alias
+	atf_check -s exit:0 -o match:"add net $alt_net(/$prefix)?: gateway $addrgw" \
+	rump.route -n add -$af -net $alt_net/$prefix $addrgw
+	$DEBUG && rump.netstat -nr -f $af
+
+	atf_check -s exit:0 -o match:"local addr: $addr1" \
+	rump.route -n get -$af $addrgw
+	atf_check -s exit:0 -o match:"local addr: $addr1" \
+	rump.route -n get -$af $alt_addr
+
+	atf_check -s exit:0 rump.ifconfig shmif0 $af $addr1 delete
+	$DEBUG && rump.netstat -nr -f $af
+
+	# local addr (rt_ifa) of the connected route should be changed
+	# on the address removal
+	atf_check -s exit:0 -o match:"local addr: $addr2" \
+	rump.route -n get -$af $addrgw
+	if [ $af = inet ]; then
+		# local addr (rt_ifa) of the related route should be changed
+		# on the address removal too
+		atf_check -s exit:0 -o match:"local addr: $addr2" \
+		rump.route -n get -$af $alt_addr
+	else
+		# For IPv6, each address has its own connected route so the
+		# address removal just results in a removal of the related route
+		atf_check -s not-exit:0 \
+		-e match:"writing to routing socket: not in table" \
+		rump.route -n get -$af $alt_addr
+	fi
+
+	rump_server_destroy_ifaces
+}
+
+atf_test_case route_address_removal cleanup
+route_address_removal_head()
+{
+
+	atf_set "descr" "tests of auto removal/update of routes on address removal (IPv4)"
+	atf_set "require.progs" "rump_server"
+}
+
+route_address_removal_body()
+{
+	local addr1=10.0.0.1
+	local addr2=10.0.0.2
+	local addrgw=10.0.0.3
+	local prefix=24
+	local prefix_short=16
+	local alt_net=10.0.1.0
+	local alt_addr=10.0.1.1
+	local af=inet
+
+	test_route_address_removal
+}
+
+route_address_removal_cleanup()
+{
+
+	$DEBUG && dump
+	cleanup
+}
+
+atf_test_case route_address_removal6 cleanup
+route_address_removal6_head()

CVS commit: src/tests/net/route

2022-09-19 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Sep 20 02:25:07 UTC 2022

Modified Files:
src/tests/net/route: t_route.sh

Log Message:
tests: add tests for automatic route deletions on an address removal


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.



Re: CVS commit: src/tests/net/route

2016-06-21 Thread Ryota Ozaki
On Tue, Jun 21, 2016 at 7:35 PM, Paul Goyette  wrote:
> On Tue, 21 Jun 2016, Ryota Ozaki wrote:
>
>> Module Name:src
>> Committed By:   ozaki-r
>> Date:   Tue Jun 21 10:18:27 UTC 2016
>>
>> Modified Files:
>> src/tests/net/route: t_route.sh
>>
>> Log Message:
>> Tweak route get outputs to make tests work
>>
>> "expire" value of route get output is unexpectedly a negative value
>> on rump kernel for some reasons and the tests almost always fail
>> on babylon5. So just ignore it to make tests work for now. Should
>> fix it in the future.
>
>
> Wouldn't it be better to mark the test as "Expected Failure" ?

No because the tests pass on normal (fast enough?) machines,
although the tests sometimes fail even on such machines (I guess
because of load).

I guess the unexpected behavior stems from rump.route implementation
(or rump kernel) and doesn't happen on non-rump environments. I don't
have idea to fix it for now.

  ozaki-r


Re: CVS commit: src/tests/net/route

2016-06-21 Thread Paul Goyette

On Tue, 21 Jun 2016, Ryota Ozaki wrote:


Module Name:src
Committed By:   ozaki-r
Date:   Tue Jun 21 10:18:27 UTC 2016

Modified Files:
src/tests/net/route: t_route.sh

Log Message:
Tweak route get outputs to make tests work

"expire" value of route get output is unexpectedly a negative value
on rump kernel for some reasons and the tests almost always fail
on babylon5. So just ignore it to make tests work for now. Should
fix it in the future.


Wouldn't it be better to mark the test as "Expected Failure" ?


+--+--++
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:  |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+--+--++