aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xqemu9
-rw-r--r--test-in.xml9
2 files changed, 16 insertions, 2 deletions
diff --git a/qemu b/qemu
index 9a20e74..5a63c63 100755
--- a/qemu
+++ b/qemu
@@ -45,7 +45,11 @@ xpath(){
echo "$2" | xmllint --xpath "$1" - 2>/dev/null
}
-get_address_family(){ [ -z "${1##*:*}" ] && echo ipv6 || echo ipv4; }
+is_ipv6(){ [ -z "${1##*:*}" ]; }
+
+ip_family_select(){ is_ipv6 "$1" && echo "$3" || echo "$2"; }
+
+get_address_family(){ ip_family_select "$1" 'ipv4' 'ipv6'; }
get_config(){
local configfile="$1"
@@ -138,8 +142,9 @@ process_route(){
local prefix; prefix="$(get_attr 'prefix' "$nodexml")"
local nexthop; nexthop="$(get_attr 'nexthop' "$nodexml")"
+ local nh_fam; nh_fam="inet$(ip_family_select "$nexthop" '' '6')"
- ip route add proto static "$prefix" via "$nexthop"
+ ip route add proto static "$prefix" via "$nh_fam" "$nexthop"
return 0
}
diff --git a/test-in.xml b/test-in.xml
index 59af475..7f5d8dd 100644
--- a/test-in.xml
+++ b/test-in.xml
@@ -14,6 +14,11 @@
<gateway address="192.0.2.9/29"/>
<host address="192.0.2.10"/>
</interface>
+ <interface mac="fa:23:45:67:89:0a" mtu="4470">
+ <gateway address="2001:db8:1337::1/64"/>
+ <host address="2001:db8:1337::2"/>
+ <route prefix="192.0.2.42/32" nexthop="2001:db8:1337::2"/>
+ </interface>
</routed-subnet>
</metadata>
<devices>
@@ -25,5 +30,9 @@
<mac address="fa:12:34:ab:cd:ef"/>
<target dev="bar0"/>
</interface>
+ <interface type="ethernet">
+ <mac address="fa:23:45:67:89:0a"/>
+ <target dev="v6only"/>
+ </interface>
</devices>
</domain>