| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: t_arp.sh,v 1.35 2018/04/06 09:21:57 ozaki-r Exp $ | | 1 | # $NetBSD: t_arp.sh,v 1.36 2018/04/06 09:23:36 ozaki-r Exp $ |
2 | # | | 2 | # |
3 | # Copyright (c) 2015 The NetBSD Foundation, Inc. | | 3 | # Copyright (c) 2015 The NetBSD Foundation, Inc. |
4 | # All rights reserved. | | 4 | # All rights reserved. |
5 | # | | 5 | # |
6 | # Redistribution and use in source and binary forms, with or without | | 6 | # Redistribution and use in source and binary forms, with or without |
7 | # modification, are permitted provided that the following conditions | | 7 | # modification, are permitted provided that the following conditions |
8 | # are met: | | 8 | # are met: |
9 | # 1. Redistributions of source code must retain the above copyright | | 9 | # 1. Redistributions of source code must retain the above copyright |
10 | # notice, this list of conditions and the following disclaimer. | | 10 | # notice, this list of conditions and the following disclaimer. |
11 | # 2. Redistributions in binary form must reproduce the above copyright | | 11 | # 2. Redistributions in binary form must reproduce the above copyright |
12 | # notice, this list of conditions and the following disclaimer in the | | 12 | # notice, this list of conditions and the following disclaimer in the |
13 | # documentation and/or other materials provided with the distribution. | | 13 | # documentation and/or other materials provided with the distribution. |
14 | # | | 14 | # |
| @@ -31,26 +31,27 @@ IP4SRC=10.0.1.1 | | | @@ -31,26 +31,27 @@ IP4SRC=10.0.1.1 |
31 | IP4SRC2=10.0.1.5 | | 31 | IP4SRC2=10.0.1.5 |
32 | IP4NET=10.0.1.0 | | 32 | IP4NET=10.0.1.0 |
33 | IP4DST=10.0.1.2 | | 33 | IP4DST=10.0.1.2 |
34 | IP4DST_PROXYARP1=10.0.1.3 | | 34 | IP4DST_PROXYARP1=10.0.1.3 |
35 | IP4DST_PROXYARP2=10.0.1.4 | | 35 | IP4DST_PROXYARP2=10.0.1.4 |
36 | | | 36 | |
37 | DEBUG=${DEBUG:-false} | | 37 | DEBUG=${DEBUG:-false} |
38 | TIMEOUT=1 | | 38 | TIMEOUT=1 |
39 | | | 39 | |
40 | atf_test_case arp_cache_expiration_5s cleanup | | 40 | atf_test_case arp_cache_expiration_5s cleanup |
41 | atf_test_case arp_cache_expiration_10s cleanup | | 41 | atf_test_case arp_cache_expiration_10s cleanup |
42 | atf_test_case arp_command cleanup | | 42 | atf_test_case arp_command cleanup |
43 | atf_test_case arp_garp cleanup | | 43 | atf_test_case arp_garp cleanup |
| | | 44 | atf_test_case arp_garp_without_dad cleanup |
44 | atf_test_case arp_cache_overwriting cleanup | | 45 | atf_test_case arp_cache_overwriting cleanup |
45 | atf_test_case arp_proxy_arp_pub cleanup | | 46 | atf_test_case arp_proxy_arp_pub cleanup |
46 | atf_test_case arp_proxy_arp_pubproxy cleanup | | 47 | atf_test_case arp_proxy_arp_pubproxy cleanup |
47 | atf_test_case arp_link_activation cleanup | | 48 | atf_test_case arp_link_activation cleanup |
48 | atf_test_case arp_static cleanup | | 49 | atf_test_case arp_static cleanup |
49 | | | 50 | |
50 | arp_cache_expiration_5s_head() | | 51 | arp_cache_expiration_5s_head() |
51 | { | | 52 | { |
52 | atf_set "descr" "Tests for ARP cache expiration (5s)" | | 53 | atf_set "descr" "Tests for ARP cache expiration (5s)" |
53 | atf_set "require.progs" "rump_server" | | 54 | atf_set "require.progs" "rump_server" |
54 | } | | 55 | } |
55 | | | 56 | |
56 | arp_cache_expiration_10s_head() | | 57 | arp_cache_expiration_10s_head() |
| @@ -61,26 +62,33 @@ arp_cache_expiration_10s_head() | | | @@ -61,26 +62,33 @@ arp_cache_expiration_10s_head() |
61 | | | 62 | |
62 | arp_command_head() | | 63 | arp_command_head() |
63 | { | | 64 | { |
64 | atf_set "descr" "Tests for arp_commands of arp(8)" | | 65 | atf_set "descr" "Tests for arp_commands of arp(8)" |
65 | atf_set "require.progs" "rump_server" | | 66 | atf_set "require.progs" "rump_server" |
66 | } | | 67 | } |
67 | | | 68 | |
68 | arp_garp_head() | | 69 | arp_garp_head() |
69 | { | | 70 | { |
70 | atf_set "descr" "Tests for GARP" | | 71 | atf_set "descr" "Tests for GARP" |
71 | atf_set "require.progs" "rump_server" | | 72 | atf_set "require.progs" "rump_server" |
72 | } | | 73 | } |
73 | | | 74 | |
| | | 75 | arp_garp_without_dad_head() |
| | | 76 | { |
| | | 77 | |
| | | 78 | atf_set "descr" "Tests for GARP with DAD disabled" |
| | | 79 | atf_set "require.progs" "rump_server" |
| | | 80 | } |
| | | 81 | |
74 | arp_cache_overwriting_head() | | 82 | arp_cache_overwriting_head() |
75 | { | | 83 | { |
76 | atf_set "descr" "Tests for behavior of overwriting ARP caches" | | 84 | atf_set "descr" "Tests for behavior of overwriting ARP caches" |
77 | atf_set "require.progs" "rump_server" | | 85 | atf_set "require.progs" "rump_server" |
78 | } | | 86 | } |
79 | | | 87 | |
80 | arp_proxy_arp_pub_head() | | 88 | arp_proxy_arp_pub_head() |
81 | { | | 89 | { |
82 | atf_set "descr" "Tests for Proxy ARP (pub)" | | 90 | atf_set "descr" "Tests for Proxy ARP (pub)" |
83 | atf_set "require.progs" "rump_server" | | 91 | atf_set "require.progs" "rump_server" |
84 | } | | 92 | } |
85 | | | 93 | |
86 | arp_proxy_arp_pubproxy_head() | | 94 | arp_proxy_arp_pubproxy_head() |
| @@ -287,65 +295,120 @@ arp_command_body() | | | @@ -287,65 +295,120 @@ arp_command_body() |
287 | | | 295 | |
288 | rump_server_destroy_ifaces | | 296 | rump_server_destroy_ifaces |
289 | } | | 297 | } |
290 | | | 298 | |
291 | make_pkt_str_arpreq() | | 299 | make_pkt_str_arpreq() |
292 | { | | 300 | { |
293 | local target=$1 | | 301 | local target=$1 |
294 | local sender=$2 | | 302 | local sender=$2 |
295 | pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP \(0x0806\), length 42:" | | 303 | pkt="> ff:ff:ff:ff:ff:ff, ethertype ARP \(0x0806\), length 42:" |
296 | pkt="$pkt Request who-has $target tell $sender, length 28" | | 304 | pkt="$pkt Request who-has $target tell $sender, length 28" |
297 | echo $pkt | | 305 | echo $pkt |
298 | } | | 306 | } |
299 | | | 307 | |
300 | arp_garp_body() | | 308 | test_garp_common() |
301 | { | | 309 | { |
| | | 310 | local no_dad=$1 |
302 | local pkt= | | 311 | local pkt= |
303 | | | 312 | |
304 | rump_server_start $SOCKSRC | | 313 | rump_server_start $SOCKSRC |
305 | | | 314 | |
306 | export RUMP_SERVER=$SOCKSRC | | 315 | export RUMP_SERVER=$SOCKSRC |
307 | | | 316 | |
| | | 317 | if $no_dad; then |
| | | 318 | atf_check -s exit:0 -o match:'3 -> 0' \ |
| | | 319 | rump.sysctl -w net.inet.ip.dad_count=0 |
| | | 320 | fi |
| | | 321 | |
308 | # Setup an interface | | 322 | # Setup an interface |
309 | rump_server_add_iface $SOCKSRC shmif0 bus1 | | 323 | rump_server_add_iface $SOCKSRC shmif0 bus1 |
310 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 | | 324 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 |
311 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias | | | |
312 | atf_check -s exit:0 rump.ifconfig shmif0 up | | 325 | atf_check -s exit:0 rump.ifconfig shmif0 up |
313 | $DEBUG && rump.ifconfig shmif0 | | 326 | $DEBUG && rump.ifconfig shmif0 |
314 | | | 327 | |
315 | atf_check -s exit:0 sleep 1 | | 328 | atf_check -s exit:0 sleep 1 |
316 | extract_new_packets bus1 > ./out | | 329 | extract_new_packets bus1 > ./out |
317 | | | 330 | |
| | | 331 | # |
| | | 332 | # Assign an address to an interface without IFF_UP |
| | | 333 | # |
318 | # A GARP packet is sent for the primary address | | 334 | # A GARP packet is sent for the primary address |
319 | pkt=$(make_pkt_str_arpreq 10.0.0.1 10.0.0.1) | | 335 | pkt=$(make_pkt_str_arpreq 10.0.0.1 10.0.0.1) |
320 | atf_check -s exit:0 -o match:"$pkt" cat ./out | | 336 | atf_check -s exit:0 -o match:"$pkt" cat ./out |
321 | # No GARP packet is sent for the alias address | | 337 | |
| | | 338 | atf_check -s exit:0 rump.ifconfig shmif0 down |
| | | 339 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias |
| | | 340 | |
| | | 341 | atf_check -s exit:0 sleep 1 |
| | | 342 | extract_new_packets bus1 > ./out |
| | | 343 | |
| | | 344 | # A GARP packet is sent for the alias address |
322 | pkt=$(make_pkt_str_arpreq 10.0.0.2 10.0.0.2) | | 345 | pkt=$(make_pkt_str_arpreq 10.0.0.2 10.0.0.2) |
323 | atf_check -s exit:0 -o not-match:"$pkt" cat ./out | | 346 | atf_check -s exit:0 -o match:"$pkt" cat ./out |
324 | | | 347 | |
325 | atf_check -s exit:0 rump.ifconfig -w 10 | | 348 | # Clean up |
| | | 349 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 delete |
| | | 350 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 delete |
| | | 351 | |
| | | 352 | # |
| | | 353 | # Assign an address to an interface with IFF_UP |
| | | 354 | # |
| | | 355 | atf_check -s exit:0 rump.ifconfig shmif0 up |
| | | 356 | |
| | | 357 | # Primary address |
326 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 | | 358 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 |
327 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias | | | |
328 | | | 359 | |
329 | # No GARP packets are sent during IFF_UP | | 360 | atf_check -s exit:0 sleep 1 |
330 | extract_new_packets bus1 > ./out | | 361 | extract_new_packets bus1 > ./out |
| | | 362 | |
331 | pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3) | | 363 | pkt=$(make_pkt_str_arpreq 10.0.0.3 10.0.0.3) |
332 | atf_check -s exit:0 -o not-match:"$pkt" cat ./out | | 364 | if $no_dad; then |
| | | 365 | # A GARP packet is sent |
| | | 366 | atf_check -s exit:0 -o match:"$pkt" cat ./out |
| | | 367 | else |
| | | 368 | # No GARP packet is sent |
| | | 369 | atf_check -s exit:0 -o not-match:"$pkt" cat ./out |
| | | 370 | fi |
| | | 371 | |
| | | 372 | # Alias address |
| | | 373 | atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.4/24 alias |
| | | 374 | |
| | | 375 | atf_check -s exit:0 sleep 1 |
| | | 376 | extract_new_packets bus1 > ./out |
| | | 377 | |
333 | pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4) | | 378 | pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4) |
334 | atf_check -s exit:0 -o not-match:"$pkt" cat ./out | | 379 | if $no_dad; then |
| | | 380 | # A GARP packet is sent |
| | | 381 | atf_check -s exit:0 -o match:"$pkt" cat ./out |
| | | 382 | else |
| | | 383 | # No GARP packet is sent |
| | | 384 | atf_check -s exit:0 -o not-match:"$pkt" cat ./out |
| | | 385 | fi |
335 | | | 386 | |
336 | rump_server_destroy_ifaces | | 387 | rump_server_destroy_ifaces |
337 | } | | 388 | } |
338 | | | 389 | |
| | | 390 | arp_garp_body() |
| | | 391 | { |
| | | 392 | |
| | | 393 | test_garp_common false |
| | | 394 | } |
| | | 395 | |
| | | 396 | arp_garp_without_dad_body() |
| | | 397 | { |
| | | 398 | |
| | | 399 | test_garp_common true |
| | | 400 | } |
| | | 401 | |
339 | arp_cache_overwriting_body() | | 402 | arp_cache_overwriting_body() |
340 | { | | 403 | { |
341 | local bonus=2 | | 404 | local bonus=2 |
342 | | | 405 | |
343 | rump_server_start $SOCKSRC | | 406 | rump_server_start $SOCKSRC |
344 | rump_server_start $SOCKDST | | 407 | rump_server_start $SOCKDST |
345 | | | 408 | |
346 | setup_dst_server | | 409 | setup_dst_server |
347 | setup_src_server | | 410 | setup_src_server |
348 | | | 411 | |
349 | export RUMP_SERVER=$SOCKSRC | | 412 | export RUMP_SERVER=$SOCKSRC |
350 | | | 413 | |
351 | # Cannot overwrite a permanent cache | | 414 | # Cannot overwrite a permanent cache |
| @@ -573,26 +636,33 @@ arp_cache_expiration_10s_cleanup() | | | @@ -573,26 +636,33 @@ arp_cache_expiration_10s_cleanup() |
573 | | | 636 | |
574 | arp_command_cleanup() | | 637 | arp_command_cleanup() |
575 | { | | 638 | { |
576 | $DEBUG && dump | | 639 | $DEBUG && dump |
577 | cleanup | | 640 | cleanup |
578 | } | | 641 | } |
579 | | | 642 | |
580 | arp_garp_cleanup() | | 643 | arp_garp_cleanup() |
581 | { | | 644 | { |
582 | $DEBUG && dump | | 645 | $DEBUG && dump |
583 | cleanup | | 646 | cleanup |
584 | } | | 647 | } |
585 | | | 648 | |
| | | 649 | arp_garp_without_dad_cleanup() |
| | | 650 | { |
| | | 651 | |
| | | 652 | $DEBUG && dump |
| | | 653 | cleanup |
| | | 654 | } |
| | | 655 | |
586 | arp_cache_overwriting_cleanup() | | 656 | arp_cache_overwriting_cleanup() |
587 | { | | 657 | { |
588 | $DEBUG && dump | | 658 | $DEBUG && dump |
589 | cleanup | | 659 | cleanup |
590 | } | | 660 | } |
591 | | | 661 | |
592 | arp_proxy_arp_pub_cleanup() | | 662 | arp_proxy_arp_pub_cleanup() |
593 | { | | 663 | { |
594 | $DEBUG && dump | | 664 | $DEBUG && dump |
595 | cleanup | | 665 | cleanup |
596 | } | | 666 | } |
597 | | | 667 | |
598 | arp_proxy_arp_pubproxy_cleanup() | | 668 | arp_proxy_arp_pubproxy_cleanup() |
| @@ -869,24 +939,25 @@ arp_stray_entries_body() | | | @@ -869,24 +939,25 @@ arp_stray_entries_body() |
869 | arp_stray_entries_cleanup() | | 939 | arp_stray_entries_cleanup() |
870 | { | | 940 | { |
871 | | | 941 | |
872 | $DEBUG && dump | | 942 | $DEBUG && dump |
873 | cleanup | | 943 | cleanup |
874 | } | | 944 | } |
875 | | | 945 | |
876 | atf_init_test_cases() | | 946 | atf_init_test_cases() |
877 | { | | 947 | { |
878 | atf_add_test_case arp_cache_expiration_5s | | 948 | atf_add_test_case arp_cache_expiration_5s |
879 | atf_add_test_case arp_cache_expiration_10s | | 949 | atf_add_test_case arp_cache_expiration_10s |
880 | atf_add_test_case arp_command | | 950 | atf_add_test_case arp_command |
881 | atf_add_test_case arp_garp | | 951 | atf_add_test_case arp_garp |
| | | 952 | atf_add_test_case arp_garp_without_dad |
882 | atf_add_test_case arp_cache_overwriting | | 953 | atf_add_test_case arp_cache_overwriting |
883 | atf_add_test_case arp_proxy_arp_pub | | 954 | atf_add_test_case arp_proxy_arp_pub |
884 | atf_add_test_case arp_proxy_arp_pubproxy | | 955 | atf_add_test_case arp_proxy_arp_pubproxy |
885 | atf_add_test_case arp_link_activation | | 956 | atf_add_test_case arp_link_activation |
886 | atf_add_test_case arp_static | | 957 | atf_add_test_case arp_static |
887 | atf_add_test_case arp_rtm | | 958 | atf_add_test_case arp_rtm |
888 | atf_add_test_case arp_purge_on_route_change | | 959 | atf_add_test_case arp_purge_on_route_change |
889 | atf_add_test_case arp_purge_on_route_delete | | 960 | atf_add_test_case arp_purge_on_route_delete |
890 | atf_add_test_case arp_purge_on_ifdown | | 961 | atf_add_test_case arp_purge_on_ifdown |
891 | atf_add_test_case arp_stray_entries | | 962 | atf_add_test_case arp_stray_entries |
892 | } | | 963 | } |