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 faith_stress cleanup
45 atf_set "descr" "Simultaneously create and destroy a faith(4)"
46 atf_set "require.user" "root"
52 faith_stress_cleanup()
57 atf_test_case faith_up_stress cleanup
58 faith_up_stress_head()
60 atf_set "descr" "Simultaneously up and destroy a faith(4)"
61 atf_set "require.user" "root"
63 faith_up_stress_body()
65 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
66 do_up_stress "faith" "" ""
68 faith_up_stress_cleanup()
73 atf_test_case faith_ipv6_up_stress cleanup
74 faith_ipv6_up_stress_head()
76 atf_set "descr" "Simultaneously up and destroy a faith(4) with IPv6"
77 atf_set "require.user" "root"
79 faith_ipv6_up_stress_body()
81 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
82 do_up_stress "faith" "6" ""
84 faith_ipv6_up_stress_cleanup()
89 atf_test_case gif_stress cleanup
92 atf_set "descr" "Simultaneously create and destroy a gif(4)"
93 atf_set "require.user" "root"
104 atf_test_case gif_up_stress cleanup
107 atf_set "descr" "Simultaneously up and destroy a gif(4)"
108 atf_set "require.user" "root"
112 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
113 do_up_stress "gif" "" "p2p"
115 gif_up_stress_cleanup()
120 atf_test_case gif_ipv6_up_stress cleanup
121 gif_ipv6_up_stress_head()
123 atf_set "descr" "Simultaneously up and destroy a gif(4) with IPv6"
124 atf_set "require.user" "root"
126 gif_ipv6_up_stress_body()
128 atf_skip "Quickly panics: rt_tables_get_rnh_ptr: fam out of bounds."
129 do_up_stress "gif" "6" "p2p"
131 gif_ipv6_up_stress_cleanup()
136 atf_test_case lo_stress cleanup
139 atf_set "descr" "Simultaneously create and destroy an lo(4)"
140 atf_set "require.user" "root"
151 atf_test_case lo_up_stress cleanup
154 atf_set "descr" "Simultaneously up and destroy an lo(4)"
155 atf_set "require.user" "root"
159 atf_skip "Quickly panics: GPF in rtsock_routemsg"
160 do_up_stress "lo" "" ""
162 lo_up_stress_cleanup()
167 atf_test_case lo_ipv6_up_stress cleanup
168 lo_ipv6_up_stress_head()
170 atf_set "descr" "Simultaneously up and destroy an lo(4) with IPv6"
171 atf_set "require.user" "root"
173 lo_ipv6_up_stress_body()
175 atf_skip "Quickly panics: page fault in rtsock_addrmsg"
176 do_up_stress "lo" "6" ""
178 lo_ipv6_up_stress_cleanup()
183 atf_test_case tap_stress cleanup
186 atf_set "descr" "Simultaneously create and destroy a tap(4)"
187 atf_set "require.user" "root"
198 atf_test_case tap_up_stress cleanup
201 atf_set "descr" "Simultaneously up and destroy a tap(4)"
202 atf_set "require.user" "root"
206 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
207 do_up_stress "tap" "" ""
209 tap_up_stress_cleanup()
214 atf_test_case tap_ipv6_up_stress cleanup
215 tap_ipv6_up_stress_head()
217 atf_set "descr" "Simultaneously up and destroy a tap(4) with IPv6"
218 atf_set "require.user" "root"
220 tap_ipv6_up_stress_body()
222 atf_skip "Quickly panics: if_delmulti_locked: inconsistent ifp 0xfffff80150e44000"
223 do_up_stress "tap" "6" ""
225 tap_ipv6_up_stress_cleanup()
230 atf_test_case tun_stress cleanup
233 atf_set "descr" "Simultaneously create and destroy a tun(4)"
234 atf_set "require.user" "root"
245 atf_test_case tun_up_stress cleanup
248 atf_set "descr" "Simultaneously up and destroy a tun(4)"
249 atf_set "require.user" "root"
253 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
254 do_up_stress "tun" "" "p2p"
256 tun_up_stress_cleanup()
261 atf_test_case tun_ipv6_up_stress cleanup
262 tun_ipv6_up_stress_head()
264 atf_set "descr" "Simultaneously up and destroy a tun(4) with IPv6"
265 atf_set "require.user" "root"
267 tun_ipv6_up_stress_body()
269 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
270 do_up_stress "tun" "6" "p2p"
272 tun_ipv6_up_stress_cleanup()
277 atf_test_case vlan_stress cleanup
280 atf_set "descr" "Simultaneously create and destroy a vlan(4)"
281 atf_set "require.user" "root"
287 vlan_stress_cleanup()
292 atf_test_case vlan_up_stress cleanup
293 vlan_up_stress_head()
295 atf_set "descr" "Simultaneously up and destroy a vlan(4)"
296 atf_set "require.user" "root"
298 vlan_up_stress_body()
300 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
301 do_up_stress "vlan" "" ""
303 vlan_up_stress_cleanup()
308 atf_test_case vlan_ipv6_up_stress cleanup
309 vlan_ipv6_up_stress_head()
311 atf_set "descr" "Simultaneously up and destroy a vlan(4) with IPv6"
312 atf_set "require.user" "root"
314 vlan_ipv6_up_stress_body()
316 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
317 do_up_stress "vlan" "6" ""
319 vlan_ipv6_up_stress_cleanup()
324 atf_test_case vmnet_stress cleanup
327 atf_set "descr" "Simultaneously create and destroy a vmnet(4)"
328 atf_set "require.user" "root"
334 vmnet_stress_cleanup()
339 atf_test_case vmnet_up_stress cleanup
340 vmnet_up_stress_head()
342 atf_set "descr" "Simultaneously up and destroy a vmnet(4)"
343 atf_set "require.user" "root"
345 vmnet_up_stress_body()
347 do_up_stress "vmnet" "" ""
349 vmnet_up_stress_cleanup()
354 atf_test_case vmnet_ipv6_up_stress cleanup
355 vmnet_ipv6_up_stress_head()
357 atf_set "descr" "Simultaneously up and destroy a vmnet(4) with IPv6"
358 atf_set "require.user" "root"
360 vmnet_ipv6_up_stress_body()
362 atf_skip "Quickly panics: if_freemulti: protospec not NULL"
363 do_up_stress "vmnet" "6" ""
365 vmnet_ipv6_up_stress_cleanup()
370 atf_init_test_cases()
372 # TODO: add epair(4) tests, which need a different syntax
373 atf_add_test_case faith_ipv6_up_stress
374 atf_add_test_case faith_stress
375 atf_add_test_case faith_up_stress
376 atf_add_test_case gif_ipv6_up_stress
377 atf_add_test_case gif_stress
378 atf_add_test_case gif_up_stress
379 # Don't test lagg; it has its own test program
380 atf_add_test_case lo_ipv6_up_stress
381 atf_add_test_case lo_stress
382 atf_add_test_case lo_up_stress
383 atf_add_test_case tap_ipv6_up_stress
384 atf_add_test_case tap_stress
385 atf_add_test_case tap_up_stress
386 atf_add_test_case tun_ipv6_up_stress
387 atf_add_test_case tun_stress
388 atf_add_test_case tun_up_stress
389 atf_add_test_case vlan_ipv6_up_stress
390 atf_add_test_case vlan_stress
391 atf_add_test_case vlan_up_stress
392 atf_add_test_case vmnet_ipv6_up_stress
393 atf_add_test_case vmnet_stress
394 atf_add_test_case vmnet_up_stress
403 # First thread: create the interface
405 ifconfig $IFACE create 2>/dev/null && \
406 echo -n . >> creator_count.txt
410 # Second thread: destroy the lagg
412 ifconfig $IFACE destroy 2>/dev/null && \
413 echo -n . >> destroyer_count.txt
420 echo "Created $IFACE `stat -f %z creator_count.txt` times."
421 echo "Destroyed it `stat -f %z destroyer_count.txt` times."
424 # Implement the up stress tests
426 # $1 Interface class, etc "lo" or "tap"
427 # $2 "6" to enable IPv6 auto address assignment, anything else otherwise
428 # $3 p2p for point to point interfaces, anything else for normal interfaces
431 local IFACE IPv6 MAC P2P SRCDIR
433 # Configure the interface to use an RFC5737 nonrouteable addresses
437 # ifconfig takes about 10ms to run. To increase race coverage,
438 # randomly delay the two commands relative to each other by 5ms either
440 MEAN_SLEEP_SECONDS=.005
441 MAX_SLEEP_USECS=10000
447 SRCDIR=$( atf_get_srcdir )
448 if [ "$IPV6" = 6 ]; then
451 ipv6_cmd="ifconfig $IFACE inet6 ifdisabled"
453 if [ "$P2P" = "p2p" ]; then
454 up_cmd="ifconfig $IFACE up ${ADDR}/${MASK} ${DSTADDR}"
456 up_cmd="ifconfig $IFACE up ${ADDR}/${MASK}"
460 { sleep ${MEAN_SLEEP_SECONDS} && \
461 eval "$up_cmd" 2> /dev/null &&
462 echo -n . >> up_count.txt ; } &
463 { ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \
464 ifconfig $IFACE destroy &&
465 echo -n . >> destroy_count.txt ; } &
467 ifconfig $IFACE create
473 echo "Upped ${IFACE} `stat -f %z up_count.txt` times."
474 echo "Destroyed it `stat -f %z destroy_count.txt` times."
477 # Creates a new cloned interface, registers it for cleanup, and echoes it
478 # params: $1 Interface class name (tap, gif, etc)
485 while ! ifconfig ${CLASS}${N} create > /dev/null 2>&1; do
486 if [ "$N" -ge 8 ]; then
487 atf_skip "Could not create a ${CLASS} interface"
492 local DEV=${CLASS}${N}
493 # Record the device so we can clean it up later
494 echo ${DEV} >> "devices_to_cleanup"
503 for DEV in `cat "devices_to_cleanup"`; do
504 if [ ${DEV%%[0-9]*a} = "epair" ]; then
505 ifconfig ${DEV}a destroy
507 ifconfig ${DEV} destroy