From 50bc5bbd0e7a5e74a606661b07a086106546ccc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Sat, 16 May 2026 20:18:13 +0000 Subject: add support for IPv4 via IPv6 nexthop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- qemu | 9 +++++++-- test-in.xml | 9 +++++++++ 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 @@ + + + + + @@ -25,5 +30,9 @@ + + + + -- cgit v1.2.1