From: Jon Maloy <jmaloy@redhat.com>
To: sbrivio@redhat.com, jmaloy@redhat.com, passt-dev@passt.top
Subject: [PATCH] netlink: Ignore routes via gateways from another address family
Date: Wed, 2 Dec 2026 17:51:47 -0500 [thread overview]
Message-ID: <20261202225147.2903249-1-jmaloy@redhat.com> (raw)
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
Suggested-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
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
next reply other threads:[~2026-12-02 22:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 22:51 Jon Maloy [this message]
2026-12-02 23:04 ` Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202225147.2903249-1-jmaloy@redhat.com \
--to=jmaloy@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).