1#!/bin/bash 2#============================================================================ 3# ${XEN_SCRIPT_DIR}/vif-route 4# 5# Script for configuring a vif in routed mode. 6# 7# Usage: 8# vif-route (add|remove|online|offline) 9# 10# Environment vars: 11# dev vif interface name (required). 12# XENBUS_PATH path to this device's details in the XenStore (required). 13# 14# Read from the store: 15# ip list of IP networks for the vif, space-separated (default given in 16# this script). 17#============================================================================ 18 19dir=$(dirname "$0") 20. "${dir}/vif-common.sh" 21 22main_ip=$(dom0_ip) 23 24case "${command}" in 25 online) 26 ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up 27 echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp 28 ipcmd='add' 29 cmdprefix='' 30 ;; 31 offline) 32 do_without_error ifdown ${dev} 33 ipcmd='del' 34 cmdprefix='do_without_error' 35 ;; 36esac 37 38if [ "${ip}" ] ; then 39 # If we've been given a list of IP addresses, then add routes from dom0 to 40 # the guest using those addresses. 41 for addr in ${ip} ; do 42 ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip} 43 done 44fi 45 46handle_iptable 47 48call_hooks vif post 49 50log debug "Successful vif-route ${command} for ${dev}." 51if [ "${command}" = "online" ] 52then 53 success 54fi 55