source: trunk/packages/sipb-xen-dom0/sipb-xen-dom0/files/etc/xen/scripts/vif-sipbroute @ 87

Last change on this file since 87 was 87, checked in by hartmans, 17 years ago
  • Add qemu-dm-sipb written by andersk to get us the domain ID in qemu-ifup
  • Add vif-sipbroute, a version of vif-route that does better netwwork isolation and has initial but useless ipv6 support. This version also uses arpspoof to take over an address for domain migrations.
  • Add init script to enable rp_filter, proxy_arp and forwarding for the network config.
  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#!/bin/bash
2
3
4
5
6#============================================================================
7# /etc/xen/vif-route
8#
9# Script for configuring a vif in routed mode.
10# The hotplugging system will call this script if it is specified either in
11# the device configuration given to Xend, or the default Xend configuration
12# in /etc/xen/xend-config.sxp.  If the script is specified in neither of those
13# places, then vif-bridge is the default.
14#
15# Usage:
16# vif-route (add|remove|online|offline)
17#
18# Environment vars:
19# vif         vif interface name (required).
20# XENBUS_PATH path to this device's details in the XenStore (required).
21# Read from the store:
22# ip      list of IP networks for the vif, space-separated (default given in
23#         this script).
24# V6PREFIX  prefix of v6 address to use
25# Note that the v6 support is kind of broken because there's not really a way to populate the v6 prefix
26# This script will set up proxy arp  for any ip addresses that are being routed
27
28#============================================================================
29
30dir=$(dirname "$0")
31. "$dir/vif-common.sh"
32
33main_ip=$(dom0_ip)
34
35case "$command" in
36    online)
37        ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up
38        echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
39        echo 1 >/proc/sys/net/ipv4/conf/${vif}/rp_filter
40        ipcmd='add'
41        cmdprefix=''
42        ;;
43    offline)
44        do_without_error ifdown ${vif}
45        if [ -f /var/run/radvd/radvd.pid.${vif} ] ; then
46            do_without_error kill `cat /var/run/radvd/radvd.pid.${vif}`
47            fi
48        ipcmd='del'
49        cmdprefix='do_without_error'
50        ;;
51esac
52
53v6prefix=${v6prefix:-}
54v6prefix=$(xenstore_read_default "$XENBUS_PATH/v6prefix" "$v6prefix")
55
56if [ "${ip}" ] ; then
57    # If we've been given a list of IP addresses, then add routes from dom0 to
58    # the guest using those addresses.
59    for addr in ${ip} ; do
60      ${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip}
61      arpspoof -i eth0 ${addr}&
62      sleep 5
63      kill %arpspoof
64    done
65fi
66
67if [ x${v6prefix} != x ] ; then
68    sed -e "s/@interface@/${vif}/" -e "s+@prefix@+${v6prefix}+" /etc/xen/radvd.conf.template >/var/run/radvd.conf.${vif}
69    ${cmdprefix} ip -6 addr  ${ipcmd}  fe80::/64 scope link  dev ${vif} 
70    if [ $1 = online ] ; then
71        radvd  -u radvd -C /var/run/radvd.conf.${vif} -p /var/run/radvd/radvd.pid.${vif}
72    fi
73    ${cmdprefix} ip -6 route ${ipcmd} ${v6prefix} dev ${vif} 
74    fi
75
76handle_iptable
77
78log debug "Successful vif-route $command for $vif."
79if [ "$command" == "online" ]
80then
81  success
82fi
Note: See TracBrowser for help on using the repository browser.