3 #============================================================================
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.
13 # vif-route (add|remove|online|offline)
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
22 # This script will set up proxy arp for any ip addresses that are being routed
23 # type read to determine if the device is ioemu
25 #============================================================================
27 . "$dir/vif-common.sh"
34 echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
35 echo 1 >/proc/sys/net/ipv4/conf/${dev}/arp_notify
36 echo 1 >/proc/sys/net/ipv4/conf/${dev}/rp_filter
37 ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
38 xenstore-write "$XENBUS_PATH/feature-gso-tcpv4" 0
39 if [ x${qemu_online} != xyes ]; then
40 ethtool -K ${dev} tx off
46 do_without_error ifdown ${vif}
48 cmdprefix='do_without_error'
52 vif_type=$(xenstore_read_default "$XENBUS_PATH/type" "viffront")
53 if [ ${vif_type} != "ioemu" -o x${qemu_online} = xyes ] ; then
55 # If we've been given a list of IP addresses, then add routes from dom0 to
56 # the guest using those addresses.
57 for addr in ${ip} ; do
58 # When PVHVM is enabled, Xen plugs two interfaces into
59 # HVMs - an emulated tap device and a paravirt vif device.
60 # vif-invirtroute (and vif-route, for that matter!) will
61 # fail when the second one is brought up, because the
62 # second invocation of 'ip route add' is identical to the
63 # first (same source and destination IPs) and the kernel
64 # rejects the new route.
66 # We work around this by adding the routes with different metrics.
67 # This should work because:
69 # 1) In the case of a pv-aware guest, the kernel will
70 # unplug the tap interface, which will bring down the tap
71 # interface's route, leaving only the one via the vif (and
72 # so the metric shouldn't matter, because it's the only
75 # 2) In the case of a non-pv-aware guest, the tap route
76 # (with metric 1) should take precedence over the vif
77 # route and carry all the traffic.
79 if [ $ipcmd == "add" ]; then
89 ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip} $metric
92 arpspoof -i $(invirt-getconf xen.iface) -t 18.181.0.1 ${addr}&
101 log debug "Successful vif-route $command for $vif."