source: trunk/packages/invirt-xen-config/vif-invirtroute @ 3044

Last change on this file since 3044 was 2895, checked in by gdb, 15 years ago

Changed xen.network -> xen.

  • Property svn:executable set to *
File size: 2.0 KB
RevLine 
[87]1#!/bin/bash
2
3#============================================================================
4# /etc/xen/vif-route
5#
6# Script for configuring a vif in routed mode.
7# The hotplugging system will call this script if it is specified either in
8# the device configuration given to Xend, or the default Xend configuration
9# in /etc/xen/xend-config.sxp.  If the script is specified in neither of those
10# places, then vif-bridge is the default.
11#
12# Usage:
13# vif-route (add|remove|online|offline)
14#
15# Environment vars:
16# vif         vif interface name (required).
17# XENBUS_PATH path to this device's details in the XenStore (required).
18# Read from the store:
19# ip      list of IP networks for the vif, space-separated (default given in
20#         this script).
[2860]21#
[87]22# This script will set up proxy arp  for any ip addresses that are being routed
[95]23# type read to determine if the device is ioemu
[87]24
25#============================================================================
26
27dir=$(dirname "$0")
28. "$dir/vif-common.sh"
29
30main_ip=$(dom0_ip)
[95]31dev=${dev:-${vif}}
[87]32
33case "$command" in
34    online)
[95]35        ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
36        echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
37        echo 1 >/proc/sys/net/ipv4/conf/${dev}/rp_filter
[1426]38        if [ x${qemu_online} != xyes ]; then
39          ethtool -K ${dev} tx off
40        fi
[87]41        ipcmd='add'
42        cmdprefix=''
43        ;;
44    offline)
45        do_without_error ifdown ${vif}
46        ipcmd='del'
47        cmdprefix='do_without_error'
48        ;;
49esac
50
[95]51vif_type=$(xenstore_read_default "$XENBUS_PATH/type" "viffront")
52if [  ${vif_type} != "ioemu"  -o  x${qemu_online} = xyes ] ; then
53    if [ "${ip}" ] ; then
[87]54    # If we've been given a list of IP addresses, then add routes from dom0 to
55    # the guest using those addresses.
[95]56        for addr in ${ip} ; do
57            ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip}
[2895]58            arpspoof -i $(invirt-getconf xen.iface) -t 18.181.0.1 ${addr}&
[95]59            sleep 5
60            kill %arpspoof
61        done
62    fi
63fi
[87]64
65log debug "Successful vif-route $command for $vif."
66if [ "$command" == "online" ]
67then
68  success
69fi
Note: See TracBrowser for help on using the repository browser.