ia64/xen-unstable

changeset 11312:0cecfb11b76b

[TOOLS] Clean up routed vifs quietly on domain destruction.

I have experienced that the vif-route script does not work as expected
when deleting a virtual interface (Redhat FC5). Both of the commands
"ifdown" and "ip route" cause an early vif-route script exit and
therefore will cause skipping of the later script commands (such as
cleaning up iptables entries for the default 'antispoof'). The
vif-route
script creates the following syslog error entry:
"/etc/xen/scripts/vif-route failed; error detected."

It appears that both of the problematic commands are actually
redundant
when destroying domains:
1. the interface is already gone (I assume because the domain frontend
is gone already) --> ifdown does not do anything
2. the route is gone as well since the interface has disappeared -->
ip
route del does not do anything

Executing those redundant commands with "do_without_error" ensures
that
the script completes and cleans up iptables rules. The attached
RFC-patch only masks those commands when bringing down an interface,
so
that domain creation continues to fail in case of vif setup problems
(intended behavior).

Having the iptables cleanup called correctly by vif-route is important
to keep the iptables rule-set clean, otherwise antispoof rules
accumulate with every vif creation.

Signed-off by: Reiner Sailer <sailer@us.ibm.com>
author kaf24@localhost.localdomain
date Mon Aug 28 12:41:15 2006 +0100 (2006-08-28)
parents b61b7478b324
children 439fa5d6c5ce
files tools/examples/vif-route
line diff
     1.1 --- a/tools/examples/vif-route	Mon Aug 28 12:35:43 2006 +0100
     1.2 +++ b/tools/examples/vif-route	Mon Aug 28 12:41:15 2006 +0100
     1.3 @@ -30,10 +30,12 @@ case "$command" in
     1.4          ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up
     1.5          echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
     1.6          ipcmd='add'
     1.7 +        cmdprefix=''
     1.8          ;;
     1.9      offline)
    1.10 -        ifdown ${vif}
    1.11 +        do_without_error ifdown ${vif}
    1.12          ipcmd='del'
    1.13 +        cmdprefix='do_without_error'
    1.14          ;;
    1.15  esac
    1.16  
    1.17 @@ -41,7 +43,7 @@ if [ "${ip}" ] ; then
    1.18      # If we've been given a list of IP addresses, then add routes from dom0 to
    1.19      # the guest using those addresses.
    1.20      for addr in ${ip} ; do
    1.21 -      ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip}
    1.22 +      ${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip}
    1.23      done 
    1.24  fi
    1.25