From 71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed Mon Sep 17 00:00:00 2001 From: Jon Maloy Date: Thu, 3 Dec 2026 10:04:41 -0500 Subject: netlink: Ignore routes via gateways from another address family With NetworkManager's CLAT implementation, the IPv4 default route has an IPv6 gateway, given in a RTA_VIA attribute instead of RTA_GATEWAY: default via inet6 fe80::1 dev wlp170s0f0 proto static src 192.0.0.5 nl_get_ext_if() picks the interface of that route as template for IPv4, but nl_route_get_def() finds no IPv4 gateway, so we disable DHCP altogether, and the guest silently ends up without IPv4 connectivity, even if the host has it. We can't pass a gateway of a different address family on to the guest, so don't consider such routes in nl_get_ext_if(). If no other IPv4 routes are available, as in the case above, we fall back to local mode, which gives the guest a working IPv4 configuration: traffic still reaches the host via our sockets, and the host translates it. The address we would otherwise copy, from 192.0.0.0/29 (RFC 7335), is just a placeholder in CLAT setups anyway. Link: https://bugs.passt.top/show_bug.cgi?id=231 Reported-by: Erica Z Suggested-by: Stefano Brivio Signed-off-by: Jon Maloy Signed-off-by: Stefano Brivio --- netlink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/netlink.c b/netlink.c index 37c55cc..e91507d 100644 --- a/netlink.c +++ b/netlink.c @@ -287,6 +287,7 @@ unsigned int nl_get_ext_if(int s, sa_family_t af) struct rtmsg *rtm = (struct rtmsg *)NLMSG_DATA(nh); const void *dst = NULL; unsigned thisifi = 0; + bool via = false; if (rtm->rtm_family != af) continue; @@ -302,12 +303,22 @@ unsigned int nl_get_ext_if(int s, sa_family_t af) thisifi = rtnh->rtnh_ifindex; } else if (rta->rta_type == RTA_DST) { dst = RTA_DATA(rta); + } else if (rta->rta_type == RTA_VIA) { + const struct rtvia *v = RTA_DATA(rta); + + via = v->rtvia_family != af; } } if (!thisifi) continue; /* No interface for this route */ + /* Skip routes with a gateway from another address family, such + * as IPv4 routes via IPv6 gateways in CLAT setups. + */ + if (via) + continue; + /* Skip 'lo': we should test IFF_LOOPBACK, but keep it simple */ if (thisifi == 1) continue; -- cgit v1.2.3