6 killall pltap-ovs 2>/dev/null || true
10 function is_switch_running
12 ovs-appctl version >/dev/null 2>&1
16 error "Usage: ${0##*/} <IP/PREFIX>"
19 # TODO: check paramether validity
26 # ensure ovs-vswitchd is running
27 if ! is_switch_running; then
28 echo "ovs-vswitchd not running" >&2
33 # check whether the address is already assigned
35 TAPNAME=$(ip addr show to "$IP/32" | perl -ne '/^\s*\d+:\s*([\w-]+):/ && print $1')
36 if [ ! -z "$TAPNAME" ]; then
37 if ovs-vsctl br-exists "$TAPNAME"; then
41 error "$IP already assigned to $TAPNAME"
50 while ! ip link show up | egrep -q "^[0-9]+: +$TAPNAME:"; do
51 echo "Waiting for $TAPNAME to come UP..." >&2
54 ovs-vsctl add-br $TAPNAME -- set bridge $TAPNAME datapath_type=planetlab