Index: stable/11/etc/mtree/BSD.tests.dist =================================================================== --- stable/11/etc/mtree/BSD.tests.dist (revision 332603) +++ stable/11/etc/mtree/BSD.tests.dist (revision 332604) @@ -1,750 +1,752 @@ # $FreeBSD$ # # Please see the file src/etc/mtree/README before making changes to this file. # /set type=dir uname=root gname=wheel mode=0755 . bin cat .. chflags .. chmod .. date .. dd .. echo .. expr .. ln .. ls .. mkdir .. mv .. pax .. pkill .. pwait .. rcp .. rmdir .. sh builtins .. errors .. execution .. expansion .. parameters .. parser .. set-e .. .. sleep .. test .. .. cddl lib .. sbin .. usr.bin ctfconvert .. .. usr.sbin dtrace common aggs .. arithmetic .. arrays .. assocs .. begin .. bitfields .. buffering .. builtinvar .. cg .. clauses .. cpc .. decls .. drops .. dtraceUtil .. end .. enum .. error .. exit .. fbtprovider .. funcs .. grammar .. include .. inline .. io .. ip .. java_api .. json .. lexer .. llquantize .. mdb .. mib .. misc .. multiaggs .. offsetof .. operators .. pid .. plockstat .. pointers .. pragma .. predicates .. preprocessor .. print .. printa .. printf .. privs .. probes .. proc .. profile-n .. providers .. raise .. rates .. safety .. scalars .. sched .. scripting .. sdt .. sizeof .. speculation .. stability .. stack .. stackdepth .. stop .. strlen .. strtoll .. struct .. syscall .. sysevent .. tick-n .. trace .. tracemem .. translators .. typedef .. types .. uctf .. union .. usdt .. ustack .. vars .. version .. .. .. zfsd .. .. .. etc rc.d .. .. games .. gnu lib .. usr.bin diff .. .. .. lib atf libatf-c detail .. .. libatf-c++ detail .. .. test-programs .. .. libarchive .. libc c063 .. db .. gen execve .. posix_spawn .. .. hash data .. .. iconv .. inet .. locale .. net getaddrinfo data .. .. .. nss .. regex data .. .. resolv .. rpc .. ssp .. setjmp .. stdio .. stdlib .. string .. sys .. time .. tls dso .. .. termios .. ttyio .. .. libcam .. libcasper services cap_dns .. cap_grp .. cap_pwd .. cap_sysctl .. .. .. libcrypt .. libdevdctl .. libkvm .. libmp .. libnv .. libpam .. libproc .. librt .. libsbuf .. libthr dlopen .. .. libutil .. libxo .. msun .. .. libexec atf atf-check .. atf-sh .. .. rtld-elf .. .. sbin dhclient .. devd .. growfs .. ifconfig .. mdconfig .. .. secure lib .. libexec .. usr.bin .. usr.sbin .. .. share examples tests atf .. plain .. tap .. .. .. zoneinfo .. .. sys acl .. aio .. fifo .. file .. fs tmpfs .. .. geom class concat .. eli .. gate .. gpt .. mirror .. nop .. part .. raid3 .. shsec .. stripe .. uzip etalon .. .. .. .. kern acct .. execve .. pipe .. .. kqueue libkqueue .. .. mac bsdextended .. portacl .. .. mqueue .. + net + .. netinet .. opencrypto .. pjdfstest chflags .. chmod .. chown .. ftruncate .. granular .. link .. mkdir .. mkfifo .. mknod .. open .. rename .. rmdir .. symlink .. truncate .. unlink .. .. posixshm .. sys .. vfs .. vm .. .. usr.bin apply .. basename .. bmake archives fmt_44bsd .. fmt_44bsd_mod .. fmt_oldbsd .. .. basic t0 .. t1 .. t2 .. t3 .. .. execution ellipsis .. empty .. joberr .. plus .. .. shell builtin .. meta .. path .. path_select .. replace .. select .. .. suffixes basic .. src_wild1 .. src_wild2 .. .. syntax directive-t0 .. enl .. funny-targets .. semi .. .. sysmk t0 2 1 .. .. mk .. .. t1 2 1 .. .. mk .. .. t2 2 1 .. .. mk .. .. .. variables modifier_M .. modifier_t .. opt_V .. t0 .. .. .. bsdcat .. calendar .. cmp .. compress .. cpio .. col .. comm .. cut .. dirname .. du .. file2c .. fold .. getconf .. grep .. gzip .. head .. hexdump .. ident .. indent .. join .. jot .. lastcomm .. limits .. m4 .. mkimg .. ncal .. opensm .. pr .. printf .. procstat .. rs .. sdiff .. sed regress.multitest.out .. .. soelim .. stat .. tail .. tar .. timeout .. tr .. truncate .. units .. uudecode .. uuencode .. uniq .. xargs .. xinstall .. xo .. yacc yacc .. .. .. usr.sbin chown .. etcupdate .. extattr .. fstyp .. makefs .. newsyslog .. nmtree .. pw .. rpcbind .. sa .. .. .. # vim: set expandtab ts=4 sw=4: Index: stable/11/tests/sys/net/Makefile =================================================================== --- stable/11/tests/sys/net/Makefile (nonexistent) +++ stable/11/tests/sys/net/Makefile (revision 332604) @@ -0,0 +1,21 @@ +# $FreeBSD$ + +.include + +TESTSDIR= ${TESTSBASE}/sys/net +BINDIR= ${TESTSDIR} + +ATF_TESTS_SH+= if_lagg_test +ATF_TESTS_SH+= if_clone_test + +# The tests are written to be run in parallel, but doing so leads to random +# panics. I think it's because the kernel's list of interfaces isn't properly +# locked. +TEST_METADATA+= is_exclusive=true + +MAN= +PROG= randsleep + +WARNS?= 6 + +.include Property changes on: stable/11/tests/sys/net/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/tests/sys/net/if_clone_test.sh =================================================================== --- stable/11/tests/sys/net/if_clone_test.sh (nonexistent) +++ stable/11/tests/sys/net/if_clone_test.sh (revision 332604) @@ -0,0 +1,511 @@ +# +# Copyright (c) 2014 Spectra Logic Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions, and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# substantially similar to the "NO WARRANTY" disclaimer below +# ("Disclaimer") and any redistribution must be conditioned upon +# including a substantially similar Disclaimer requirement for further +# binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. +# +# Authors: Alan Somers (Spectra Logic Corporation) +# +# $FreeBSD$ + +# Outline: +# For each cloned interface type, do three tests +# 1) Create and destroy it +# 2) Create, up, and destroy it +# 3) Create, disable IPv6 auto address assignment, up, and destroy it + +TESTLEN=10 # seconds + +atf_test_case faith_stress cleanup +faith_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy a faith(4)" + atf_set "require.user" "root" +} +faith_stress_body() +{ + do_stress "faith" +} +faith_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case faith_up_stress cleanup +faith_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a faith(4)" + atf_set "require.user" "root" +} +faith_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "faith" "" "" +} +faith_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case faith_ipv6_up_stress cleanup +faith_ipv6_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a faith(4) with IPv6" + atf_set "require.user" "root" +} +faith_ipv6_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "faith" "6" "" +} +faith_ipv6_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case gif_stress cleanup +gif_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy a gif(4)" + atf_set "require.user" "root" +} +gif_stress_body() +{ + do_stress "gif" +} +gif_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case gif_up_stress cleanup +gif_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a gif(4)" + atf_set "require.user" "root" +} +gif_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "gif" "" "p2p" +} +gif_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case gif_ipv6_up_stress cleanup +gif_ipv6_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a gif(4) with IPv6" + atf_set "require.user" "root" +} +gif_ipv6_up_stress_body() +{ + atf_skip "Quickly panics: rt_tables_get_rnh_ptr: fam out of bounds." + do_up_stress "gif" "6" "p2p" +} +gif_ipv6_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case lo_stress cleanup +lo_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy an lo(4)" + atf_set "require.user" "root" +} +lo_stress_body() +{ + do_stress "lo" +} +lo_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case lo_up_stress cleanup +lo_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy an lo(4)" + atf_set "require.user" "root" +} +lo_up_stress_body() +{ + atf_skip "Quickly panics: GPF in rtsock_routemsg" + do_up_stress "lo" "" "" +} +lo_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case lo_ipv6_up_stress cleanup +lo_ipv6_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy an lo(4) with IPv6" + atf_set "require.user" "root" +} +lo_ipv6_up_stress_body() +{ + atf_skip "Quickly panics: page fault in rtsock_addrmsg" + do_up_stress "lo" "6" "" +} +lo_ipv6_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case tap_stress cleanup +tap_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy a tap(4)" + atf_set "require.user" "root" +} +tap_stress_body() +{ + do_stress "tap" +} +tap_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case tap_up_stress cleanup +tap_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a tap(4)" + atf_set "require.user" "root" +} +tap_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "tap" "" "" +} +tap_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case tap_ipv6_up_stress cleanup +tap_ipv6_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a tap(4) with IPv6" + atf_set "require.user" "root" +} +tap_ipv6_up_stress_body() +{ + atf_skip "Quickly panics: if_delmulti_locked: inconsistent ifp 0xfffff80150e44000" + do_up_stress "tap" "6" "" +} +tap_ipv6_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case tun_stress cleanup +tun_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy a tun(4)" + atf_set "require.user" "root" +} +tun_stress_body() +{ + do_stress "tun" +} +tun_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case tun_up_stress cleanup +tun_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a tun(4)" + atf_set "require.user" "root" +} +tun_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "tun" "" "p2p" +} +tun_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case tun_ipv6_up_stress cleanup +tun_ipv6_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a tun(4) with IPv6" + atf_set "require.user" "root" +} +tun_ipv6_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "tun" "6" "p2p" +} +tun_ipv6_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case vlan_stress cleanup +vlan_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy a vlan(4)" + atf_set "require.user" "root" +} +vlan_stress_body() +{ + do_stress "vlan" +} +vlan_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case vlan_up_stress cleanup +vlan_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a vlan(4)" + atf_set "require.user" "root" +} +vlan_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "vlan" "" "" +} +vlan_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case vlan_ipv6_up_stress cleanup +vlan_ipv6_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a vlan(4) with IPv6" + atf_set "require.user" "root" +} +vlan_ipv6_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "vlan" "6" "" +} +vlan_ipv6_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case vmnet_stress cleanup +vmnet_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy a vmnet(4)" + atf_set "require.user" "root" +} +vmnet_stress_body() +{ + do_stress "vmnet" +} +vmnet_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case vmnet_up_stress cleanup +vmnet_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a vmnet(4)" + atf_set "require.user" "root" +} +vmnet_up_stress_body() +{ + do_up_stress "vmnet" "" "" +} +vmnet_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_test_case vmnet_ipv6_up_stress cleanup +vmnet_ipv6_up_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a vmnet(4) with IPv6" + atf_set "require.user" "root" +} +vmnet_ipv6_up_stress_body() +{ + atf_skip "Quickly panics: if_freemulti: protospec not NULL" + do_up_stress "vmnet" "6" "" +} +vmnet_ipv6_up_stress_cleanup() +{ + cleanup_ifaces +} + +atf_init_test_cases() +{ + # TODO: add epair(4) tests, which need a different syntax + atf_add_test_case faith_ipv6_up_stress + atf_add_test_case faith_stress + atf_add_test_case faith_up_stress + atf_add_test_case gif_ipv6_up_stress + atf_add_test_case gif_stress + atf_add_test_case gif_up_stress + # Don't test lagg; it has its own test program + atf_add_test_case lo_ipv6_up_stress + atf_add_test_case lo_stress + atf_add_test_case lo_up_stress + atf_add_test_case tap_ipv6_up_stress + atf_add_test_case tap_stress + atf_add_test_case tap_up_stress + atf_add_test_case tun_ipv6_up_stress + atf_add_test_case tun_stress + atf_add_test_case tun_up_stress + atf_add_test_case vlan_ipv6_up_stress + atf_add_test_case vlan_stress + atf_add_test_case vlan_up_stress + atf_add_test_case vmnet_ipv6_up_stress + atf_add_test_case vmnet_stress + atf_add_test_case vmnet_up_stress +} + +do_stress() +{ + local IFACE + + IFACE=`get_iface $1` + + # First thread: create the interface + while true; do + ifconfig $IFACE create 2>/dev/null && \ + echo -n . >> creator_count.txt + done & + CREATOR_PID=$! + + # Second thread: destroy the lagg + while true; do + ifconfig $IFACE destroy 2>/dev/null && \ + echo -n . >> destroyer_count.txt + done & + DESTROYER_PID=$! + + sleep ${TESTLEN} + kill $CREATOR_PID + kill $DESTROYER_PID + echo "Created $IFACE `stat -f %z creator_count.txt` times." + echo "Destroyed it `stat -f %z destroyer_count.txt` times." +} + +# Implement the up stress tests +# Parameters +# $1 Interface class, etc "lo" or "tap" +# $2 "6" to enable IPv6 auto address assignment, anything else otherwise +# $3 p2p for point to point interfaces, anything else for normal interfaces +do_up_stress() +{ + local IFACE IPv6 MAC P2P SRCDIR + + # Configure the interface to use an RFC5737 nonrouteable addresses + ADDR="192.0.2.2" + DSTADDR="192.0.2.3" + MASK="24" + # ifconfig takes about 10ms to run. To increase race coverage, + # randomly delay the two commands relative to each other by 5ms either + # way. + MEAN_SLEEP_SECONDS=.005 + MAX_SLEEP_USECS=10000 + + IFACE=`get_iface $1` + IPV6=$2 + P2P=$3 + + SRCDIR=$( atf_get_srcdir ) + if [ "$IPV6" = 6 ]; then + ipv6_cmd="true" + else + ipv6_cmd="ifconfig $IFACE inet6 ifdisabled" + fi + if [ "$P2P" = "p2p" ]; then + up_cmd="ifconfig $IFACE up ${ADDR}/${MASK} ${DSTADDR}" + else + up_cmd="ifconfig $IFACE up ${ADDR}/${MASK}" + fi + while true; do + eval "$ipv6_cmd" + { sleep ${MEAN_SLEEP_SECONDS} && \ + eval "$up_cmd" 2> /dev/null && + echo -n . >> up_count.txt ; } & + { ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \ + ifconfig $IFACE destroy && + echo -n . >> destroy_count.txt ; } & + wait + ifconfig $IFACE create + done & + LOOP_PID=$! + + sleep ${TESTLEN} + kill $LOOP_PID + echo "Upped ${IFACE} `stat -f %z up_count.txt` times." + echo "Destroyed it `stat -f %z destroy_count.txt` times." +} + +# Creates a new cloned interface, registers it for cleanup, and echoes it +# params: $1 Interface class name (tap, gif, etc) +get_iface() +{ + local CLASS DEV N + + CLASS=$1 + N=0 + while ! ifconfig ${CLASS}${N} create > /dev/null 2>&1; do + if [ "$N" -ge 8 ]; then + atf_skip "Could not create a ${CLASS} interface" + else + N=$(($N + 1)) + fi + done + local DEV=${CLASS}${N} + # Record the device so we can clean it up later + echo ${DEV} >> "devices_to_cleanup" + echo ${DEV} +} + + +cleanup_ifaces() +{ + local DEV + + for DEV in `cat "devices_to_cleanup"`; do + if [ ${DEV%%[0-9]*a} = "epair" ]; then + ifconfig ${DEV}a destroy + else + ifconfig ${DEV} destroy + fi + done + true +} Property changes on: stable/11/tests/sys/net/if_clone_test.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/tests/sys/net/if_lagg_test.sh =================================================================== --- stable/11/tests/sys/net/if_lagg_test.sh (nonexistent) +++ stable/11/tests/sys/net/if_lagg_test.sh (revision 332604) @@ -0,0 +1,466 @@ +# +# Copyright (c) 2014 Spectra Logic Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions, and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# substantially similar to the "NO WARRANTY" disclaimer below +# ("Disclaimer") and any redistribution must be conditioned upon +# including a substantially similar Disclaimer requirement for further +# binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGES. +# +# Authors: Alan Somers (Spectra Logic Corporation) +# +# $FreeBSD$ + +atf_test_case create cleanup +create_head() +{ + atf_set "descr" "Create a lagg and assign an address" + atf_set "require.user" "root" +} +create_body() +{ + local TAP0 TAP1 LAGG MAC + + # Configure the lagg interface to use an RFC5737 nonrouteable addresses + ADDR="192.0.2.2" + MASK="24" + + TAP0=`get_tap` + TAP1=`get_tap` + LAGG=`get_lagg` + + # Create the lagg + ifconfig $TAP0 up + ifconfig $TAP1 up + atf_check ifconfig $LAGG up laggport $TAP0 laggport $TAP1 \ + ${ADDR}/${MASK} + atf_check -o match:"inet ${ADDR}" ifconfig $LAGG + atf_check -o match:"laggport: ${TAP0}" ifconfig $LAGG + atf_check -o match:"laggport: ${TAP1}" ifconfig $LAGG + + # Check that all members have the same MAC + MAC=`ifconfig $LAGG | awk '/ether/ {print $2}'` + atf_check -o match:"ether ${MAC}" ifconfig $TAP0 + atf_check -o match:"ether ${MAC}" ifconfig $TAP1 + + # Check that no members have an IPv6 link-local address. IPv6 + # link-local addresses should never be merged in any way to prevent + # scope violation. + atf_check -o not-match:"inet6 fe80:" ifconfig $TAP0 + atf_check -o not-match:"inet6 fe80:" ifconfig $TAP1 +} +create_cleanup() +{ + cleanup_tap_and_lagg +} + +atf_test_case status_stress cleanup +status_stress_head() +{ + atf_set "descr" "Simultaneously query a lagg while also creating or destroying it." + atf_set "require.user" "root" +} +status_stress_body() +{ + local TAP0 TAP1 LAGG MAC + + # Configure the lagg interface to use an RFC5737 nonrouteable addresses + ADDR="192.0.2.2" + MASK="24" + + TAP0=`get_tap` + TAP1=`get_tap` + TAP2=`get_tap` + TAP3=`get_tap` + LAGG=`get_lagg` + + # Up the lagg's children + ifconfig $TAP0 inet6 ifdisabled up + ifconfig $TAP1 inet6 ifdisabled up + ifconfig $TAP2 inet6 ifdisabled up + ifconfig $TAP3 inet6 ifdisabled up + + # First thread: create and destroy the lagg + while true; do + ifconfig $LAGG destroy 2>&1 + ifconfig $LAGG create 2>/dev/null + ifconfig $LAGG inet6 ifdisabled + ifconfig $LAGG up laggport $TAP0 laggport $TAP1 laggport $TAP2\ + laggport $TAP3 ${ADDR}/${MASK} 2>/dev/null + echo -n . >> creator_count.txt + done & + CREATOR_PID=$! + + # Second thread: Query the lagg's status + while true; do + ifconfig -am 2> /dev/null > /dev/null + echo -n . >> querier_count.txt + done & + QUERIER_PID=$! + + sleep 60 + kill $CREATOR_PID + kill $QUERIER_PID + echo "Created the lagg `stat -f %z creator_count.txt` times." + echo "Queried its status `stat -f %z querier_count.txt` times" +} +status_stress_cleanup() +{ + cleanup_tap_and_lagg +} + +atf_test_case create_destroy_stress cleanup +create_destroy_stress_head() +{ + atf_set "descr" "Simultaneously create and destroy a lagg" + atf_set "require.user" "root" +} +create_destroy_stress_body() +{ + local TAP0 TAP1 LAGG MAC + + atf_skip "Skipping this test because it easily panics the machine" + + TAP0=`get_tap` + TAP1=`get_tap` + TAP2=`get_tap` + TAP3=`get_tap` + LAGG=`get_lagg` + + # Up the lagg's children + ifconfig $TAP0 inet6 ifdisabled up + ifconfig $TAP1 inet6 ifdisabled up + ifconfig $TAP2 inet6 ifdisabled up + ifconfig $TAP3 inet6 ifdisabled up + + # First thread: create the lagg + while true; do + ifconfig $LAGG create 2>/dev/null && \ + echo -n . >> creator_count.txt + done & + CREATOR_PID=$! + + # Second thread: destroy the lagg + while true; do + ifconfig $LAGG destroy 2>/dev/null && \ + echo -n . >> destroyer_count.txt + done & + DESTROYER_PID=$! + + sleep 60 + kill $CREATOR_PID + kill $DESTROYER_PID + echo "Created the lagg `stat -f %z creator_count.txt` times." + echo "Destroyed it `stat -f %z destroyer_count.txt` times." +} +create_destroy_stress_cleanup() +{ + cleanup_tap_and_lagg +} + +# This test regresses a panic that is particular to LACP. If the child's link +# state changes while the lagg is being destroyed, lacp_linkstate can +# use-after-free. The problem is compounded by two factors: +# 1) In SpectraBSD, downing the parent will also down the child +# 2) The cxgbe driver will show the link state as "no carrier" as soon as you +# down the interface. +# TeamTrack: P2_30328 +atf_test_case lacp_linkstate_destroy_stress cleanup +lacp_linkstate_destroy_stress_head() +{ + atf_set "descr" "Simultaneously destroy an LACP lagg and change its childrens link states" + atf_set "require.user" "root" +} +lacp_linkstate_destroy_stress_body() +{ + local TAP0 TAP1 LAGG MAC SRCDIR + + # Configure the lagg interface to use an RFC5737 nonrouteable addresses + ADDR="192.0.2.2" + MASK="24" + # ifconfig takes about 10ms to run. To increase race coverage, + # randomly delay the two commands relative to each other by 5ms either + # way. + MEAN_SLEEP_SECONDS=.005 + MAX_SLEEP_USECS=10000 + + TAP0=`get_tap` + TAP1=`get_tap` + LAGG=`get_lagg` + + # Up the lagg's children + ifconfig $TAP0 inet6 ifdisabled up + ifconfig $TAP1 inet6 ifdisabled up + + SRCDIR=$( atf_get_srcdir ) + while true; do + ifconfig $LAGG inet6 ifdisabled + # We must open the tap devices to change their link states + cat /dev/$TAP0 > /dev/null & + CAT0_PID=$! + cat /dev/$TAP1 > /dev/null & + CAT1_PID=$! + ifconfig $LAGG up laggport $TAP0 laggport $TAP1 \ + ${ADDR}/${MASK} 2> /dev/null && + { sleep ${MEAN_SLEEP_SECONDS} && \ + kill $CAT0_PID && + kill $CAT1_PID && + echo -n . >> linkstate_count.txt ; } & + { ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \ + ifconfig $LAGG destroy && + echo -n . >> destroy_count.txt ; } & + wait + ifconfig $LAGG create + done & + LOOP_PID=$! + + sleep 60 + kill $LOOP_PID + echo "Disconnected the children `stat -f %z linkstate_count.txt` times." + echo "Destroyed the lagg `stat -f %z destroy_count.txt` times." +} +lacp_linkstate_destroy_stress_cleanup() +{ + cleanup_tap_and_lagg +} + +atf_test_case up_destroy_stress cleanup +up_destroy_stress_head() +{ + atf_set "descr" "Simultaneously up and destroy a lagg" + atf_set "require.user" "root" +} +up_destroy_stress_body() +{ + local TAP0 TAP1 LAGG MAC SRCDIR + + atf_skip "Skipping this test because it panics the machine fairly often" + + # Configure the lagg interface to use an RFC5737 nonrouteable addresses + ADDR="192.0.2.2" + MASK="24" + # ifconfig takes about 10ms to run. To increase race coverage, + # randomly delay the two commands relative to each other by 5ms either + # way. + MEAN_SLEEP_SECONDS=.005 + MAX_SLEEP_USECS=10000 + + TAP0=`get_tap` + TAP1=`get_tap` + TAP2=`get_tap` + TAP3=`get_tap` + LAGG=`get_lagg` + + # Up the lagg's children + ifconfig $TAP0 inet6 ifdisabled up + ifconfig $TAP1 inet6 ifdisabled up + ifconfig $TAP2 inet6 ifdisabled up + ifconfig $TAP3 inet6 ifdisabled up + + SRCDIR=$( atf_get_srcdir ) + while true; do + ifconfig $LAGG inet6 ifdisabled + { sleep ${MEAN_SLEEP_SECONDS} && \ + ifconfig $LAGG up laggport $TAP0 laggport $TAP1 \ + laggport $TAP2 laggport $TAP3 \ + ${ADDR}/${MASK} 2> /dev/null && + echo -n . >> up_count.txt ; } & + { ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \ + ifconfig $LAGG destroy && + echo -n . >> destroy_count.txt ; } & + wait + ifconfig $LAGG create + done & + LOOP_PID=$! + + sleep 60 + kill $LOOP_PID + echo "Upped the lagg `stat -f %z up_count.txt` times." + echo "Destroyed it `stat -f %z destroy_count.txt` times." +} +up_destroy_stress_cleanup() +{ + cleanup_tap_and_lagg +} + +atf_test_case set_ether cleanup +set_ether_head() +{ + atf_set "descr" "Set a lagg's ethernet address" + atf_set "require.user" "root" +} +set_ether_body() +{ + local TAP0 TAP1 LAGG MAC + + # Configure the lagg interface to use an RFC5737 nonrouteable addresses + ADDR="192.0.2.2" + MASK="24" + MAC="00:11:22:33:44:55" + + TAP0=`get_tap` + TAP1=`get_tap` + LAGG=`get_lagg` + + # Create the lagg + ifconfig $TAP0 up + ifconfig $TAP1 up + atf_check ifconfig $LAGG up laggport $TAP0 laggport $TAP1 \ + ${ADDR}/${MASK} + + # Change the lagg's ethernet address + atf_check ifconfig $LAGG ether ${MAC} + + # Check that all members have the same MAC + atf_check -o match:"ether ${MAC}" ifconfig $LAGG + atf_check -o match:"ether ${MAC}" ifconfig $TAP0 + atf_check -o match:"ether ${MAC}" ifconfig $TAP1 +} +set_ether_cleanup() +{ + cleanup_tap_and_lagg +} + +atf_test_case updown cleanup +updown_head() +{ + atf_set "descr" "upping or downing a lagg ups or downs its children" + atf_set "require.user" "root" +} +updown_body() +{ + local TAP0 TAP1 LAGG MAC + + atf_expect_fail "PR 226144 Upping a lagg interrface should automatically up its children" + # Configure the lagg interface to use an RFC5737 nonrouteable addresses + ADDR="192.0.2.2" + MASK="24" + MAC="00:11:22:33:44:55" + + TAP0=`get_tap` + TAP1=`get_tap` + LAGG=`get_lagg` + + # Create the lagg + ifconfig $TAP0 up + ifconfig $TAP1 up + atf_check ifconfig $LAGG up laggport $TAP0 laggport $TAP1 \ + ${ADDR}/${MASK} + + # Down the lagg + ifconfig $LAGG down + atf_check -o not-match:"flags=.*\" ifconfig $LAGG + atf_check -o not-match:"flags=.*\" ifconfig $TAP0 + atf_check -o not-match:"flags=.*\" ifconfig $TAP1 + # Up the lagg again + ifconfig $LAGG up + atf_check -o match:"flags=.*\" ifconfig $LAGG + atf_check -o match:"flags=.*\" ifconfig $TAP0 + atf_check -o match:"flags=.*\" ifconfig $TAP1 + + # Check that no members have acquired an IPv6 link-local address by + # virtue of being upped. IPv6 link-local addresses should never be + # merged in any way to prevent scope violation. + atf_check -o not-match:"inet6 fe80:" ifconfig $TAP0 + atf_check -o not-match:"inet6 fe80:" ifconfig $TAP1 +} +updown_cleanup() +{ + cleanup_tap_and_lagg +} + +# Check for lock-order reversals. For best results, this test should be run +# last. +atf_test_case witness +witness_head() +{ + atf_set "descr" "Check witness(4) for lock-order reversals in if_lagg" +} +witness_body() +{ + if [ `sysctl -n debug.witness.watch` -ne 1 ]; then + atf_skip "witness(4) is not enabled" + fi + if `sysctl -n debug.witness.badstacks | grep -q 'at lagg_'`; then + sysctl debug.witness.badstacks + atf_fail "Lock-order reversals involving if_lagg.c detected" + fi +} + +atf_init_test_cases() +{ + atf_add_test_case create + atf_add_test_case create_destroy_stress + atf_add_test_case lacp_linkstate_destroy_stress + atf_add_test_case set_ether + atf_add_test_case status_stress + atf_add_test_case up_destroy_stress + atf_add_test_case updown + # For best results, keep the witness test last + atf_add_test_case witness +} + + +# Creates a new tap(4) interface, registers it for cleanup, and echoes it +get_tap() +{ + local TAPN=0 + while ! ifconfig tap${TAPN} create > /dev/null 2>&1; do + if [ "$TAPN" -ge 8 ]; then + atf_skip "Could not create a tap(4) interface" + else + TAPN=$(($TAPN + 1)) + fi + done + local TAPD=tap${TAPN} + # Record the TAP device so we can clean it up later + echo ${TAPD} >> "devices_to_cleanup" + echo ${TAPD} +} + +# Creates a new lagg(4) interface, registers it for cleanup, and echoes it +get_lagg() +{ + local LAGGN=0 + while ! ifconfig lagg${LAGGN} create > /dev/null 2>&1; do + if [ "$LAGGN" -ge 8 ]; then + atf_skip "Could not create a lagg(4) interface" + else + LAGGN=$(($LAGGN + 1)) + fi + done + local LAGGD=lagg${LAGGN} + # Record the lagg device so we can clean it up later + echo ${LAGGD} >> "devices_to_cleanup" + echo ${LAGGD} +} + +cleanup_tap_and_lagg() +{ + local DEV + + for DEV in `cat "devices_to_cleanup"`; do + ifconfig ${DEV} destroy + done + true +} Property changes on: stable/11/tests/sys/net/if_lagg_test.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11/tests/sys/net/randsleep.c =================================================================== --- stable/11/tests/sys/net/randsleep.c (nonexistent) +++ stable/11/tests/sys/net/randsleep.c (revision 332604) @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014 Spectra Logic Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * Authors: Alan Somers (Spectra Logic Corporation) + * + * $FreeBSD$ + */ + +#include +#include +#include +#include + +#define RANDOM_MAX ((1<<31) - 1) + +int main(int argc, char** argv){ + useconds_t max_usecs, usecs; + double frac; + + if (argc != 2) { + printf("Usage: randsleep \n"); + exit(2); + } + + errno = 0; + max_usecs = (useconds_t)strtol(argv[1], NULL, 0); + if (errno != 0) { + perror("strtol"); + exit(1); + } + srandomdev(); + frac = (double)random() / (double)RANDOM_MAX; + usecs = (useconds_t)((double)max_usecs * frac); + usleep(usecs); + + return (0); +} Property changes on: stable/11/tests/sys/net/randsleep.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/11 =================================================================== --- stable/11 (revision 332603) +++ stable/11 (revision 332604) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r329874