CVS commit: src/tests/net/arp
Module Name:src Committed By: roy Date: Fri Sep 18 16:33:49 UTC 2020 Modified Files: src/tests/net/arp: t_arp.sh Log Message: arp tests: Delete ARP entry after failed ping test As it might hang around in WAITDELETE for a few seconds. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/tests/net/arp/t_arp.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.44 src/tests/net/arp/t_arp.sh:1.45 --- src/tests/net/arp/t_arp.sh:1.44 Thu Sep 17 11:51:01 2020 +++ src/tests/net/arp/t_arp.sh Fri Sep 18 16:33:49 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.44 2020/09/17 11:51:01 roy Exp $ +# $NetBSD: t_arp.sh,v 1.45 2020/09/18 16:33:49 roy Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -491,6 +491,8 @@ test_proxy_arp() export RUMP_SERVER=$SOCKSRC atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 + # Remove ARP entry as it may hang around in WAITDELETE a few seconds + atf_check -s ignore rump.arp -d $IP4DST_PROXYARP1 # Flushing extract_new_packets bus1 > ./out @@ -525,6 +527,8 @@ test_proxy_arp() export RUMP_SERVER=$SOCKSRC atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP2 + # Remove ARP entry as it may hang around in WAITDELETE a few seconds + atf_check -s ignore rump.arp -d $IP4DST_PROXYARP2 extract_new_packets bus1 > ./out $DEBUG && cat ./out
CVS commit: src/tests/net/arp
Module Name:src Committed By: roy Date: Thu Sep 17 11:51:01 UTC 2020 Modified Files: src/tests/net/arp: t_arp.sh Log Message: arp_rtm: Only ping once Pointless doing 10 pings. On a slow system, it's possible that many RTM_MISS messages could overflow into the next test. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/tests/net/arp/t_arp.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.43 src/tests/net/arp/t_arp.sh:1.44 --- src/tests/net/arp/t_arp.sh:1.43 Tue Sep 15 11:19:10 2020 +++ src/tests/net/arp/t_arp.sh Thu Sep 17 11:51:01 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.43 2020/09/15 11:19:10 roy Exp $ +# $NetBSD: t_arp.sh,v 1.44 2020/09/17 11:51:01 roy Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -717,9 +717,8 @@ arp_rtm_body() rump.route -n monitor -c 1 > $file & pid=$! sleep 1 - # arp_maxtries = 5, second between each try atf_check -s exit:2 -o ignore -e ignore \ - rump.ping -n -w 10 -c 10 $IP4DST_FAIL1 + rump.ping -n -w 1 -c 1 $IP4DST_FAIL1 wait $pid $DEBUG && cat $file
CVS commit: src/tests/net/arp
Module Name:src Committed By: roy Date: Tue Sep 15 11:19:10 UTC 2020 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Don't check lifetime when testing published To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/tests/net/arp/t_arp.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.42 src/tests/net/arp/t_arp.sh:1.43 --- src/tests/net/arp/t_arp.sh:1.42 Sun Sep 13 14:36:32 2020 +++ src/tests/net/arp/t_arp.sh Tue Sep 15 11:19:10 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.42 2020/09/13 14:36:32 roy Exp $ +# $NetBSD: t_arp.sh,v 1.43 2020/09/15 11:19:10 roy Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -477,7 +477,7 @@ test_proxy_arp() opts="pub proxy" fi # Always proxy only since migrating to lltable/llentry - title='permanent published \(proxy only\)' + title='published \(proxy only\)' # # Test#1: First setup an endpoint then create proxy arp entry
CVS commit: src/tests/net/arp
Module Name:src Committed By: roy Date: Sun Sep 13 14:36:32 UTC 2020 Modified Files: src/tests/net/arp: t_arp.sh Log Message: arp test: Use the ndp cache expiration test in place of the old one As the logic is the same. While here, GC some variables and comment out a redundant sleep. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/tests/net/arp/t_arp.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.41 src/tests/net/arp/t_arp.sh:1.42 --- src/tests/net/arp/t_arp.sh:1.41 Wed Mar 11 08:52:13 2020 +++ src/tests/net/arp/t_arp.sh Sun Sep 13 14:36:32 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.41 2020/03/11 08:52:13 roy Exp $ +# $NetBSD: t_arp.sh,v 1.42 2020/09/13 14:36:32 roy Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -39,8 +39,7 @@ IP4DST_FAIL2=10.0.99.99 DEBUG=${DEBUG:-false} TIMEOUT=1 -atf_test_case arp_cache_expiration_5s cleanup -atf_test_case arp_cache_expiration_10s cleanup +atf_test_case arp_cache_expiration cleanup atf_test_case arp_command cleanup atf_test_case arp_garp cleanup atf_test_case arp_garp_without_dad cleanup @@ -50,15 +49,9 @@ atf_test_case arp_proxy_arp_pubproxy cle atf_test_case arp_link_activation cleanup atf_test_case arp_static cleanup -arp_cache_expiration_5s_head() +arp_cache_expiration_head() { - atf_set "descr" "Tests for ARP cache expiration (5s)" - atf_set "require.progs" "rump_server" -} - -arp_cache_expiration_10s_head() -{ - atf_set "descr" "Tests for ARP cache expiration (10s)" + atf_set "descr" "Tests for ARP cache expiration" atf_set "require.progs" "rump_server" } @@ -132,10 +125,12 @@ setup_src_server() export RUMP_SERVER=$SOCKSRC - # Adjust ARP parameters + # Shorten the expire time of cache entries if [ $keep != 0 ]; then + # Convert to ms + keep=$(($keep * 1000)) atf_check -s exit:0 -o ignore \ - rump.sysctl -w net.inet.arp.keep=$keep + rump.sysctl -w net.inet.arp.nd_reachable=$keep fi # Setup an interface @@ -152,10 +147,17 @@ setup_src_server() atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4DST } -test_cache_expiration() +get_timeout() { - local arp_keep=$1 - local bonus=2 + local addr="$1" + local timeout=$(env RUMP_SERVER=$SOCKSRC rump.arp -n $addr |grep $addr|awk '{print $7;}') + timeout=${timeout%s} + echo $timeout +} + +arp_cache_expiration_body() +{ + local arp_keep=7 rump_server_start $SOCKSRC rump_server_start $SOCKDST @@ -163,38 +165,33 @@ test_cache_expiration() setup_dst_server setup_src_server $arp_keep + # Make a permanent cache entry to avoid sending an NS packet disturbing + # the test + macaddr=$(get_macaddr $SOCKSRC shmif0) + export RUMP_SERVER=$SOCKDST + atf_check -s exit:0 -o ignore rump.arp -s $IP4SRC $macaddr + + export RUMP_SERVER=$SOCKSRC + # # Check if a cache is expired expectedly # - export RUMP_SERVER=$SOCKSRC atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST $DEBUG && rump.arp -n -a - atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4SRC + atf_check -s not-exit:0 -o ignore -e match:'no entry' rump.arp -n $IP4SRC # Should be cached - atf_check -s exit:0 -o ignore rump.arp -n $IP4DST - $DEBUG && rump.netstat -nr -f inet - atf_check -s exit:0 -o match:"$IP4DST" rump.netstat -nr -f inet + atf_check -s exit:0 -o not-match:'permanent' rump.arp -n $IP4DST - atf_check -s exit:0 sleep $(($arp_keep + $bonus)) + timeout=$(get_timeout $IP4DST) - $DEBUG && rump.arp -n -a - atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4SRC - # Should be expired - atf_check -s not-exit:0 -e match:'no entry' rump.arp -n $IP4DST -} - -arp_cache_expiration_5s_body() -{ + atf_check -s exit:0 sleep $(($timeout + 1)) - test_cache_expiration 5 - rump_server_destroy_ifaces -} - -arp_cache_expiration_10s_body() -{ + $DEBUG && rump.arp -n -a + atf_check -s not-exit:0 -o ignore -e match:'no entry' rump.arp -n $IP4SRC + # Expired but remains until GC sweaps it (1 day) + atf_check -s exit:0 -o match:"$ONEDAYISH" rump.arp -n $IP4DST - test_cache_expiration 10 rump_server_destroy_ifaces } @@ -290,9 +287,9 @@ arp_command_body() check_arp_static_entry 10.0.1.10 'b2:a0:20:00:00:10' temp # Hm? the cache doesn't expire... - atf_check -s exit:0 sleep $(($arp_keep + $bonus)) - $DEBUG && rump.arp -n -a - $DEBUG && rump.netstat -nr -f inet + #atf_check -s exit:0 sleep $(($arp_keep + $bonus)) + #$DEBUG && rump.arp -n -a + #$DEBUG && rump.netstat -nr -f inet #atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.10 rump_server_destroy_ifaces @@ -403,7 +400,6 @@ arp_garp_without_dad_body() arp_cache_overwriting_body() { - local bonus=2 rump_server_start $SOCKSRC rump_server_start $SOCKDST @@ -563,7 +559,6 @@ arp_proxy_arp_pubproxy_body() arp_link_activation_body() { - local bonus=2
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Apr 6 09:23:36 UTC 2018 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Add tests for GARP without DAD Additionally make the existing tests for GARP more explicit. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/tests/net/arp/t_arp.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.35 src/tests/net/arp/t_arp.sh:1.36 --- src/tests/net/arp/t_arp.sh:1.35 Fri Apr 6 09:21:57 2018 +++ src/tests/net/arp/t_arp.sh Fri Apr 6 09:23:36 2018 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.35 2018/04/06 09:21:57 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.36 2018/04/06 09:23:36 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -41,6 +41,7 @@ atf_test_case arp_cache_expiration_5s cl atf_test_case arp_cache_expiration_10s cleanup atf_test_case arp_command cleanup atf_test_case arp_garp cleanup +atf_test_case arp_garp_without_dad cleanup atf_test_case arp_cache_overwriting cleanup atf_test_case arp_proxy_arp_pub cleanup atf_test_case arp_proxy_arp_pubproxy cleanup @@ -71,6 +72,13 @@ arp_garp_head() atf_set "require.progs" "rump_server" } +arp_garp_without_dad_head() +{ + + atf_set "descr" "Tests for GARP with DAD disabled" + atf_set "require.progs" "rump_server" +} + arp_cache_overwriting_head() { atf_set "descr" "Tests for behavior of overwriting ARP caches" @@ -297,45 +305,100 @@ make_pkt_str_arpreq() echo $pkt } -arp_garp_body() +test_garp_common() { + local no_dad=$1 local pkt= rump_server_start $SOCKSRC export RUMP_SERVER=$SOCKSRC + if $no_dad; then + atf_check -s exit:0 -o match:'3 -> 0' \ + rump.sysctl -w net.inet.ip.dad_count=0 + fi + # Setup an interface rump_server_add_iface $SOCKSRC shmif0 bus1 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 - atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias atf_check -s exit:0 rump.ifconfig shmif0 up $DEBUG && rump.ifconfig shmif0 atf_check -s exit:0 sleep 1 extract_new_packets bus1 > ./out + # + # Assign an address to an interface without IFF_UP + # # A GARP packet is sent for the primary address pkt=$(make_pkt_str_arpreq 10.0.0.1 10.0.0.1) atf_check -s exit:0 -o match:"$pkt" cat ./out - # No GARP packet is sent for the alias address + + atf_check -s exit:0 rump.ifconfig shmif0 down + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias + + atf_check -s exit:0 sleep 1 + extract_new_packets bus1 > ./out + + # A GARP packet is sent for the alias address pkt=$(make_pkt_str_arpreq 10.0.0.2 10.0.0.2) - atf_check -s exit:0 -o not-match:"$pkt" cat ./out + atf_check -s exit:0 -o match:"$pkt" cat ./out - atf_check -s exit:0 rump.ifconfig -w 10 + # Clean up + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 delete + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 delete + + # + # Assign an address to an interface with IFF_UP + # + atf_check -s exit:0 rump.ifconfig shmif0 up + + # Primary address atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 - atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias - # No GARP packets are sent during IFF_UP + atf_check -s exit:0 sleep 1 extract_new_packets bus1 > ./out + pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3) - atf_check -s exit:0 -o not-match:"$pkt" cat ./out + if $no_dad; then + # A GARP packet is sent + atf_check -s exit:0 -o match:"$pkt" cat ./out + else + # No GARP packet is sent + atf_check -s exit:0 -o not-match:"$pkt" cat ./out + fi + + # Alias address + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias + + atf_check -s exit:0 sleep 1 + extract_new_packets bus1 > ./out + pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4) - atf_check -s exit:0 -o not-match:"$pkt" cat ./out + if $no_dad; then + # A GARP packet is sent + atf_check -s exit:0 -o match:"$pkt" cat ./out + else + # No GARP packet is sent + atf_check -s exit:0 -o not-match:"$pkt" cat ./out + fi rump_server_destroy_ifaces } +arp_garp_body() +{ + + test_garp_common false +} + +arp_garp_without_dad_body() +{ + + test_garp_common true +} + arp_cache_overwriting_body() { local bonus=2 @@ -583,6 +646,13 @@ arp_garp_cleanup() cleanup } +arp_garp_without_dad_cleanup() +{ + + $DEBUG && dump + cleanup +} + arp_cache_overwriting_cleanup() { $DEBUG && dump @@ -879,6 +949,7 @@ atf_init_test_cases() atf_add_test_case arp_cache_expiration_10s atf_add_test_case arp_command atf_add_test_case arp_garp + atf_add_test_case arp_garp_without_dad atf_add_test_case arp_cache_overwriting atf_add_test_case arp_proxy_arp_pub atf_add_test_case arp_proxy_arp_pubproxy
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Apr 6 09:21:57 UTC 2018 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Improve packet checks and error reporting To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/tests/net/arp/t_arp.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.34 src/tests/net/arp/t_arp.sh:1.35 --- src/tests/net/arp/t_arp.sh:1.34 Thu Nov 23 06:22:12 2017 +++ src/tests/net/arp/t_arp.sh Fri Apr 6 09:21:57 2018 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.34 2017/11/23 06:22:12 kre Exp $ +# $NetBSD: t_arp.sh,v 1.35 2018/04/06 09:21:57 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -292,7 +292,7 @@ make_pkt_str_arpreq() { local target=$1 local sender=$2 - pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42:" + pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP \(0x0806\), length 42:" pkt="$pkt Request who-has $target tell $sender, length 28" echo $pkt } @@ -313,25 +313,25 @@ arp_garp_body() $DEBUG && rump.ifconfig shmif0 atf_check -s exit:0 sleep 1 - shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out + extract_new_packets bus1 > ./out # A GARP packet is sent for the primary address pkt=$(make_pkt_str_arpreq 10.0.0.1 10.0.0.1) - atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o match:"$pkt" cat ./out # No GARP packet is sent for the alias address pkt=$(make_pkt_str_arpreq 10.0.0.2 10.0.0.2) - atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o not-match:"$pkt" cat ./out atf_check -s exit:0 rump.ifconfig -w 10 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias # No GARP packets are sent during IFF_UP - shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out + extract_new_packets bus1 > ./out pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3) - atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o not-match:"$pkt" cat ./out pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4) - atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o not-match:"$pkt" cat ./out rump_server_destroy_ifaces } @@ -519,7 +519,7 @@ arp_link_activation_body() $DEBUG && cat ./out pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC) - atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o not-match:"$pkt" cat ./out atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \ b2:a1:00:00:00:02 active @@ -529,8 +529,7 @@ arp_link_activation_body() $DEBUG && cat ./out pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC) - atf_check -s exit:0 -x \ - "cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'" + atf_check -s exit:0 -o match:"b2:a1:00:00:00:02 $pkt" cat ./out rump_server_destroy_ifaces }
CVS commit: src/tests/net/arp
Module Name:src Committed By: kre Date: Thu Nov 23 06:22:12 UTC 2017 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Clean up the arp_rtm subtest... 1. Be assertive when claiming the pid of the background route monitor command, not polite... (ie: $! will give you the pid, $? is just 0 there). 2. Since "wait 0" simply (always) exits with status 127, immediately (we know without thinking that we have no child with pid 0) the waits were ineffective - now (after fix #1) they work .. which requires the route monitor that watches the arp -d to exit after 1 message, not 2, as 1 is all it gets. (If there really should be 2, someone needs to find out why the kernel is sending only 1 - I am not that someone). 3. The file contents need to be read only once, no matter how many patterns we need to look for, save some work, and do it that way (this is not really a bug,m but saving time for the ATF tests is always a good thing.) Not sure if this will stop it randomly failing on bablyon5, but it might. (The likely cause is that the "route.monitor" has not flushed its stdout buffers at the time the "grep -A 3" [aside: why that way to read the file??] is performed, so fails to find its expected output ... the route monitor would get an extra message once interfaces start being destroyed, I assume, and would exit then, flushing its buffer, but by then it is too late. If that is/was the cause, then it should be fixed now.) To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/tests/net/arp/t_arp.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.33 src/tests/net/arp/t_arp.sh:1.34 --- src/tests/net/arp/t_arp.sh:1.33 Wed Jun 28 08:17:50 2017 +++ src/tests/net/arp/t_arp.sh Thu Nov 23 06:22:12 2017 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.33 2017/06/28 08:17:50 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.34 2017/11/23 06:22:12 kre Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -626,7 +626,7 @@ arp_rtm_body() { local macaddr_src= macaddr_dst= local file=./tmp - local pid= str= + local pid= hdr= what= addr= rump_server_start $SOCKSRC rump_server_start $SOCKDST @@ -641,33 +641,31 @@ arp_rtm_body() # Test ping and a resulting routing message (RTM_ADD) rump.route -n monitor -c 1 > $file & - pid=$? + pid=$! sleep 1 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST wait $pid $DEBUG && cat $file - str="RTM_ADD.+" - atf_check -s exit:0 -o match:"$str" cat $file - str=" " - atf_check -s exit:0 -o match:"$str" cat $file - str="$IP4DST link#2" - atf_check -s exit:0 -o match:"$str" cat $file + hdr="RTM_ADD.+ " + what=" " + addr="$IP4DST link#2" + atf_check -s exit:0 -o match:"$hdr" -o match:"$what" -o match:"$addr" \ + cat $file # Test arp -d and resulting routing messages (RTM_DELETE) - rump.route -n monitor -c 2 > $file & - pid=$? + rump.route -n monitor -c 1 > $file & + pid=$! sleep 1 atf_check -s exit:0 -o ignore rump.arp -d $IP4DST wait $pid $DEBUG && cat $file - str="RTM_DELETE.+ " - atf_check -s exit:0 -o match:"$str" grep -A 3 RTM_DELETE $file - str=" " - atf_check -s exit:0 -o match:"$str" grep -A 3 RTM_DELETE $file - str="$IP4DST $macaddr_dst" - atf_check -s exit:0 -o match:"$str" grep -A 3 RTM_DELETE $file + hdr="RTM_DELETE.+ " + what=" " + addr="$IP4DST $macaddr_dst" + atf_check -s exit:0 -o match:"$hdr" -o match:"$what" -o match:"$addr" \ + grep -A 3 RTM_DELETE $file rump_server_destroy_ifaces }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Wed Jun 21 03:10:42 UTC 2017 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Set net.inet.arp.keep only if it's required To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/net/arp/t_arp.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.24 src/tests/net/arp/t_arp.sh:1.25 --- src/tests/net/arp/t_arp.sh:1.24 Mon Jun 19 10:57:37 2017 +++ src/tests/net/arp/t_arp.sh Wed Jun 21 03:10:42 2017 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.24 2017/06/19 10:57:37 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.25 2017/06/21 03:10:42 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -115,12 +115,15 @@ setup_dst_server() setup_src_server() { - local keep=$1 + local keep=${1:-0} export RUMP_SERVER=$SOCKSRC # Adjust ARP parameters - atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.arp.keep=$keep + if [ $keep != 0 ]; then + atf_check -s exit:0 -o ignore \ + rump.sysctl -w net.inet.arp.keep=$keep + fi # Setup an interface rump_server_add_iface $SOCKSRC shmif0 bus1 @@ -309,14 +312,13 @@ arp_garp_body() arp_cache_overwriting_body() { - local arp_keep=5 local bonus=2 rump_server_start $SOCKSRC rump_server_start $SOCKDST setup_dst_server - setup_src_server $arp_keep + setup_src_server export RUMP_SERVER=$SOCKSRC @@ -366,7 +368,6 @@ make_pkt_str_garp() test_proxy_arp() { - local arp_keep=5 local opts= title= flags= local type=$1 @@ -374,7 +375,7 @@ test_proxy_arp() rump_server_start $SOCKDST tap setup_dst_server - setup_src_server $arp_keep + setup_src_server export RUMP_SERVER=$SOCKDST atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1 @@ -480,14 +481,13 @@ arp_proxy_arp_pubproxy_body() arp_link_activation_body() { - local arp_keep=5 local bonus=2 rump_server_start $SOCKSRC rump_server_start $SOCKDST setup_dst_server - setup_src_server $arp_keep + setup_src_server # flush old packets extract_new_packets bus1 > ./out @@ -520,14 +520,13 @@ arp_link_activation_body() arp_static_body() { - local arp_keep=5 local macaddr_src= rump_server_start $SOCKSRC rump_server_start $SOCKDST setup_dst_server - setup_src_server $arp_keep + setup_src_server macaddr_src=$(get_macaddr $SOCKSRC shmif0) @@ -608,7 +607,6 @@ arp_rtm_head() arp_rtm_body() { - local arp_keep=5 local macaddr_src= macaddr_dst= local file=./tmp local pid= str= @@ -617,7 +615,7 @@ arp_rtm_body() rump_server_start $SOCKDST setup_dst_server - setup_src_server $arp_keep + setup_src_server macaddr_src=$(get_macaddr $SOCKSRC shmif0) macaddr_dst=$(get_macaddr $SOCKDST shmif0)
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Sat Mar 11 02:01:10 UTC 2017 Modified Files: src/tests/net/arp: t_dad.sh Log Message: Improve test stability and output messages on failure To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.14 src/tests/net/arp/t_dad.sh:1.15 --- src/tests/net/arp/t_dad.sh:1.14 Wed Mar 8 05:30:56 2017 +++ src/tests/net/arp/t_dad.sh Sat Mar 11 02:01:10 2017 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.14 2017/03/08 05:30:56 ozaki-r Exp $ +# $NetBSD: t_dad.sh,v 1.15 2017/03/11 02:01:10 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -168,21 +168,24 @@ dad_duplicated_body() export RUMP_SERVER=$SOCKLOCAL # The primary address isn't marked as duplicated - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -iq duplicated" + atf_check -s exit:0 -o not-match:"${localip1}.+DUPLICATED" \ + rump.ifconfig shmif0 # # Add a new address duplicated with the peer server # atf_check -s exit:0 rump.ifconfig shmif0 inet $peerip alias - atf_check -s exit:0 sleep 1 + atf_check -s exit:0 sleep 2 # The new address is marked as duplicated - atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -iq duplicated" + atf_check -s exit:0 -o match:"${peerip}.+DUPLICATED" \ + rump.ifconfig shmif0 # A unique address isn't marked as duplicated atf_check -s exit:0 rump.ifconfig shmif0 inet $localip2 alias - atf_check -s exit:0 sleep 1 - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -iq duplicated" + atf_check -s exit:0 sleep 2 + atf_check -s exit:0 -o not-match:"${localip2}.+DUPLICATED" \ + rump.ifconfig shmif0 rump_server_destroy_ifaces }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Wed Mar 8 05:30:56 UTC 2017 Modified Files: src/tests/net/arp: t_dad.sh Log Message: Improve test stability and output messages on failure To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.13 src/tests/net/arp/t_dad.sh:1.14 --- src/tests/net/arp/t_dad.sh:1.13 Fri Nov 25 08:51:16 2016 +++ src/tests/net/arp/t_dad.sh Wed Mar 8 05:30:56 2017 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.13 2016/11/25 08:51:16 ozaki-r Exp $ +# $NetBSD: t_dad.sh,v 1.14 2017/03/08 05:30:56 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -64,7 +64,7 @@ make_pkt_str() { local target=$1 local sender=$2 - pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42:" + pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP \(0x0806\), length 42:" pkt="$pkt Request who-has $target tell $sender, length 28" echo $pkt } @@ -78,6 +78,10 @@ dad_basic_body() export RUMP_SERVER=$SOCKLOCAL + # Increase the number of trials, which makes the tests stable + atf_check -s exit:0 -o match:'3 -> 5' \ + rump.sysctl -w net.inet.ip.dad_count=5 + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias $DEBUG && rump.ifconfig shmif0 @@ -87,10 +91,9 @@ dad_basic_body() $DEBUG && cat ./out # The primary address doesn't start with tentative state - atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -iq tentative" + atf_check -s exit:0 -o not-match:'10\.0\.0\.1.+TENTATIVE' cat ./out # The alias address starts with tentative state - # XXX we have no stable way to check this, so skip for now - #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -iq tentative" + atf_check -s exit:0 -o match:'10\.0\.0\.2.+TENTATIVE' cat ./out atf_check -s exit:0 sleep 2 extract_new_packets bus1 > ./out @@ -98,23 +101,24 @@ dad_basic_body() # Check DAD probe packets pkt=$(make_pkt_str 10.0.0.2 0.0.0.0) - atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o match:"$pkt" cat ./out # No DAD for the primary address pkt=$(make_pkt_str 10.0.0.1 0.0.0.0) - atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o not-match:"$pkt" cat ./out # Waiting for DAD complete atf_check -s exit:0 rump.ifconfig -w 10 # Give a chance to send a DAD announce packet - atf_check -s exit:0 sleep 1 + atf_check -s exit:0 sleep 2 extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check the DAD announce packet pkt=$(make_pkt_str 10.0.0.2 10.0.0.2) - atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o match:"$pkt" cat ./out # The alias address left tentative - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -iq tentative" + atf_check -s exit:0 -o not-match:'10\.0\.0\.2.+TENTATIVE' \ + rump.ifconfig shmif0 # # Add a new address on the fly @@ -122,28 +126,29 @@ dad_basic_body() atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 alias # The new address starts with tentative state - # XXX we have no stable way to check this, so skip for now - #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative" + atf_check -s exit:0 -o match:'10\.0\.0\.3.+TENTATIVE' \ + rump.ifconfig shmif0 # Check DAD probe packets atf_check -s exit:0 sleep 2 extract_new_packets bus1 > ./out $DEBUG && cat ./out pkt=$(make_pkt_str 10.0.0.3 0.0.0.0) - atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o match:"$pkt" cat ./out # Waiting for DAD complete atf_check -s exit:0 rump.ifconfig -w 10 # Give a chance to send a DAD announce packet - atf_check -s exit:0 sleep 1 + atf_check -s exit:0 sleep 2 extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check the DAD announce packet pkt=$(make_pkt_str 10.0.0.3 10.0.0.3) - atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + atf_check -s exit:0 -o match:"$pkt" cat ./out # The new address left tentative - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative" + atf_check -s exit:0 -o not-match:'10\.0\.0\.3.+TENTATIVE' \ + rump.ifconfig shmif0 rump_server_destroy_ifaces }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Thu Nov 24 11:34:51 UTC 2016 Modified Files: src/tests/net/arp: t_dad.sh Log Message: Add missing bus argument for extract_new_packets To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.11 src/tests/net/arp/t_dad.sh:1.12 --- src/tests/net/arp/t_dad.sh:1.11 Thu Nov 24 09:03:53 2016 +++ src/tests/net/arp/t_dad.sh Thu Nov 24 11:34:51 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.11 2016/11/24 09:03:53 ozaki-r Exp $ +# $NetBSD: t_dad.sh,v 1.12 2016/11/24 11:34:51 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -97,7 +97,7 @@ dad_basic_body() #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -iq tentative" atf_check -s exit:0 sleep 2 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check DAD probe packets @@ -111,7 +111,7 @@ dad_basic_body() atf_check -s exit:0 rump.ifconfig -w 10 # Give a chance to send a DAD announce packet atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check the DAD announce packet @@ -131,7 +131,7 @@ dad_basic_body() # Check DAD probe packets atf_check -s exit:0 sleep 2 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out pkt=$(make_pkt_str 10.0.0.3 0.0.0.0) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" @@ -140,7 +140,7 @@ dad_basic_body() atf_check -s exit:0 rump.ifconfig -w 10 # Give a chance to send a DAD announce packet atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check the DAD announce packet
CVS commit: src/tests/net/arp
Module Name:src Committed By: christos Date: Wed Sep 14 16:00:10 UTC 2016 Modified Files: src/tests/net/arp: t_dad.sh Log Message: adjust for new ifconfig output. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.7 src/tests/net/arp/t_dad.sh:1.8 --- src/tests/net/arp/t_dad.sh:1.7 Wed Aug 10 18:05:07 2016 +++ src/tests/net/arp/t_dad.sh Wed Sep 14 12:00:10 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.7 2016/08/10 22:05:07 kre Exp $ +# $NetBSD: t_dad.sh,v 1.8 2016/09/14 16:00:10 christos Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -107,10 +107,10 @@ dad_basic_body() $DEBUG && cat ./out # The primary address doesn't start with tentative state - atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -q tentative" + atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -iq tentative" # The alias address starts with tentative state # XXX we have no stable way to check this, so skip for now - #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -q tentative" + #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -iq tentative" atf_check -s exit:0 sleep 2 extract_new_packets > ./out @@ -134,7 +134,7 @@ dad_basic_body() pkt=$(make_pkt_str 10.0.0.2 10.0.0.2) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" # The alias address left tentative - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -q tentative" + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -iq tentative" # # Add a new address on the fly @@ -143,7 +143,7 @@ dad_basic_body() # The new address starts with tentative state # XXX we have no stable way to check this, so skip for now - #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative" + #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative" # Check DAD probe packets atf_check -s exit:0 sleep 2 @@ -163,7 +163,7 @@ dad_basic_body() pkt=$(make_pkt_str 10.0.0.3 10.0.0.3) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" # The new address left tentative - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative" + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative" } dad_duplicated_body() @@ -181,7 +181,7 @@ dad_duplicated_body() export RUMP_SERVER=$SOCKLOCAL # The primary address isn't marked as duplicated - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -q duplicated" + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -iq duplicated" # # Add a new address duplicated with the peer server @@ -190,12 +190,12 @@ dad_duplicated_body() atf_check -s exit:0 sleep 1 # The new address is marked as duplicated - atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -q duplicated" + atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -iq duplicated" # A unique address isn't marked as duplicated atf_check -s exit:0 rump.ifconfig shmif0 inet $localip2 alias atf_check -s exit:0 sleep 1 - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -q duplicated" + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -iq duplicated" } cleanup()
CVS commit: src/tests/net/arp
Module Name:src Committed By: christos Date: Tue Aug 23 16:03:45 UTC 2016 Modified Files: src/tests/net/arp: t_arp.sh Log Message: no functional change To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/net/arp/t_arp.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.16 src/tests/net/arp/t_arp.sh:1.17 --- src/tests/net/arp/t_arp.sh:1.16 Tue Jun 21 01:04:16 2016 +++ src/tests/net/arp/t_arp.sh Tue Aug 23 12:03:45 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.16 2016/06/21 05:04:16 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.17 2016/08/23 16:03:45 christos Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,8 +25,8 @@ # POSSIBILITY OF SUCH DAMAGE. # -inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" -inetserver="$inetserver -lrumpdev -lrumpnet_tap" +inetlib="-lrumpnet_shmif -lrumpnet_tap -lrumpnet -lrumpnet_net -lrumpnet_netinet" +inetserver="rump_server $inetlib -lrumpdev" HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" SOCKSRC=unix://commsock1
CVS commit: src/tests/net/arp
Module Name:src Committed By: kre Date: Wed Aug 10 22:05:07 UTC 2016 Modified Files: src/tests/net/arp: t_dad.sh Log Message: + -lrumpdev To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.6 src/tests/net/arp/t_dad.sh:1.7 --- src/tests/net/arp/t_dad.sh:1.6 Tue Aug 25 02:24:34 2015 +++ src/tests/net/arp/t_dad.sh Wed Aug 10 22:05:07 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.6 2015/08/25 02:24:34 ozaki-r Exp $ +# $NetBSD: t_dad.sh,v 1.7 2016/08/10 22:05:07 kre Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -26,6 +26,7 @@ # inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" +inetserver="${inetserver} -lrumpdev" HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" SOCKLOCAL=unix://commsock1
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Mon Apr 18 02:27:34 UTC 2016 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Add a test case for static ARP It tests receiving an ARP request that has a spa (i.e., IP address) whose ARP entry already exists in the table as a static ARP entry. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/net/arp/t_arp.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.14 src/tests/net/arp/t_arp.sh:1.15 --- src/tests/net/arp/t_arp.sh:1.14 Mon Apr 4 07:37:08 2016 +++ src/tests/net/arp/t_arp.sh Mon Apr 18 02:27:34 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.14 2016/04/04 07:37:08 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.15 2016/04/18 02:27:34 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -47,6 +47,7 @@ atf_test_case cache_overwriting cleanup atf_test_case proxy_arp_pub cleanup atf_test_case proxy_arp_pubproxy cleanup atf_test_case link_activation cleanup +atf_test_case static_arp cleanup cache_expiration_5s_head() { @@ -96,6 +97,13 @@ link_activation_head() atf_set "require.progs" "rump_server" } +static_arp_head() +{ + + atf_set "descr" "Tests for static ARP entries" + atf_set "require.progs" "rump_server" +} + setup_dst_server() { export RUMP_SERVER=$SOCKDST @@ -520,6 +528,31 @@ link_activation_body() "cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'" } +static_arp_body() +{ + local arp_keep=5 + local macaddr_src= + + atf_check -s exit:0 ${inetserver} $SOCKSRC + atf_check -s exit:0 ${inetserver} $SOCKDST + + setup_dst_server + setup_src_server $arp_keep + + export RUMP_SERVER=$SOCKSRC + macaddr_src=$(rump.ifconfig shmif0 |awk '/address/ {print $2;}') + + # Set a (valid) static ARP entry for the src server + export RUMP_SERVER=$SOCKDST + $DEBUG && rump.arp -n -a + atf_check -s exit:0 -o ignore rump.arp -s $IP4SRC $macaddr_src + $DEBUG && rump.arp -n -a + + # Test receiving an ARP request with the static ARP entry (as spa/sha) + export RUMP_SERVER=$SOCKSRC + atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST +} + cleanup() { env RUMP_SERVER=$SOCKSRC rump.halt @@ -600,6 +633,12 @@ link_activation_cleanup() cleanup } +static_arp_cleanup() +{ + $DEBUG && dump + cleanup +} + atf_init_test_cases() { atf_add_test_case cache_expiration_5s @@ -610,4 +649,5 @@ atf_init_test_cases() atf_add_test_case proxy_arp_pub atf_add_test_case proxy_arp_pubproxy atf_add_test_case link_activation + atf_add_test_case static_arp }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Mar 4 04:18:44 UTC 2016 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Improve tests of proxy arp The tests make it clear how it behaves though, I don't know if the current behavior is what it should be. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/net/arp/t_arp.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.12 src/tests/net/arp/t_arp.sh:1.13 --- src/tests/net/arp/t_arp.sh:1.12 Mon Feb 29 09:35:16 2016 +++ src/tests/net/arp/t_arp.sh Fri Mar 4 04:18:44 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.12 2016/02/29 09:35:16 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.13 2016/03/04 04:18:44 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -26,16 +26,15 @@ # inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" +inetserver="$inetserver -lrumpdev -lrumpnet_tap" HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" SOCKSRC=unix://commsock1 SOCKDST=unix://commsock2 IP4SRC=10.0.1.1 IP4DST=10.0.1.2 -IP4DST_PUB=10.0.1.3 -MACDST_PUB=b2:a1:00:00:00:01 -IP4DST_PUBPROXY=10.0.1.4 -MACDST_PUBPROXY=b2:a1:00:00:00:02 +IP4DST_PROXYARP1=10.0.1.3 +IP4DST_PROXYARP2=10.0.1.4 DEBUG=false TIMEOUT=1 @@ -45,7 +44,8 @@ atf_test_case cache_expiration_10s clean atf_test_case command cleanup atf_test_case garp cleanup atf_test_case cache_overwriting cleanup -atf_test_case pubproxy_arp cleanup +atf_test_case proxy_arp_pub cleanup +atf_test_case proxy_arp_pubproxy cleanup atf_test_case link_activation cleanup cache_expiration_5s_head() @@ -78,9 +78,15 @@ cache_overwriting_head() atf_set "require.progs" "rump_server" } -pubproxy_arp_head() +proxy_arp_pub_head() { - atf_set "descr" "Tests for Proxy ARP" + atf_set "descr" "Tests for Proxy ARP (pub)" + atf_set "require.progs" "rump_server" +} + +proxy_arp_pubproxy_head() +{ + atf_set "descr" "Tests for Proxy ARP (pub proxy)" atf_set "require.progs" "rump_server" } @@ -360,9 +366,12 @@ check_entry_flags() "rump.netstat -rn -f inet | grep ^'$ip'" } -pubproxy_arp_body() + +test_proxy_arp() { local arp_keep=5 + local opts= title= flags= + local type=$1 atf_check -s exit:0 ${inetserver} $SOCKSRC atf_check -s exit:0 ${inetserver} $SOCKDST @@ -371,48 +380,116 @@ pubproxy_arp_body() setup_src_server $arp_keep export RUMP_SERVER=$SOCKDST + atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1 + macaddr_dst=$(rump.ifconfig shmif0 |awk '/address/ {print $2;}') - atf_check -s exit:0 -o ignore rump.arp -s $IP4DST_PUB \ - $MACDST_PUB pub - atf_check -s exit:0 -o match:'permanent published' \ - rump.arp -n $IP4DST_PUB - check_entry_flags $IP4DST_PUB ULSp + if [ "$type" = "pub" ]; then + opts="pub" + title="permanent published" + flags="ULSp" + else + opts="pub proxy" + title='permanent published \(proxy only\)' + flags="UHLSp" + fi - $DEBUG && rump.arp -n -a - $DEBUG && rump.netstat -nr -f inet + # + # Test#1: First setup an endpoint then create proxy arp entry + # + export RUMP_SERVER=$SOCKDST + atf_check -s exit:0 rump.ifconfig tap1 create + atf_check -s exit:0 rump.ifconfig tap1 $IP4DST_PROXYARP1/24 up + atf_check -s exit:0 rump.ifconfig -w 10 - atf_check -s exit:0 -o ignore rump.arp -s $IP4DST_PUBPROXY \ - $MACDST_PUBPROXY pub proxy - atf_check -s exit:0 -o match:'permanent published \(proxy only\)' \ - rump.arp -n $IP4DST_PUBPROXY - check_entry_flags $IP4DST_PUBPROXY UHLSp + # Try to ping (should fail w/o proxy arp) + export RUMP_SERVER=$SOCKSRC + atf_check -s not-exit:0 -o ignore -e ignore \ + rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 - $DEBUG && rump.arp -n -a - $DEBUG && rump.netstat -nr -f inet + # Flushing + extract_new_packets > ./out - export RUMP_SERVER=$SOCKSRC + # Set up proxy ARP entry + export RUMP_SERVER=$SOCKDST + atf_check -s exit:0 -o ignore \ + rump.arp -s $IP4DST_PROXYARP1 $macaddr_dst $opts + atf_check -s exit:0 -o match:"$title" rump.arp -n $IP4DST_PROXYARP1 + if [ "$type" = "pub" ]; then + # XXX local? Is it correct? + check_entry_flags $IP4DST_PROXYARP1 ${flags}l + else + check_entry_flags $IP4DST_PROXYARP1 $flags + fi - atf_check -s not-exit:0 -o ignore -e ignore \ - rump.ping -n -w 1 -c 1 $IP4DST_PUB + # Try to ping + export RUMP_SERVER=$SOCKSRC + if [ "$type" = "pub" ]; then + # XXX fails + atf_check -s not-exit:0 -o ignore -e ignore \ + rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 + else + atf_check -s exit:0 -o ignore \ + rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 + fi - atf_check -s exit:0 sleep 1 extract_new_packets > ./out $DEBUG && cat ./out - pkt=$(make_pkt_str_arprep $IP4DST_PUB $MACDST_PUB) - atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + pkt=$(make_pkt_str_arprep
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Thu Feb 25 03:23:15 UTC 2016 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Add basic tests for Proxy ARP The tests don't much enough and need more realitic tests, for example tests for a setup using ppp found in PR 44032. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/net/arp/t_arp.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.10 src/tests/net/arp/t_arp.sh:1.11 --- src/tests/net/arp/t_arp.sh:1.10 Wed Dec 2 06:05:14 2015 +++ src/tests/net/arp/t_arp.sh Thu Feb 25 03:23:15 2016 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.10 2015/12/02 06:05:14 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.11 2016/02/25 03:23:15 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -32,6 +32,10 @@ SOCKSRC=unix://commsock1 SOCKDST=unix://commsock2 IP4SRC=10.0.1.1 IP4DST=10.0.1.2 +IP4DST_PUB=10.0.1.3 +MACDST_PUB=b2:a1:00:00:00:01 +IP4DST_PUBPROXY=10.0.1.4 +MACDST_PUBPROXY=b2:a1:00:00:00:02 DEBUG=false TIMEOUT=1 @@ -41,6 +45,7 @@ atf_test_case cache_expiration_10s clean atf_test_case command cleanup atf_test_case garp cleanup atf_test_case cache_overwriting cleanup +atf_test_case pubproxy_arp cleanup cache_expiration_5s_head() { @@ -72,6 +77,12 @@ cache_overwriting_head() atf_set "require.progs" "rump_server" } +pubproxy_arp_head() +{ + atf_set "descr" "Tests for Proxy ARP" + atf_set "require.progs" "rump_server" +} + setup_dst_server() { export RUMP_SERVER=$SOCKDST @@ -225,7 +236,7 @@ command_body() return 0 } -make_pkt_str() +make_pkt_str_arpreq() { local target=$1 local sender=$2 @@ -253,10 +264,10 @@ garp_body() shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out # A GARP packet is sent for the primary address - pkt=$(make_pkt_str 10.0.0.1 10.0.0.1) + pkt=$(make_pkt_str_arpreq 10.0.0.1 10.0.0.1) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" # No GARP packet is sent for the alias address - pkt=$(make_pkt_str 10.0.0.2 10.0.0.2) + pkt=$(make_pkt_str_arpreq 10.0.0.2 10.0.0.2) atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" atf_check -s exit:0 rump.ifconfig -w 10 @@ -265,9 +276,9 @@ garp_body() # No GARP packets are sent during IFF_UP shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - > ./out - pkt=$(make_pkt_str 10.0.0.3 10.0.0.3) + pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3) atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" - pkt=$(make_pkt_str 10.0.0.4 10.0.0.4) + pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4) atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" } @@ -309,6 +320,94 @@ cache_overwriting_body() return 0 } +make_pkt_str_arprep() +{ + local ip=$1 + local mac=$2 + pkt="ethertype ARP (0x0806), length 42: " + pkt="Reply $ip is-at $mac, length 28" + echo $pkt +} + +extract_new_packets() +{ + local old=./old + + if [ ! -f $old ]; then + old=/dev/null + fi + + shmif_dumpbus -p - bus1 2>/dev/null| \ + tcpdump -n -e -r - 2>/dev/null > ./new + diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff + mv -f ./new ./old + cat ./diff +} + +check_entry_flags() +{ + local ip=$(echo $1 |sed 's/\./\\./g') + local flags=$2 + + atf_check -s exit:0 -o match:" $flags " -e ignore -x \ + "rump.netstat -rn -f inet | grep ^'$ip'" +} + +pubproxy_arp_body() +{ + local arp_keep=5 + + atf_check -s exit:0 ${inetserver} $SOCKSRC + atf_check -s exit:0 ${inetserver} $SOCKDST + + setup_dst_server + setup_src_server $arp_keep + + export RUMP_SERVER=$SOCKDST + + atf_check -s exit:0 -o ignore rump.arp -s $IP4DST_PUB \ + $MACDST_PUB pub + atf_check -s exit:0 -o match:'permanent published' \ + rump.arp -n $IP4DST_PUB + check_entry_flags $IP4DST_PUB ULSp + + $DEBUG && rump.arp -n -a + $DEBUG && rump.netstat -nr -f inet + + atf_check -s exit:0 -o ignore rump.arp -s $IP4DST_PUBPROXY \ + $MACDST_PUBPROXY pub proxy + atf_check -s exit:0 -o match:'permanent published \(proxy only\)' \ + rump.arp -n $IP4DST_PUBPROXY + check_entry_flags $IP4DST_PUBPROXY UHLSp + + $DEBUG && rump.arp -n -a + $DEBUG && rump.netstat -nr -f inet + + export RUMP_SERVER=$SOCKSRC + + atf_check -s not-exit:0 -o ignore -e ignore \ + rump.ping -n -w 1 -c 1 $IP4DST_PUB + + atf_check -s exit:0 sleep 1 + extract_new_packets > ./out + $DEBUG && cat ./out + + pkt=$(make_pkt_str_arprep $IP4DST_PUB $MACDST_PUB) + atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + + atf_check -s not-exit:0 -o ignore -e ignore \ + rump.ping -n -w 1 -c 1 $IP4DST_PUBPROXY + + atf_check -s exit:0 sleep 1 + extract_new_packets > ./out + $DEBUG && cat ./out + + pkt=$(make_pkt_str_arprep $IP4DST_PUBPROXY $MACDST_PUBPROXY) + atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" + + return 0 +} + cleanup() { env RUMP_SERVER=$SOCKSRC rump.halt @@ -371,6 +470,12 @@ cache_overwriting_cleanup()
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Wed Dec 2 06:05:14 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Make checks strict rump.arp should fail with File exists (EEXIST). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/net/arp/t_arp.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.9 src/tests/net/arp/t_arp.sh:1.10 --- src/tests/net/arp/t_arp.sh:1.9 Mon Aug 31 08:08:20 2015 +++ src/tests/net/arp/t_arp.sh Wed Dec 2 06:05:14 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.9 2015/08/31 08:08:20 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.10 2015/12/02 06:05:14 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -285,7 +285,8 @@ cache_overwriting_body() export RUMP_SERVER=$SOCKSRC # Cannot overwrite a permanent cache - atf_check -s not-exit:0 -e ignore rump.arp -s $IP4SRC b2:a0:20:00:00:ff + atf_check -s not-exit:0 -e match:'File exists' \ + rump.arp -s $IP4SRC b2:a0:20:00:00:ff $DEBUG && rump.arp -n -a atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST @@ -301,7 +302,8 @@ cache_overwriting_body() atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10 atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10 # Cannot overwrite a temp cache - atf_check -s not-exit:0 -e ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:ff + atf_check -s not-exit:0 -e match:'File exists' \ + rump.arp -s 10.0.1.10 b2:a0:20:00:00:ff $DEBUG && rump.arp -n -a return 0
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Mon Aug 31 08:08:20 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Reflect the current ARP cache implementation in tests net.inet.arp.prune and net.inet.arp.refresh were obsoleted. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/net/arp/t_arp.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.8 src/tests/net/arp/t_arp.sh:1.9 --- src/tests/net/arp/t_arp.sh:1.8 Thu Aug 13 10:22:21 2015 +++ src/tests/net/arp/t_arp.sh Mon Aug 31 08:08:20 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.8 2015/08/13 10:22:21 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.9 2015/08/31 08:08:20 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -87,16 +87,12 @@ setup_dst_server() setup_src_server() { - local prune=$1 - local keep=$2 + local keep=$1 export RUMP_SERVER=$SOCKSRC # Adjust ARP parameters - atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.arp.prune=$prune atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.arp.keep=$keep - # Don't refresh to test expiration easily - atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.arp.refresh=0 # Setup an interface atf_check -s exit:0 rump.ifconfig shmif0 create @@ -114,7 +110,6 @@ setup_src_server() test_cache_expiration() { - local arp_prune=1 local arp_keep=$1 local bonus=2 @@ -122,7 +117,7 @@ test_cache_expiration() atf_check -s exit:0 ${inetserver} $SOCKDST setup_dst_server - setup_src_server $arp_prune $arp_keep + setup_src_server $arp_keep # # Check if a cache is expired expectedly @@ -135,7 +130,7 @@ test_cache_expiration() # Should be cached atf_check -s exit:0 -o ignore rump.arp -n $IP4DST - atf_check -s exit:0 sleep $(($arp_keep + $arp_prune + $bonus)) + atf_check -s exit:0 sleep $(($arp_keep + $bonus)) $DEBUG && rump.arp -n -a atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC @@ -155,7 +150,6 @@ cache_expiration_10s_body() command_body() { - local arp_prune=1 local arp_keep=5 local bonus=2 @@ -163,7 +157,7 @@ command_body() atf_check -s exit:0 ${inetserver} $SOCKDST setup_dst_server - setup_src_server $arp_prune $arp_keep + setup_src_server $arp_keep export RUMP_SERVER=$SOCKSRC @@ -224,7 +218,7 @@ command_body() atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10 # Hm? the cache doesn't expire... - atf_check -s exit:0 sleep $(($arp_keep + $arp_prune + $bonus)) + atf_check -s exit:0 sleep $(($arp_keep + $bonus)) $DEBUG && rump.arp -n -a #atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.10 @@ -279,7 +273,6 @@ garp_body() cache_overwriting_body() { - local arp_prune=1 local arp_keep=5 local bonus=2 @@ -287,7 +280,7 @@ cache_overwriting_body() atf_check -s exit:0 ${inetserver} $SOCKDST setup_dst_server - setup_src_server $arp_prune $arp_keep + setup_src_server $arp_keep export RUMP_SERVER=$SOCKSRC
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Tue Aug 25 02:24:34 UTC 2015 Modified Files: src/tests/net/arp: t_dad.sh Log Message: Give a chance to send a DAD announce packet ifconfig -w ensures IP addresses have left tentative state, however, it doesn't guarantee that a DAD announce packet is sent. The kernel clears tentative flag and then sends the packet so that ifconfig -w can return before the kernel sends the packet. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.5 src/tests/net/arp/t_dad.sh:1.6 --- src/tests/net/arp/t_dad.sh:1.5 Mon Aug 24 02:02:25 2015 +++ src/tests/net/arp/t_dad.sh Tue Aug 25 02:24:34 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.5 2015/08/24 02:02:25 ozaki-r Exp $ +# $NetBSD: t_dad.sh,v 1.6 2015/08/25 02:24:34 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -124,6 +124,8 @@ dad_basic_body() # Waiting for DAD complete atf_check -s exit:0 rump.ifconfig -w 10 + # Give a chance to send a DAD announce packet + atf_check -s exit:0 sleep 1 extract_new_packets ./out $DEBUG cat ./out @@ -151,6 +153,8 @@ dad_basic_body() # Waiting for DAD complete atf_check -s exit:0 rump.ifconfig -w 10 + # Give a chance to send a DAD announce packet + atf_check -s exit:0 sleep 1 extract_new_packets ./out $DEBUG cat ./out
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Thu Aug 13 10:22:21 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Reflect a fix on rt_refcnt The test was adjusted based on wrong behavior. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/net/arp/t_arp.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.7 src/tests/net/arp/t_arp.sh:1.8 --- src/tests/net/arp/t_arp.sh:1.7 Fri Aug 7 05:32:12 2015 +++ src/tests/net/arp/t_arp.sh Thu Aug 13 10:22:21 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.7 2015/08/07 05:32:12 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.8 2015/08/13 10:22:21 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -140,8 +140,7 @@ test_cache_expiration() $DEBUG rump.arp -n -a atf_check -s exit:0 -o ignore rump.arp -n $IP4SRC # Should be expired - #atf_check -s not-exit:0 -e ignore rump.arp -n $IP4DST - atf_check -s exit:0 -o match:'incomplete' rump.arp -n $IP4DST + atf_check -s not-exit:0 -e ignore rump.arp -n $IP4DST } cache_expiration_5s_body() @@ -227,7 +226,7 @@ command_body() # Hm? the cache doesn't expire... atf_check -s exit:0 sleep $(($arp_keep + $arp_prune + $bonus)) $DEBUG rump.arp -n -a - #atf_check -s exit:0 -o match:'incomplete' rump.arp -n 10.0.1.10 + #atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.10 return 0 }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Aug 7 05:32:12 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Check MAC address of ARP caches additionally To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/net/arp/t_arp.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.6 src/tests/net/arp/t_arp.sh:1.7 --- src/tests/net/arp/t_arp.sh:1.6 Fri Jul 31 10:16:36 2015 +++ src/tests/net/arp/t_arp.sh Fri Aug 7 05:32:12 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.6 2015/07/31 10:16:36 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.7 2015/08/07 05:32:12 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -172,6 +172,7 @@ command_body() $DEBUG rump.arp -n -a atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 $DEBUG rump.arp -n -a + atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10 atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.10 atf_check -s exit:0 -o ignore rump.arp -d 10.0.1.10 $DEBUG rump.arp -n -a @@ -188,10 +189,15 @@ command_body() $DEBUG rump.arp -n -a atf_check -s exit:0 -o ignore rump.arp -f ./list $DEBUG rump.arp -n -a + atf_check -s exit:0 -o match:'b2:a0:20:00:00:11' rump.arp -n 10.0.1.11 atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.11 + atf_check -s exit:0 -o match:'b2:a0:20:00:00:12' rump.arp -n 10.0.1.12 atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.12 + atf_check -s exit:0 -o match:'b2:a0:20:00:00:13' rump.arp -n 10.0.1.13 atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.13 + atf_check -s exit:0 -o match:'b2:a0:20:00:00:14' rump.arp -n 10.0.1.14 atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.14 + atf_check -s exit:0 -o match:'b2:a0:20:00:00:15' rump.arp -n 10.0.1.15 atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.15 # Test arp -a @@ -215,6 +221,7 @@ command_body() $DEBUG rump.arp -n -a atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp $DEBUG rump.arp -n -a + atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10 atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10 # Hm? the cache doesn't expire... @@ -294,10 +301,12 @@ cache_overwriting_body() # Can overwrite a dynamic cache atf_check -s exit:0 -o ignore rump.arp -s $IP4DST b2:a0:20:00:00:00 $DEBUG rump.arp -n -a + atf_check -s exit:0 -o match:'b2:a0:20:00:00:00' rump.arp -n $IP4DST atf_check -s exit:0 -o match:'permanent' rump.arp -n $IP4DST atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp $DEBUG rump.arp -n -a + atf_check -s exit:0 -o match:'b2:a0:20:00:00:10' rump.arp -n 10.0.1.10 atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10 # Cannot overwrite a temp cache atf_check -s not-exit:0 -e ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:ff
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Jul 31 10:16:36 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Return 0 explicitly to avoid unexpected failures when $DEBUG=false To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/net/arp/t_arp.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.5 src/tests/net/arp/t_arp.sh:1.6 --- src/tests/net/arp/t_arp.sh:1.5 Fri Jul 31 02:39:12 2015 +++ src/tests/net/arp/t_arp.sh Fri Jul 31 10:16:36 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.5 2015/07/31 02:39:12 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.6 2015/07/31 10:16:36 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -221,6 +221,8 @@ command_body() atf_check -s exit:0 sleep $(($arp_keep + $arp_prune + $bonus)) $DEBUG rump.arp -n -a #atf_check -s exit:0 -o match:'incomplete' rump.arp -n 10.0.1.10 + + return 0 } make_pkt_str() @@ -300,6 +302,8 @@ cache_overwriting_body() # Cannot overwrite a temp cache atf_check -s not-exit:0 -e ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:ff $DEBUG rump.arp -n -a + + return 0 } cleanup()
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Jul 31 00:23:54 UTC 2015 Modified Files: src/tests/net/arp: t_dad.sh Log Message: Remove remaining debug code To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.2 src/tests/net/arp/t_dad.sh:1.3 --- src/tests/net/arp/t_dad.sh:1.2 Fri Jul 31 00:22:44 2015 +++ src/tests/net/arp/t_dad.sh Fri Jul 31 00:23:54 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.2 2015/07/31 00:22:44 ozaki-r Exp $ +# $NetBSD: t_dad.sh,v 1.3 2015/07/31 00:23:54 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -173,8 +173,6 @@ dad_duplicated_body() cleanup() { - gdb -ex bt /usr/bin/rump_server rump_server.core - gdb -ex bt /usr/sbin/arp arp.core env RUMP_SERVER=$SOCKLOCAL rump.halt env RUMP_SERVER=$SOCKPEER rump.halt }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Jul 31 00:22:44 UTC 2015 Modified Files: src/tests/net/arp: t_dad.sh Log Message: Fix cleanup; halt all running rump_servers To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/arp/t_dad.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_dad.sh diff -u src/tests/net/arp/t_dad.sh:1.1 src/tests/net/arp/t_dad.sh:1.2 --- src/tests/net/arp/t_dad.sh:1.1 Thu Jul 30 02:52:53 2015 +++ src/tests/net/arp/t_dad.sh Fri Jul 31 00:22:44 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.1 2015/07/30 02:52:53 ozaki-r Exp $ +# $NetBSD: t_dad.sh,v 1.2 2015/07/31 00:22:44 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -214,7 +214,7 @@ dad_basic_cleanup() dad_duplicated_cleanup() { $DEBUG dump - env RUMP_SERVER=$SOCKLOCAL rump.halt + cleanup } atf_init_test_cases()
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Jul 31 02:39:12 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Add tests of cache overwriting To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/net/arp/t_arp.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.4 src/tests/net/arp/t_arp.sh:1.5 --- src/tests/net/arp/t_arp.sh:1.4 Fri Jul 31 02:35:09 2015 +++ src/tests/net/arp/t_arp.sh Fri Jul 31 02:39:12 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.4 2015/07/31 02:35:09 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.5 2015/07/31 02:39:12 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -40,6 +40,7 @@ atf_test_case cache_expiration_5s cleanu atf_test_case cache_expiration_10s cleanup atf_test_case command cleanup atf_test_case garp cleanup +atf_test_case cache_overwriting cleanup cache_expiration_5s_head() { @@ -65,6 +66,12 @@ garp_head() atf_set require.progs rump_server } +cache_overwriting_head() +{ + atf_set descr Tests for behavior of overwriting ARP caches + atf_set require.progs rump_server +} + setup_dst_server() { export RUMP_SERVER=$SOCKDST @@ -262,6 +269,39 @@ garp_body() atf_check -s not-exit:0 -x cat ./out |grep -q '$pkt' } +cache_overwriting_body() +{ + local arp_prune=1 + local arp_keep=5 + local bonus=2 + + atf_check -s exit:0 ${inetserver} $SOCKSRC + atf_check -s exit:0 ${inetserver} $SOCKDST + + setup_dst_server + setup_src_server $arp_prune $arp_keep + + export RUMP_SERVER=$SOCKSRC + + # Cannot overwrite a permanent cache + atf_check -s not-exit:0 -e ignore rump.arp -s $IP4SRC b2:a0:20:00:00:ff + $DEBUG rump.arp -n -a + + atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4DST + $DEBUG rump.arp -n -a + # Can overwrite a dynamic cache + atf_check -s exit:0 -o ignore rump.arp -s $IP4DST b2:a0:20:00:00:00 + $DEBUG rump.arp -n -a + atf_check -s exit:0 -o match:'permanent' rump.arp -n $IP4DST + + atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp + $DEBUG rump.arp -n -a + atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10 + # Cannot overwrite a temp cache + atf_check -s not-exit:0 -e ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:ff + $DEBUG rump.arp -n -a +} + cleanup() { env RUMP_SERVER=$SOCKSRC rump.halt @@ -318,10 +358,17 @@ garp_cleanup() env RUMP_SERVER=$SOCKSRC rump.halt } +cache_overwriting_cleanup() +{ + $DEBUG dump + cleanup +} + atf_init_test_cases() { atf_add_test_case cache_expiration_5s atf_add_test_case cache_expiration_10s atf_add_test_case command atf_add_test_case garp + atf_add_test_case cache_overwriting }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Fri Jul 31 02:35:09 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Add tests for temp option To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/net/arp/t_arp.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.3 src/tests/net/arp/t_arp.sh:1.4 --- src/tests/net/arp/t_arp.sh:1.3 Thu Jul 30 08:41:18 2015 +++ src/tests/net/arp/t_arp.sh Fri Jul 31 02:35:09 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.3 2015/07/30 08:41:18 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.4 2015/07/31 02:35:09 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -203,6 +203,17 @@ command_body() atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.14 atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.15 atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.1 + + # Test temp option + $DEBUG rump.arp -n -a + atf_check -s exit:0 -o ignore rump.arp -s 10.0.1.10 b2:a0:20:00:00:10 temp + $DEBUG rump.arp -n -a + atf_check -s exit:0 -o not-match:'permanent' rump.arp -n 10.0.1.10 + + # Hm? the cache doesn't expire... + atf_check -s exit:0 sleep $(($arp_keep + $arp_prune + $bonus)) + $DEBUG rump.arp -n -a + #atf_check -s exit:0 -o match:'incomplete' rump.arp -n 10.0.1.10 } make_pkt_str()
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Thu Jul 30 08:41:18 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Add tests for arp -a option To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/net/arp/t_arp.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.2 src/tests/net/arp/t_arp.sh:1.3 --- src/tests/net/arp/t_arp.sh:1.2 Thu Jul 30 02:51:05 2015 +++ src/tests/net/arp/t_arp.sh Thu Jul 30 08:41:18 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.2 2015/07/30 02:51:05 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.3 2015/07/30 08:41:18 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -187,6 +187,13 @@ command_body() atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.14 atf_check -s exit:0 -o match:'permanent' rump.arp -n 10.0.1.15 + # Test arp -a + atf_check -s exit:0 -o match:'10.0.1.11' rump.arp -n -a + atf_check -s exit:0 -o match:'10.0.1.12' rump.arp -n -a + atf_check -s exit:0 -o match:'10.0.1.13' rump.arp -n -a + atf_check -s exit:0 -o match:'10.0.1.14' rump.arp -n -a + atf_check -s exit:0 -o match:'10.0.1.15' rump.arp -n -a + # Flush all entries $DEBUG rump.arp -n -a atf_check -s exit:0 -o ignore rump.arp -d -a
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Thu Jul 30 02:51:05 UTC 2015 Modified Files: src/tests/net/arp: t_arp.sh Log Message: Add tests for GARP To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/arp/t_arp.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.1 src/tests/net/arp/t_arp.sh:1.2 --- src/tests/net/arp/t_arp.sh:1.1 Wed Jul 29 06:10:10 2015 +++ src/tests/net/arp/t_arp.sh Thu Jul 30 02:51:05 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.1 2015/07/29 06:10:10 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.2 2015/07/30 02:51:05 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -39,6 +39,7 @@ TIMEOUT=1 atf_test_case cache_expiration_5s cleanup atf_test_case cache_expiration_10s cleanup atf_test_case command cleanup +atf_test_case garp cleanup cache_expiration_5s_head() { @@ -58,6 +59,12 @@ command_head() atf_set require.progs rump_server } +garp_head() +{ + atf_set descr Tests for GARP + atf_set require.progs rump_server +} + setup_dst_server() { export RUMP_SERVER=$SOCKDST @@ -191,24 +198,80 @@ command_body() atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.1 } +make_pkt_str() +{ + local target=$1 + local sender=$2 + pkt= ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: + pkt=$pkt Request who-has $target tell $sender, length 28 + echo $pkt +} + +garp_body() +{ + local pkt= + + atf_check -s exit:0 ${inetserver} $SOCKSRC + export RUMP_SERVER=$SOCKSRC + + # Setup an interface + atf_check -s exit:0 rump.ifconfig shmif0 create + atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias + atf_check -s exit:0 rump.ifconfig shmif0 up + $DEBUG rump.ifconfig shmif0 + + atf_check -s exit:0 sleep 1 + shmif_dumpbus -p - bus1 2/dev/null| tcpdump -n -e -r - ./out + + # A GARP packet is sent for the primary address + pkt=$(make_pkt_str 10.0.0.1 10.0.0.1) + atf_check -s exit:0 -x cat ./out |grep -q '$pkt' + # No GARP packet is sent for the alias address + pkt=$(make_pkt_str 10.0.0.2 10.0.0.2) + atf_check -s not-exit:0 -x cat ./out |grep -q '$pkt' + + atf_check -s exit:0 rump.ifconfig -w 10 + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 + atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias + + # No GARP packets are sent during IFF_UP + shmif_dumpbus -p - bus1 2/dev/null| tcpdump -n -e -r - ./out + pkt=$(make_pkt_str 10.0.0.3 10.0.0.3) + atf_check -s not-exit:0 -x cat ./out |grep -q '$pkt' + pkt=$(make_pkt_str 10.0.0.4 10.0.0.4) + atf_check -s not-exit:0 -x cat ./out |grep -q '$pkt' +} + cleanup() { env RUMP_SERVER=$SOCKSRC rump.halt env RUMP_SERVER=$SOCKDST rump.halt } -dump() +dump_src() { export RUMP_SERVER=$SOCKSRC rump.netstat -nr rump.arp -n -a + rump.ifconfig $HIJACKING dmesg +} +dump_dst() +{ export RUMP_SERVER=$SOCKDST rump.netstat -nr rump.arp -n -a + rump.ifconfig $HIJACKING dmesg +} +dump() +{ + dump_src + dump_dst shmif_dumpbus -p - bus1 2/dev/null| tcpdump -n -e -r - } @@ -230,9 +293,17 @@ command_cleanup() cleanup } +garp_cleanup() +{ + $DEBUG dump_src + $DEBUG shmif_dumpbus -p - bus1 2/dev/null| tcpdump -n -e -r - + env RUMP_SERVER=$SOCKSRC rump.halt +} + atf_init_test_cases() { atf_add_test_case cache_expiration_5s atf_add_test_case cache_expiration_10s atf_add_test_case command + atf_add_test_case garp }
CVS commit: src/tests/net/arp
Module Name:src Committed By: ozaki-r Date: Thu Jul 30 05:43:43 UTC 2015 Modified Files: src/tests/net/arp: Makefile Log Message: Fix TESTS_SH assignment To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/net/arp/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/net/arp/Makefile diff -u src/tests/net/arp/Makefile:1.2 src/tests/net/arp/Makefile:1.3 --- src/tests/net/arp/Makefile:1.2 Thu Jul 30 02:52:53 2015 +++ src/tests/net/arp/Makefile Thu Jul 30 05:43:42 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2015/07/30 02:52:53 ozaki-r Exp $ +# $NetBSD: Makefile,v 1.3 2015/07/30 05:43:42 ozaki-r Exp $ # .include bsd.own.mk @@ -6,6 +6,6 @@ TESTSDIR= ${TESTSBASE}/net/arp TESTS_SH= t_arp -TESTS_SH= t_dad +TESTS_SH+= t_dad .include bsd.test.mk