Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / bridge / tests / functest
bloba321c59d997164452cbceaac05ac44a9cb98b874
1 #! /bin/bash
2 BR=${1:-"br549"}
3 ETH=${2:-"eth0"}
4 maxports=${3:-1000}
6 echo "Ethernet Bridge functional test"
8 echo -n "Testing kernel: " ; uname -a
9 echo -n "Utilities: " ; brctl -V
11 # fetch ip of working $ETH
12 IP=`/sbin/ifconfig $ETH | sed -n -e 's/^.*inet addr:\([0-9][0-9\.]*\).*$/\1/p'`
13 echo "Using IP address $IP"
15 # All commands in this part must succeed
16 set -e
18 echo "0. Creating $maxports dummy devices"
19 modprobe dummy numdummies=$maxports
21 echo "1. Creating bridge $BR"
22 brctl addbr $BR
23 brctl stp $BR on
25 echo "2. Add $ETH"
26 ifconfig $ETH 0.0.0.0
27 brctl addif $BR $ETH
29 echo "3. Bring up bridge"
30 ifconfig $BR $IP
32 echo "4 Bring up another bridge"
33 brctl addbr "brx%d"
34 ifconfig brx0 1.1.1.1
36 echo "5 Bring down bridge"
37 ifconfig brx0 down
38 brctl delbr brx0
40 echo -n "6. Add " $maxports " ports:"
41 for (( i=1; i < $maxports; i++))
43 brctl addif $BR dummy$i
44 if [[ $(( $i % 10 )) -eq 10 ]]
45 then echo -n '.'
47 done
48 echo
50 echo -n "7. Delete those ports:"
51 for (( i=1; i < $maxports; i++))
53 brctl delif $BR dummy$i
54 if [[ $(( $i % 10 )) -eq 10 ]]
55 then echo -n '.'
57 done
58 echo
60 echo "8. Notififer cases"
61 brctl addif $BR dummy0
63 echo "8a Device down"
64 ifconfig dummy0 down
66 echo "8b Change device address"
67 ifconfig dummy0 hw ether 00:0d:02:03:04:05
69 echo "8c. Device up"
70 ifconfig dummy0 up
72 echo "8d Unregister device (slow)"
73 rmmod dummy
74 echo "** Done"
76 modprobe dummy numdummies=2
78 set +e
80 echo "10 Error cases"
81 echo -n " duplicate bridge - "
82 brctl addbr $BR
84 echo -n " bridge to bridge - "
85 brctl addbr brTmp
86 brctl addif $BR brTmp
88 echo -n " already in other bridge - "
89 brctl addif brTmp $ETH
91 echo -n " already in this bridge - "
92 brctl addif $BR $ETH
94 echo -n " remove from wrong bridge - "
95 brctl delif brTmp $ETH
96 brctl delbr brTmp
98 echo -n " remove bridge $ETH - "
99 brctl delbr $ETH
101 echo -n " remove bridge bogus - "
102 brctl delbr bogus
104 echo -n " remove still active bridge - "
105 brctl delbr $BR
107 echo -n " zero hw address - "
108 ifconfig dummy0 hw ether 00:00:00:00:00:00
109 brctl addif $BR dummy0
111 echo -n " duplicate hw address - "
112 ifconfig dummy0 hw ether 00:0d:01:00:00:00
113 ifconfig dummy1 hw ether 00:0d:01:00:00:00
114 brctl addif $BR dummy0
115 brctl addif $BR dummy1
116 # leave dummy0 for next test.
118 echo "10 Tuning"
119 set -e
120 brctl stp $BR off
121 brctl stp $BR on
122 brctl setageing $BR 4000
123 brctl setbridgeprio $BR 1
124 brctl setfd $BR 120
125 brctl sethello $BR 20
126 brctl setmaxage $BR 1000
127 brctl setpathcost $BR dummy0 50
128 brctl setportprio $BR dummy0 2
130 echo "Status check"
131 brctl show
132 read -p "Ok?"
133 brctl showstp $BR
134 read -p "Ok?"
135 brctl showmacs $BR
136 read -p "Ok?"
139 echo "30 Shutdown"
140 ifconfig $BR down
141 brctl delbr $BR
142 ifconfig $ETH $IP
144 echo "31 Remove bridge module"
145 rmmod bridge
146 rmmod dummy
147 rmmod bridge
149 echo "32 Check for dead bridge cleanup"
150 brctl addbr $BR
151 rmmod bridge
152 modprobe bridge
153 sleep 1
155 echo "33 Remove module with race"
156 brctl addbr $BR
157 ifconfig $BR 9.9.9.9
159 rmmod --wait bridge &
160 sleep 2
161 brctl addbr brXX
162 if ifconfig brXX 1.1.1.1 ; then
163 echo "?? ifconfig succeeded"
164 ifconfig brXX down
167 ifconfig $BR down
168 wait
170 echo "*** Done ***"