From owner-svn-src-projects@FreeBSD.ORG Thu Jul 26 15:29:08 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0FDD10657A7; Thu, 26 Jul 2012 15:29:08 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D0828FC14; Thu, 26 Jul 2012 15:29:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6QFT8AC098355; Thu, 26 Jul 2012 15:29:08 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6QFT82r098354; Thu, 26 Jul 2012 15:29:08 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201207261529.q6QFT82r098354@svn.freebsd.org> From: Monthadar Al Jaberi Date: Thu, 26 Jul 2012 15:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238809 - projects/net80211_testsuite/wtap/009 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jul 2012 15:29:08 -0000 Author: monthadar Date: Thu Jul 26 15:29:08 2012 New Revision: 238809 URL: http://svn.freebsd.org/changeset/base/238809 Log: Added test 009 - test mesh peer code w/ ACL policy. Added: projects/net80211_testsuite/wtap/009/ projects/net80211_testsuite/wtap/009/test.sh (contents, props changed) Added: projects/net80211_testsuite/wtap/009/test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/net80211_testsuite/wtap/009/test.sh Thu Jul 26 15:29:08 2012 (r238809) @@ -0,0 +1,198 @@ +#!/bin/sh + +# This program requires: +# + wtap - to create/destroy the wtap instances +# + vis_map - to setup the visibility map between wtap instances +# + vimage - to configure/destroy vtap nodes + +# The name of the test that will be printed in the begining +TEST_NBR="009" +TEST_NAME="test mesh peer code w/ ACL policy" + +# Return value from this test, 0 success failure otherwise +TEST_RESULT=127 + +# The number of nodes to test +NBR_NODES=2 + +# The subnet prefix +IP_SUBNET="192.168.2." + +cmd() +{ + echo "***${TEST_NBR}*** " $* + $* +} + +info() +{ + echo "***${TEST_NBR}*** " $* +} + +descr() +{ + cat < B + +* node A filters out B with ACL deny policy +* node B should not flood with PEER OPEN + +EOL +} + +setup() +{ + # Initialize output file + info "TEST: ${TEST_NAME}" + info `date` + + # load mac ACL policy + cmd kldload wlan_acl + + # Create wtap/vimage nodes + for i in `seq 1 ${NBR_NODES}`; do + wtap_if="`expr $i - 1`" + info "Setup: vimage $i - wtap$wtap_if" + cmd vimage -c $i + cmd wtap c $wtap_if + done + + # Set visibility for each node to see the + # next node. + n="`expr ${NBR_NODES} - 1`" + for i in `seq 0 ${n}`; do + j="`expr ${i} + 1`" + cmd vis_map a $i $j + cmd vis_map a $j $i + done + + # Makes the visibility map plugin deliver packets to resp. dest. + cmd vis_map o + + # Create each wlan subinterface, place into the correct vnet + for i in `seq 0 ${n}`; do + vnet="`expr ${i} + 1`" + cmd ifconfig wlan${i} create wlandev wtap${i} wlanmode mesh + if [ ${i} = 0 ]; then + cmd ifconfig wlan${i} mac:add 00:98:9a:98:96:98 + cmd ifconfig wlan${i} mac:deny + fi + cmd ifconfig wlan${i} meshid mymesh + cmd wlandebug -i wlan${i} mesh + cmd ifconfig wlan${i} vnet ${vnet} + cmd jexec ${vnet} ifconfig wlan${i} up + cmd jexec ${vnet} ifconfig wlan${i} inet ${IP_SUBNET}${vnet} + done +} + +run() +{ + NBR_TESTS=1 NBR_FAIL=0 + + cmd sleep 10 + n="`expr ${NBR_NODES} - 1`" + for i in `seq 0 ${n}`; do + vnet="`expr ${i} + 1`" + cmd cat /dev/wtap${i} > wtap${i}.debug + done + TMP=`cat wtap${i}.debug | grep "send PEER OPEN" | wc -l` + + if [ $TMP -gt "3" ]; then # 3 is just random, should read from sysctl. + info "node B is flooding!" + NBR_FAIL="`expr ${NBR_FAIL} + 1`" + fi + + if [ $NBR_FAIL = 0 ]; then + info "ALL TESTS PASSED" + TEST_RESULT=0 + else + info "FAILED ${NBR_FAIL} of ${NBR_TESTS} TESTS" + fi +} + +teardown() +{ + cmd vis_map c + # Unlink all links + # XXX: this is a limitation of the current plugin, + # no way to reset vis_map without unload wtap. + n="`expr ${NBR_NODES} - 1`" + for i in `seq 0 ${n}`; do + j="`expr ${i} + 1`" + cmd vis_map d $i $j + cmd vis_map d $j $i + done + n="`expr ${NBR_NODES} - 1`" + for i in `seq 0 ${n}`; do + vnet="`expr ${i} + 1`" + cmd cat /dev/wtap${i} >> wtap${i}.debug + cmd jexec ${vnet} ifconfig wlan${i} destroy + done + for i in `seq 1 ${NBR_NODES}`; do + wtap_if="`expr $i - 1`" + cmd wtap d ${wtap_if} + cmd vimage -d ${i} + done + + # unload mac ACL policy + cmd kldunload wlan_acl + + exit ${TEST_RESULT} +} + +EXEC_SETUP=0 +EXEC_RUN=0 +EXEC_TEARDOWN=0 +while [ "$#" -gt "0" ] +do + case $1 in + 'all') + EXEC_SETUP=1 + EXEC_RUN=1 + EXEC_TEARDOWN=1 + ;; + 'setup') + EXEC_SETUP=1 + ;; + 'run') + EXEC_RUN=1 + ;; + 'teardown') + EXEC_TEARDOWN=1 + ;; + 'descr') + descr + exit 0 + ;; + *) + echo "$0 {all | setup | run | teardown | descr}" + exit 127 + ;; + esac + shift +done + +if [ $EXEC_SETUP = 1 ]; then + setup +fi +if [ $EXEC_RUN = 1 ]; then + run +fi +if [ $EXEC_TEARDOWN = 1 ]; then + teardown +fi + +exit 0 +