vm/network: use metric to allow multiple routes to same VM
This is required when VM has multiple interfaces (eg HVM: PV and stubdom). Prefer the later one.
This commit is contained in:
parent
a06c8c3786
commit
05db5c9f92
@ -29,7 +29,7 @@ case "$command" in
|
|||||||
online)
|
online)
|
||||||
ifconfig ${vif} up
|
ifconfig ${vif} up
|
||||||
echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
|
echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
|
||||||
ipcmd='replace'
|
ipcmd='add'
|
||||||
iptables_cmd='-I PREROUTING 1'
|
iptables_cmd='-I PREROUTING 1'
|
||||||
cmdprefix=''
|
cmdprefix=''
|
||||||
;;
|
;;
|
||||||
@ -41,11 +41,17 @@ case "$command" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
domid=${vif/vif/}
|
||||||
|
domid=${domid/.*/}
|
||||||
|
# metric must be possitive, but prefer later interface
|
||||||
|
# 32752 is max XID aka domid
|
||||||
|
metric=$[ 32752 - $domid ]
|
||||||
|
|
||||||
if [ "${ip}" ] ; then
|
if [ "${ip}" ] ; then
|
||||||
# If we've been given a list of IP addresses, then add routes from dom0 to
|
# If we've been given a list of IP addresses, then add routes from dom0 to
|
||||||
# the guest using those addresses.
|
# the guest using those addresses.
|
||||||
for addr in ${ip} ; do
|
for addr in ${ip} ; do
|
||||||
${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} || true
|
${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} metric $metric
|
||||||
done
|
done
|
||||||
echo ${cmdprefix} iptables -t raw $iptables_cmd -i ${vif} \! -s ${ip} -j DROP
|
echo ${cmdprefix} iptables -t raw $iptables_cmd -i ${vif} \! -s ${ip} -j DROP
|
||||||
${cmdprefix} iptables -t raw $iptables_cmd -i ${vif} \! -s ${ip} -j DROP
|
${cmdprefix} iptables -t raw $iptables_cmd -i ${vif} \! -s ${ip} -j DROP
|
||||||
|
Loading…
Reference in New Issue
Block a user