ia64/xen-unstable

view tools/examples/vif-route @ 7827:60bf9aa39043

Have the vif scripts expect the offline event, not the remove event. With
the remove event, the script environment variable has disappeared, so we must
hook on the offline event instead. This fix was put into xen-backend.rules,
but not the vif scripts, so they were out of sync, and the interfaces were not
being properly closed down.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Tue Nov 15 15:56:47 2005 +0100 (2005-11-15)
parents e2e7f47e6f79
children 801c6363501b
line source
1 #!/bin/sh
2 #============================================================================
3 # /etc/xen/vif-route
4 #
5 # Script for configuring a vif in routed mode.
6 # The hotplugging system will call this script if it is specified either in
7 # the device configuration given to Xend, or the default Xend configuration
8 # in /etc/xen/xend-config.sxp. If the script is specified in neither of those
9 # places, then vif-bridge is the default.
10 #
11 # Usage:
12 # vif-route (add|remove|online|offline)
13 #
14 # Environment vars:
15 # vif vif interface name (required).
16 # XENBUS_PATH path to this device's details in the XenStore (required).
17 #
18 # Read from the store:
19 # ip list of IP networks for the vif, space-separated (default given in
20 # this script).
21 #============================================================================
23 dir=$(dirname "$0")
24 . "$dir/vif-common.sh"
26 main_ip=$(ip addr show eth0 | sed -e '/inet /!d;s/^.*inet \([^\s*]\)\s.*$/\1/')
28 case "$command" in
29 online)
30 ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up
31 echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
32 ipcmd='a'
33 ;;
34 offline)
35 ifdown ${vif}
36 ipcmd='d'
37 ;;
38 esac
40 if [ "${ip}" ] ; then
41 # If we've been given a list of IP addresses, then add routes from dom0 to
42 # the guest using those addresses.
43 for addr in ${ip} ; do
44 ip r ${ipcmd} ${addr} dev ${vif} src ${main_ip}
45 done
46 fi
48 handle_iptable
50 success