]> xenbits.xensource.com Git - people/tklengyel/xen.git/commitdiff
tools/hotplug/Linux: Use correct device name for vifs in setup scripts
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 11 Feb 2011 18:21:35 +0000 (18:21 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 11 Feb 2011 18:21:35 +0000 (18:21 +0000)
In vif-common.sh, set the shell variable "dev" to the new interface
name when interfaces are renamed, and consistently use this variable
in all the vif scripts.

This fixes hotplug of renamed interfaces.

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
From: Patrick Scharrenberg <pittipatti@web.de>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Patrick Scharrenberg <pittipatti@web.de>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/hotplug/Linux/vif-common.sh
tools/hotplug/Linux/vif-nat
tools/hotplug/Linux/vif-route

index 76ad0f8c76a5ff1d7c33028374c6c43e5b510ba1..c9c5d41da0cc864c975852b70858ae3cf8ef91c8 100644 (file)
@@ -69,16 +69,16 @@ esac
 if [ "$type_if" = vif ]; then
     # Check presence of compulsory args.
     XENBUS_PATH="${XENBUS_PATH:?}"
-    vif="${vif:?}"
+    dev="${dev:?}"
 
     vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "")
     if [ "$vifname" ]
     then
         if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null
         then
-            do_or_die ip link set "$vif" name "$vifname"
+            do_or_die ip link set "$dev" name "$vifname"
         fi
-        vif="$vifname"
+        dev="$vifname"
     fi
 elif [ "$type_if" = tap ]; then
     # Check presence of compulsory args.
@@ -105,9 +105,9 @@ frob_iptable()
     local c="-D"
   fi
 
-  iptables "$c" FORWARD -m physdev --physdev-is-bridged --physdev-in "$vif" \
+  iptables "$c" FORWARD -m physdev --physdev-is-bridged --physdev-in "$dev" \
     "$@" -j ACCEPT 2>/dev/null &&
-  iptables "$c" FORWARD -m physdev --physdev-is-bridged --physdev-out "$vif" \
+  iptables "$c" FORWARD -m physdev --physdev-is-bridged --physdev-out "$dev" \
     -j ACCEPT 2>/dev/null
 
   if [ "$command" == "online" -a $? -ne 0 ]
index 74743ed7611b01c44bc3a2329a55221a8547e054..9082cc96bbb29c5a5cd164eb410d6f9958df4de3 100644 (file)
@@ -12,7 +12,7 @@
 # vif-nat (add|remove|online|offline)
 #
 # Environment vars:
-# vif         vif interface name (required).
+# dev         vif interface name (required).
 # XENBUS_PATH path to this device's details in the XenStore (required).
 #
 # Parameters:
@@ -98,7 +98,7 @@ fi
 dhcparg_remove_entry()
 {
   local tmpfile=$(mktemp)
-  sed -e "s/$vif //" "$dhcpd_arg_file" >"$tmpfile"
+  sed -e "s/${dev} //" "$dhcpd_arg_file" >"$tmpfile"
   if diff "$tmpfile" "$dhcpd_arg_file" >/dev/null
   then
     rm "$tmpfile"
@@ -112,11 +112,11 @@ dhcparg_add_entry()
   dhcparg_remove_entry
   local tmpfile=$(mktemp)
   # handle Red Hat, SUSE, and Debian styles, with or without quotes
-  sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"$vif "'"/' \
+  sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
      "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
-  sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"$vif "'"/' \
+  sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' \
      "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
-  sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"$vif "'"/' \
+  sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
      "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
   rm -f "$tmpfile"
 }
@@ -164,28 +164,28 @@ dhcp_down()
 
 case "$command" in
     online)
-        if ip route | grep -q "dev $vif"
+        if ip route | grep -q "dev ${dev}"
         then
-          log debug "$vif already up"
+          log debug "${dev} already up"
           exit 0
         fi
 
-        do_or_die ip link set "$vif" up arp on
-        do_or_die ip addr add "$router_ip" dev "$vif"
-        do_or_die ip route add "$vif_ip" dev "$vif" src "$router_ip"
-        echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
+        do_or_die ip link set "${dev}" up arp on
+        do_or_die ip addr add "$router_ip" dev "${dev}"
+        do_or_die ip route add "$vif_ip" dev "${dev}" src "$router_ip"
+        echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
         [ "$dhcp" != 'no' ] && dhcp_up
         ;;
     offline)
         [ "$dhcp" != 'no' ] && dhcp_down
-        do_without_error ifconfig "$vif" down
+        do_without_error ifconfig "${dev}" down
         ;;
 esac
 
 
 handle_iptable
 
-log debug "Successful vif-nat $command for $vif."
+log debug "Successful vif-nat $command for ${dev}."
 if [ "$command" = "online" ]
 then
   success
index 0cacfcb99ec4a0a9304f669c4d7dfa81f0ff3547..6c5587afd5ccdddeaed20f8d1094f485e3d9ac4e 100644 (file)
@@ -12,7 +12,7 @@
 # vif-route (add|remove|online|offline)
 #
 # Environment vars:
-# vif         vif interface name (required).
+# dev         vif interface name (required).
 # XENBUS_PATH path to this device's details in the XenStore (required).
 #
 # Read from the store:
 #============================================================================
 
 dir=$(dirname "$0")
-. "$dir/vif-common.sh"
+. "${dir}/vif-common.sh"
 
 main_ip=$(dom0_ip)
 
-case "$command" in
+case "${command}" in
     online)
-        ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up
-        echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
+        ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
+        echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
         ipcmd='add'
         cmdprefix=''
         ;;
     offline)
-        do_without_error ifdown ${vif}
+        do_without_error ifdown ${dev}
         ipcmd='del'
         cmdprefix='do_without_error'
         ;;
@@ -43,14 +43,14 @@ if [ "${ip}" ] ; then
     # If we've been given a list of IP addresses, then add routes from dom0 to
     # the guest using those addresses.
     for addr in ${ip} ; do
-      ${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip}
-    done 
+      ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip}
+    done
 fi
 
 handle_iptable
 
-log debug "Successful vif-route $command for $vif."
-if [ "$command" = "online" ]
+log debug "Successful vif-route ${command} for ${dev}."
+if [ "${command}" = "online" ]
 then
   success
 fi