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"
52 epair_stress_cleanup()
57 atf_test_case epair_up_stress cleanup
58 epair_up_stress_head()
60 atf_set "descr" "Simultaneously up and detroy an epair(4)"
61 atf_set "require.user" "root"
63 epair_up_stress_body()
65 do_up_stress "epair" "" ""
67 epair_up_stress_cleanup()
72 atf_test_case epair_ipv6_up_stress cleanup
73 epair_ipv6_up_stress_head()
75 atf_set "descr" "Simultaneously up and destroy an epair(4) with IPv6"
76 atf_set "require.user" "root"
78 epair_ipv6_up_stress_body()
80 atf_skip "Quickly panics: page fault in in6_unlink_ifa (PR 225438)"
81 do_up_stress "epair" "6" ""
83 epair_ipv6_up_stress_cleanup()
88 atf_test_case faith_stress cleanup
91 atf_set "descr" "Simultaneously create and destroy a faith(4)"
92 atf_set "require.user" "root"
98 faith_stress_cleanup()
103 atf_test_case faith_up_stress cleanup
104 faith_up_stress_head()
106 atf_set "descr" "Simultaneously up and destroy a faith(4)"
107 atf_set "require.user" "root"
109 faith_up_stress_body()
111 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
112 do_up_stress "faith" "" ""
114 faith_up_stress_cleanup()
119 atf_test_case faith_ipv6_up_stress cleanup
120 faith_ipv6_up_stress_head()
122 atf_set "descr" "Simultaneously up and destroy a faith(4) with IPv6"
123 atf_set "require.user" "root"
125 faith_ipv6_up_stress_body()
127 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
128 do_up_stress "faith" "6" ""
130 faith_ipv6_up_stress_cleanup()
135 atf_test_case gif_stress cleanup
138 atf_set "descr" "Simultaneously create and destroy a gif(4)"
139 atf_set "require.user" "root"
150 atf_test_case gif_up_stress cleanup
153 atf_set "descr" "Simultaneously up and destroy a gif(4)"
154 atf_set "require.user" "root"
158 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
159 do_up_stress "gif" "" "p2p"
161 gif_up_stress_cleanup()
166 atf_test_case gif_ipv6_up_stress cleanup
167 gif_ipv6_up_stress_head()
169 atf_set "descr" "Simultaneously up and destroy a gif(4) with IPv6"
170 atf_set "require.user" "root"
172 gif_ipv6_up_stress_body()
174 atf_skip "Quickly panics: rt_tables_get_rnh_ptr: fam out of bounds."
175 do_up_stress "gif" "6" "p2p"
177 gif_ipv6_up_stress_cleanup()
182 atf_test_case lo_stress cleanup
185 atf_set "descr" "Simultaneously create and destroy an lo(4)"
186 atf_set "require.user" "root"
197 atf_test_case lo_up_stress cleanup
200 atf_set "descr" "Simultaneously up and destroy an lo(4)"
201 atf_set "require.user" "root"
205 atf_skip "Quickly panics: GPF in rtsock_routemsg"
206 do_up_stress "lo" "" ""
208 lo_up_stress_cleanup()
213 atf_test_case lo_ipv6_up_stress cleanup
214 lo_ipv6_up_stress_head()
216 atf_set "descr" "Simultaneously up and destroy an lo(4) with IPv6"
217 atf_set "require.user" "root"
219 lo_ipv6_up_stress_body()
221 atf_skip "Quickly panics: page fault in rtsock_addrmsg"
222 do_up_stress "lo" "6" ""
224 lo_ipv6_up_stress_cleanup()
229 atf_test_case tap_stress cleanup
232 atf_set "descr" "Simultaneously create and destroy a tap(4)"
233 atf_set "require.user" "root"
244 atf_test_case tap_up_stress cleanup
247 atf_set "descr" "Simultaneously up and destroy a tap(4)"
248 atf_set "require.user" "root"
252 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
253 do_up_stress "tap" "" ""
255 tap_up_stress_cleanup()
260 atf_test_case tap_ipv6_up_stress cleanup
261 tap_ipv6_up_stress_head()
263 atf_set "descr" "Simultaneously up and destroy a tap(4) with IPv6"
264 atf_set "require.user" "root"
266 tap_ipv6_up_stress_body()
268 atf_skip "Quickly panics: if_delmulti_locked: inconsistent ifp 0xfffff80150e44000"
269 do_up_stress "tap" "6" ""
271 tap_ipv6_up_stress_cleanup()
276 atf_test_case tun_stress cleanup
279 atf_set "descr" "Simultaneously create and destroy a tun(4)"
280 atf_set "require.user" "root"
291 atf_test_case tun_up_stress cleanup
294 atf_set "descr" "Simultaneously up and destroy a tun(4)"
295 atf_set "require.user" "root"
299 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
300 do_up_stress "tun" "" "p2p"
302 tun_up_stress_cleanup()
307 atf_test_case tun_ipv6_up_stress cleanup
308 tun_ipv6_up_stress_head()
310 atf_set "descr" "Simultaneously up and destroy a tun(4) with IPv6"
311 atf_set "require.user" "root"
313 tun_ipv6_up_stress_body()
315 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
316 do_up_stress "tun" "6" "p2p"
318 tun_ipv6_up_stress_cleanup()
323 atf_test_case vlan_stress cleanup
326 atf_set "descr" "Simultaneously create and destroy a vlan(4)"
327 atf_set "require.user" "root"
333 vlan_stress_cleanup()
338 atf_test_case vlan_up_stress cleanup
339 vlan_up_stress_head()
341 atf_set "descr" "Simultaneously up and destroy a vlan(4)"
342 atf_set "require.user" "root"
344 vlan_up_stress_body()
346 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
347 do_up_stress "vlan" "" ""
349 vlan_up_stress_cleanup()
354 atf_test_case vlan_ipv6_up_stress cleanup
355 vlan_ipv6_up_stress_head()
357 atf_set "descr" "Simultaneously up and destroy a vlan(4) with IPv6"
358 atf_set "require.user" "root"
360 vlan_ipv6_up_stress_body()
362 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
363 do_up_stress "vlan" "6" ""
365 vlan_ipv6_up_stress_cleanup()
370 atf_test_case vmnet_stress cleanup
373 atf_set "descr" "Simultaneously create and destroy a vmnet(4)"
374 atf_set "require.user" "root"
380 vmnet_stress_cleanup()
385 atf_test_case vmnet_up_stress cleanup
386 vmnet_up_stress_head()
388 atf_set "descr" "Simultaneously up and destroy a vmnet(4)"
389 atf_set "require.user" "root"
391 vmnet_up_stress_body()
393 do_up_stress "vmnet" "" ""
395 vmnet_up_stress_cleanup()
400 atf_test_case vmnet_ipv6_up_stress cleanup
401 vmnet_ipv6_up_stress_head()
403 atf_set "descr" "Simultaneously up and destroy a vmnet(4) with IPv6"
404 atf_set "require.user" "root"
406 vmnet_ipv6_up_stress_body()
408 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
409 do_up_stress "vmnet" "6" ""
411 vmnet_ipv6_up_stress_cleanup()
416 atf_init_test_cases()
418 atf_add_test_case epair_ipv6_up_stress
419 atf_add_test_case epair_stress
420 atf_add_test_case epair_up_stress
421 atf_add_test_case faith_ipv6_up_stress
422 atf_add_test_case faith_stress
423 atf_add_test_case faith_up_stress
424 atf_add_test_case gif_ipv6_up_stress
425 atf_add_test_case gif_stress
426 atf_add_test_case gif_up_stress
427 # Don't test lagg; it has its own test program
428 atf_add_test_case lo_ipv6_up_stress
429 atf_add_test_case lo_stress
430 atf_add_test_case lo_up_stress
431 atf_add_test_case tap_ipv6_up_stress
432 atf_add_test_case tap_stress
433 atf_add_test_case tap_up_stress
434 atf_add_test_case tun_ipv6_up_stress
435 atf_add_test_case tun_stress
436 atf_add_test_case tun_up_stress
437 atf_add_test_case vlan_ipv6_up_stress
438 atf_add_test_case vlan_stress
439 atf_add_test_case vlan_up_stress
440 atf_add_test_case vmnet_ipv6_up_stress
441 atf_add_test_case vmnet_stress
442 atf_add_test_case vmnet_up_stress
447 local IFACE CREATOR_PID DESTROYER_PID
451 # First thread: create the interface
453 ifconfig ${IFACE%a} create 2>/dev/null && \
454 echo -n . >> creator_count.txt
458 # Second thread: destroy the lagg
460 ifconfig $IFACE destroy 2>/dev/null && \
461 echo -n . >> destroyer_count.txt
468 echo "Created ${IFACE%a} `stat -f %z creator_count.txt` times."
469 echo "Destroyed it `stat -f %z destroyer_count.txt` times."
472 # Implement the up stress tests
474 # $1 Interface class, etc "lo" or "tap"
475 # $2 "6" to enable IPv6 auto address assignment, anything else otherwise
476 # $3 p2p for point to point interfaces, anything else for normal interfaces
479 local ADDR DSTADDR MASK MEAN_SLEEP_SECONDS MAX_SLEEP_USECS \
480 IFACE IPV6 P2P SRCDIR LOOP_PID ipv6_cmd up_cmd
482 # Configure the interface to use an RFC5737 nonrouteable addresses
486 # ifconfig takes about 10ms to run. To increase race coverage,
487 # randomly delay the two commands relative to each other by 5ms either
489 MEAN_SLEEP_SECONDS=.005
490 MAX_SLEEP_USECS=10000
496 SRCDIR=$( atf_get_srcdir )
497 if [ "$IPV6" = 6 ]; then
500 ipv6_cmd="ifconfig $IFACE inet6 ifdisabled"
502 if [ "$P2P" = "p2p" ]; then
503 up_cmd="ifconfig $IFACE up ${ADDR}/${MASK} ${DSTADDR}"
505 up_cmd="ifconfig $IFACE up ${ADDR}/${MASK}"
509 { sleep ${MEAN_SLEEP_SECONDS} && \
510 eval "$up_cmd" 2> /dev/null &&
511 echo -n . >> up_count.txt ; } &
512 { ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \
513 ifconfig $IFACE destroy &&
514 echo -n . >> destroy_count.txt ; } &
516 ifconfig ${IFACE%a} create
522 echo "Upped ${IFACE} `stat -f %z up_count.txt` times."
523 echo "Destroyed it `stat -f %z destroy_count.txt` times."
526 # Creates a new cloned interface, registers it for cleanup, and echoes it
527 # params: $1 Interface class name (tap, gif, etc)
534 while ! ifconfig ${CLASS}${N} create > /dev/null 2>&1; do
535 if [ "$N" -ge 8 ]; then
536 atf_skip "Could not create a ${CLASS} interface"
541 if [ ${CLASS} = "epair" ]; then
546 # Record the device so we can clean it up later
547 echo ${DEV} >> "devices_to_cleanup"
556 for DEV in `cat "devices_to_cleanup"`; do
557 ifconfig ${DEV} destroy