diff options
| author | Jon Maloy <jmaloy@redhat.com> | 2026-12-03 10:04:41 -0500 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-12-04 22:54:12 +0100 |
| commit | 71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed (patch) | |
| tree | 55ddc3673423470b2b909e98c20d5cf64c8ec9e3 | |
| parent | 29fc1490b48a04b4d3fde8769c7c64d594335915 (diff) | |
| download | passt-71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed.tar passt-71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed.tar.gz passt-71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed.tar.bz2 passt-71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed.tar.lz passt-71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed.tar.xz passt-71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed.tar.zst passt-71ee9ecf920cc2b63f5ff4d8d05c2c32ae1241ed.zip | |
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 <zerica@callcc.eu>
Suggested-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | netlink.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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; |
