Who designs these APIs, anyway?
[invirt/packages/invirt-xen-config.git] / vif-invirtroute
index e8b5eb8..c24741e 100755 (executable)
@@ -33,15 +33,16 @@ main_ip=$(dom0_ip)
 dev=${dev:-${vif}}
 intfname=${dev}
 
+brname=dom${vif#vif}
 if [ ${dev} != ${vif} ]; then
     # This is an HVM and it has two interfaces, so we'll set up a bridge.
-    brname=dom${vif#vif}
+    dobridge=yes
     intfname=${brname}
 fi
 
 case "$command" in
     online)
-       if [ $brname ]; then
+       if [ $dobridge ]; then
             create_bridge ${brname}
             setup_bridge_port ${dev}
             setup_bridge_port ${vif}
@@ -57,11 +58,9 @@ case "$command" in
         cmdprefix=''
         ;;
     offline)
-       if [ $brname ]; then
-            do_without_error brctl delif ${brname} ${vif}
-            do_without_error brctl delif ${brname} ${dev}
-            do_without_error ifconfig ${brname} down
-       fi
+        do_without_error brctl delif ${brname} ${vif}
+        do_without_error brctl delif ${brname} ${dev}
+        do_without_error ifconfig ${brname} down
         ipcmd='del'
         cmdprefix='do_without_error'
         ;;
@@ -86,7 +85,7 @@ if [  ${vif_type} != "ioemu"  -o  x${qemu_online} = xyes ] ; then
     fi
 fi
 
-if [[ "$command" == "offline" && -n "$brname" ]]
+if [ "$command" == "offline" ]
 then
     do_without_error brctl delbr ${brname}
 fi