2 # Copyright (c) 2014 Spectra Logic Corporation
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions, and the following disclaimer,
10 # without modification.
11 # 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 # substantially similar to the "NO WARRANTY" disclaimer below
13 # ("Disclaimer") and any redistribution must be conditioned upon
14 # including a substantially similar Disclaimer requirement for further
15 # binary redistribution.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGES.
30 # Authors: Alan Somers (Spectra Logic Corporation)
35 # For each cloned interface type, do three tests
36 # 1) Create and destroy it
37 # 2) Create, up, and destroy it
38 # 3) Create, disable IPv6 auto address assignment, up, and destroy it
42 atf_test_case epair_stress cleanup
45 atf_set "descr" "Simultaneously create and destroy an epair(4)"
46 atf_set "require.user" "root"
50 if [ "$(atf_config_get ci false)" = "true" ]; then
51 atf_skip "https://bugs.freebsd.org/246443"
55 epair_stress_cleanup()
60 atf_test_case epair_up_stress cleanup
61 epair_up_stress_head()
63 atf_set "descr" "Simultaneously up and detroy an epair(4)"
64 atf_set "require.user" "root"
66 epair_up_stress_body()
68 do_up_stress "epair" "" ""
70 epair_up_stress_cleanup()
75 atf_test_case epair_ipv6_up_stress cleanup
76 epair_ipv6_up_stress_head()
78 atf_set "descr" "Simultaneously up and destroy an epair(4) with IPv6"
79 atf_set "require.user" "root"
81 epair_ipv6_up_stress_body()
83 atf_skip "Quickly panics: page fault in in6_unlink_ifa (PR 225438)"
84 do_up_stress "epair" "6" ""
86 epair_ipv6_up_stress_cleanup()
91 atf_test_case faith_stress cleanup
94 atf_set "descr" "Simultaneously create and destroy a faith(4)"
95 atf_set "require.user" "root"
101 faith_stress_cleanup()
106 atf_test_case faith_up_stress cleanup
107 faith_up_stress_head()
109 atf_set "descr" "Simultaneously up and destroy a faith(4)"
110 atf_set "require.user" "root"
112 faith_up_stress_body()
114 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
115 do_up_stress "faith" "" ""
117 faith_up_stress_cleanup()
122 atf_test_case faith_ipv6_up_stress cleanup
123 faith_ipv6_up_stress_head()
125 atf_set "descr" "Simultaneously up and destroy a faith(4) with IPv6"
126 atf_set "require.user" "root"
128 faith_ipv6_up_stress_body()
130 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
131 do_up_stress "faith" "6" ""
133 faith_ipv6_up_stress_cleanup()
138 atf_test_case gif_stress cleanup
141 atf_set "descr" "Simultaneously create and destroy a gif(4)"
142 atf_set "require.user" "root"
153 atf_test_case gif_up_stress cleanup
156 atf_set "descr" "Simultaneously up and destroy a gif(4)"
157 atf_set "require.user" "root"
161 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
162 do_up_stress "gif" "" "p2p"
164 gif_up_stress_cleanup()
169 atf_test_case gif_ipv6_up_stress cleanup
170 gif_ipv6_up_stress_head()
172 atf_set "descr" "Simultaneously up and destroy a gif(4) with IPv6"
173 atf_set "require.user" "root"
175 gif_ipv6_up_stress_body()
177 atf_skip "Quickly panics: rt_tables_get_rnh_ptr: fam out of bounds."
178 do_up_stress "gif" "6" "p2p"
180 gif_ipv6_up_stress_cleanup()
185 atf_test_case lo_stress cleanup
188 atf_set "descr" "Simultaneously create and destroy an lo(4)"
189 atf_set "require.user" "root"
200 atf_test_case lo_up_stress cleanup
203 atf_set "descr" "Simultaneously up and destroy an lo(4)"
204 atf_set "require.user" "root"
208 atf_skip "Quickly panics: GPF in rtsock_routemsg"
209 do_up_stress "lo" "" ""
211 lo_up_stress_cleanup()
216 atf_test_case lo_ipv6_up_stress cleanup
217 lo_ipv6_up_stress_head()
219 atf_set "descr" "Simultaneously up and destroy an lo(4) with IPv6"
220 atf_set "require.user" "root"
222 lo_ipv6_up_stress_body()
224 atf_skip "Quickly panics: page fault in rtsock_addrmsg"
225 do_up_stress "lo" "6" ""
227 lo_ipv6_up_stress_cleanup()
232 atf_test_case tap_stress cleanup
235 atf_set "descr" "Simultaneously create and destroy a tap(4)"
236 atf_set "require.user" "root"
247 atf_test_case tap_up_stress cleanup
250 atf_set "descr" "Simultaneously up and destroy a tap(4)"
251 atf_set "require.user" "root"
255 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
256 do_up_stress "tap" "" ""
258 tap_up_stress_cleanup()
263 atf_test_case tap_ipv6_up_stress cleanup
264 tap_ipv6_up_stress_head()
266 atf_set "descr" "Simultaneously up and destroy a tap(4) with IPv6"
267 atf_set "require.user" "root"
269 tap_ipv6_up_stress_body()
271 atf_skip "Quickly panics: if_delmulti_locked: inconsistent ifp 0xfffff80150e44000"
272 do_up_stress "tap" "6" ""
274 tap_ipv6_up_stress_cleanup()
279 atf_test_case tun_stress cleanup
282 atf_set "descr" "Simultaneously create and destroy a tun(4)"
283 atf_set "require.user" "root"
294 atf_test_case tun_up_stress cleanup
297 atf_set "descr" "Simultaneously up and destroy a tun(4)"
298 atf_set "require.user" "root"
302 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
303 do_up_stress "tun" "" "p2p"
305 tun_up_stress_cleanup()
310 atf_test_case tun_ipv6_up_stress cleanup
311 tun_ipv6_up_stress_head()
313 atf_set "descr" "Simultaneously up and destroy a tun(4) with IPv6"
314 atf_set "require.user" "root"
316 tun_ipv6_up_stress_body()
318 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
319 do_up_stress "tun" "6" "p2p"
321 tun_ipv6_up_stress_cleanup()
326 atf_test_case vlan_stress cleanup
329 atf_set "descr" "Simultaneously create and destroy a vlan(4)"
330 atf_set "require.user" "root"
336 vlan_stress_cleanup()
341 atf_test_case vlan_up_stress cleanup
342 vlan_up_stress_head()
344 atf_set "descr" "Simultaneously up and destroy a vlan(4)"
345 atf_set "require.user" "root"
347 vlan_up_stress_body()
349 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
350 do_up_stress "vlan" "" ""
352 vlan_up_stress_cleanup()
357 atf_test_case vlan_ipv6_up_stress cleanup
358 vlan_ipv6_up_stress_head()
360 atf_set "descr" "Simultaneously up and destroy a vlan(4) with IPv6"
361 atf_set "require.user" "root"
363 vlan_ipv6_up_stress_body()
365 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
366 do_up_stress "vlan" "6" ""
368 vlan_ipv6_up_stress_cleanup()
373 atf_test_case vmnet_stress cleanup
376 atf_set "descr" "Simultaneously create and destroy a vmnet(4)"
377 atf_set "require.user" "root"
383 vmnet_stress_cleanup()
388 atf_test_case vmnet_up_stress cleanup
389 vmnet_up_stress_head()
391 atf_set "descr" "Simultaneously up and destroy a vmnet(4)"
392 atf_set "require.user" "root"
394 vmnet_up_stress_body()
396 do_up_stress "vmnet" "" ""
398 vmnet_up_stress_cleanup()
403 atf_test_case vmnet_ipv6_up_stress cleanup
404 vmnet_ipv6_up_stress_head()
406 atf_set "descr" "Simultaneously up and destroy a vmnet(4) with IPv6"
407 atf_set "require.user" "root"
409 vmnet_ipv6_up_stress_body()
411 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
412 do_up_stress "vmnet" "6" ""
414 vmnet_ipv6_up_stress_cleanup()
419 atf_init_test_cases()
421 atf_add_test_case epair_ipv6_up_stress
422 atf_add_test_case epair_stress
423 atf_add_test_case epair_up_stress
424 atf_add_test_case faith_ipv6_up_stress
425 atf_add_test_case faith_stress
426 atf_add_test_case faith_up_stress
427 atf_add_test_case gif_ipv6_up_stress
428 atf_add_test_case gif_stress
429 atf_add_test_case gif_up_stress
430 # Don't test lagg; it has its own test program
431 atf_add_test_case lo_ipv6_up_stress
432 atf_add_test_case lo_stress
433 atf_add_test_case lo_up_stress
434 atf_add_test_case tap_ipv6_up_stress
435 atf_add_test_case tap_stress
436 atf_add_test_case tap_up_stress
437 atf_add_test_case tun_ipv6_up_stress
438 atf_add_test_case tun_stress
439 atf_add_test_case tun_up_stress
440 atf_add_test_case vlan_ipv6_up_stress
441 atf_add_test_case vlan_stress
442 atf_add_test_case vlan_up_stress
443 atf_add_test_case vmnet_ipv6_up_stress
444 atf_add_test_case vmnet_stress
445 atf_add_test_case vmnet_up_stress
450 local IFACE CREATOR_PID DESTROYER_PID
454 # First thread: create the interface
456 ifconfig ${IFACE%a} create 2>/dev/null && \
457 echo -n . >> creator_count.txt
461 # Second thread: destroy the lagg
463 ifconfig $IFACE destroy 2>/dev/null && \
464 echo -n . >> destroyer_count.txt
471 echo "Created ${IFACE%a} `stat -f %z creator_count.txt` times."
472 echo "Destroyed it `stat -f %z destroyer_count.txt` times."
475 # Implement the up stress tests
477 # $1 Interface class, etc "lo" or "tap"
478 # $2 "6" to enable IPv6 auto address assignment, anything else otherwise
479 # $3 p2p for point to point interfaces, anything else for normal interfaces
482 local ADDR DSTADDR MASK MEAN_SLEEP_SECONDS MAX_SLEEP_USECS \
483 IFACE IPV6 P2P SRCDIR LOOP_PID ipv6_cmd up_cmd
485 # Configure the interface to use an RFC5737 nonrouteable addresses
489 # ifconfig takes about 10ms to run. To increase race coverage,
490 # randomly delay the two commands relative to each other by 5ms either
492 MEAN_SLEEP_SECONDS=.005
493 MAX_SLEEP_USECS=10000
499 SRCDIR=$( atf_get_srcdir )
500 if [ "$IPV6" = 6 ]; then
503 ipv6_cmd="ifconfig $IFACE inet6 ifdisabled"
505 if [ "$P2P" = "p2p" ]; then
506 up_cmd="ifconfig $IFACE up ${ADDR}/${MASK} ${DSTADDR}"
508 up_cmd="ifconfig $IFACE up ${ADDR}/${MASK}"
512 { sleep ${MEAN_SLEEP_SECONDS} && \
513 eval "$up_cmd" 2> /dev/null &&
514 echo -n . >> up_count.txt ; } &
515 { ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \
516 ifconfig $IFACE destroy &&
517 echo -n . >> destroy_count.txt ; } &
519 ifconfig ${IFACE%a} create
525 echo "Upped ${IFACE} `stat -f %z up_count.txt` times."
526 echo "Destroyed it `stat -f %z destroy_count.txt` times."
529 # Creates a new cloned interface, registers it for cleanup, and echoes it
530 # params: $1 Interface class name (tap, gif, etc)
537 while ! ifconfig ${CLASS}${N} create > /dev/null 2>&1; do
538 if [ "$N" -ge 8 ]; then
539 atf_skip "Could not create a ${CLASS} interface"
544 if [ ${CLASS} = "epair" ]; then
549 # Record the device so we can clean it up later
550 echo ${DEV} >> "devices_to_cleanup"
559 for DEV in `cat "devices_to_cleanup"`; do
560 ifconfig ${DEV} destroy