diff options
| author | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2026-05-16 20:18:13 +0000 |
|---|---|---|
| committer | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2026-05-16 20:31:27 +0000 |
| commit | 50bc5bbd0e7a5e74a606661b07a086106546ccc4 (patch) | |
| tree | a80de9df28a9e6426fe24693dcdde2462efebf67 | |
| parent | 5819dd5768e054547ddd8c4ac8ac78e562ff1841 (diff) | |
| download | libvirt-routed-subnet-master.tar.gz libvirt-routed-subnet-master.tar.xz libvirt-routed-subnet-master.zip | |
This is common with BGP (RFC 8950), but the underlying
principle is will soon have it's own RFC.
Example: (guest VM)
ip addr add 192.0.2.42/32 dev lo
ip route add proto static 0.0.0.0/0 via inet6 2001:db8:1337::1
RFC 8950: Advertising IPv4 NLRI with an IPv6 Next Hop
https://www.rfc-editor.org/rfc/rfc8950
draft-ietf-intarea-v4-via-v6: IPv4 routes with an IPv6 next hop
https://datatracker.ietf.org/doc/draft-ietf-intarea-v4-via-v6/
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
| -rwxr-xr-x | qemu | 9 | ||||
| -rw-r--r-- | test-in.xml | 9 |
2 files changed, 16 insertions, 2 deletions
@@ -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> |
