-
Notifications
You must be signed in to change notification settings - Fork 54
HwsimTestTemplate
jcard0na edited this page Nov 19, 2012
·
2 revisions
#! /bin/bash
# Test template for open80211s tests using mac80211_hwsim
#
# Copyright (c) 2008-2012 cozybit Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
NUM_PHYS=4
modprobe -rq mac80211_hwsim
modprobe mac80211_hwsim radios=$NUM_PHYS
mount -t debugfs | grep debugfs &> /dev/null || mount -t debugfs null /sys/kernel/debug
PHYS=`find /sys/kernel/debug/ieee80211 -name hwsim | cut -d/ -f 6 | sort`
i=0
for phy in ${PHYS}; do
# Force a linear topology
echo $((3 << i)) > /sys/kernel/debug/ieee80211/$phy/hwsim/group
if [ $i == 0 ]
then
# The usual stuff
iw phy ${phy} interface add mesh${i} type mesh
ifconfig mesh${i} hw ether 42:00:00:00:0${i}:00
ip address add dev mesh${i} 192.168.77.$((10 + i))/24
ip link set mesh${i} up
iw dev mesh${i} mesh join bazooka
else
# This interface will live under a separate network namespace
# bound to a different shell
echo iw phy ${phy} set netns \$BASHPID > mesh${i}_up_in_netns.sh
# ^^^^ This does not work anymore ^^^
# we cannot pull phy's from a different namespace only push
# them, which requires knowing the target PID in advance :(
echo iw phy ${phy} interface add mesh${i} type mesh >> mesh${i}_up_in_netns.sh
echo ifconfig mesh${i} hw ether 42:00:00:00:0${i}:00 >> mesh${i}_up_in_netns.sh
echo ip address add dev mesh${i} 192.168.77.$((10 + i))/24 >> mesh${i}_up_in_netns.sh
echo ip link set mesh${i} up >> mesh${i}_up_in_netns.sh
echo iw dev mesh${i} mesh join bazooka >> mesh${i}_up_in_netns.sh
echo sleep 10000 >> mesh${i}_up_in_netns.sh
unshare -n -- /bin/bash mesh${i}_up_in_netns.sh & &> /dev/null
NETNS_PID[i]=$!
fi
i=$((i+1))
done
ping 192.168.77.13 -W 5 -c 1 | grep '1 received' &> /dev/null || { echo FAIL; exit -1; }
for pid in ${NETNS_PID[*]}; do kill $pid; done
echo PASS