* [PATCH v2] netlink: Ignore routes via gateways from another address family
@ 2026-12-03 15:04 Jon Maloy
0 siblings, 0 replies; only message in thread
From: Jon Maloy @ 2026-12-03 15:04 UTC (permalink / raw)
To: sbrivio, jmaloy, passt-dev; +Cc: zerica
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 <zerica@callcc.eu>
Suggested-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
v2: Added Reported-by: tag (Stefano)
---
netlink.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/netlink.c b/netlink.c
index a0f8783b..99aeec2b 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;
--
2.56.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-03 15:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 15:04 [PATCH v2] netlink: Ignore routes via gateways from another address family Jon Maloy
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).