|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/5] hotplug/linux: Add IPv6 support to vif-route
Signed-off-by: Sylvain Munaut <s.munaut@xxxxxxxxxxxxxxxxxxxx>
---
tools/hotplug/Linux/vif-common.sh | 33 +++++++++++++++++++++++++++++++++
tools/hotplug/Linux/vif-route | 20 +++++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/tools/hotplug/Linux/vif-common.sh
b/tools/hotplug/Linux/vif-common.sh
index 6cbb963..bb7b18b 100644
--- a/tools/hotplug/Linux/vif-common.sh
+++ b/tools/hotplug/Linux/vif-common.sh
@@ -342,3 +342,36 @@ dom0_ip()
fi
echo "$result"
}
+
+
+##
+# ip6_of interface
+#
+# Print the first IPv6 address currently in use at the given interface, or
nothing if
+# the interface is not up.
+#
+ip6_of()
+{
+ ip -6 -o addr show primary dev "$1" scope global | awk '$3 == "inet6"
{split($4,i,"/"); print i[1]; exit}'
+}
+
+
+##
+# dom0_ip6
+#
+# Print the IPv6 address of the interface in dom0 through which we are routing.
+# This is the IP address on the interface specified as "netdev" as a parameter
+# to these scripts, or eth0 by default. This function will return nothing if
no
+# such interface could be found.
+#
+dom0_ip6()
+{
+ local nd=${netdev:-eth0}
+ local result=$(ip6_of "$nd")
+ if [ -z "$result" ]
+ then
+ ""
+ else
+ echo "$result"
+ fi
+}
diff --git a/tools/hotplug/Linux/vif-route b/tools/hotplug/Linux/vif-route
index 02f1403..8cf80d5 100644
--- a/tools/hotplug/Linux/vif-route
+++ b/tools/hotplug/Linux/vif-route
@@ -24,11 +24,21 @@ dir=$(dirname "$0")
. "${dir}/vif-common.sh"
main_ip=$(dom0_ip)
+main_ip6=$(dom0_ip6)
+
+proxy_ndp=$(xenstore_read_default "$XENBUS_PATH/proxy_ndp" "off")
+
case "${command}" in
online)
ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
+ if [ ! -z "${main_ip6}" ]; then
+ ip -6 addr add ${main_ip6} dev ${vif}
+ if [ "${proxy_ndp}" != "off" ]; then
+ echo 1 >/proc/sys/net/ipv6/conf/${vif}/proxy_ndp
+ fi
+ fi
ipcmd='add'
cmdprefix=''
;;
@@ -43,7 +53,15 @@ if [ "${ip}" ] ; then
# If we've been given a list of IP addresses, then add routes from dom0 to
# the guest using those addresses.
for addr in ${ip} ; do
- ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip}
+ result=$(is_ipv6 "${addr}")
+ if [ -z "${result}" ] ; then
+ ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip}
+ else
+ ${cmdprefix} ip -6 route ${ipcmd} ${addr} dev ${vif} src
${main_ip6}
+ if [ "${proxy_ndp}" != "off" ]; then
+ ${cmdprefix} ip -6 neighbor ${ipcmd} proxy ${addr} dev
${netdev:-eth0}
+ fi
+ fi
done
fi
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |