From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 8EDA35A0269 for ; Thu, 03 Dec 2026 16:04:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796310287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=H6HNNGAMVPQLagKc/J3+/UDULyxN2JkoPltUD3Fryms=; b=ag859TyhmRAm+dRc3jb+/rIDhCFcKlsAMYoxC1D+n7ayVanplaUOOVnlaj86zMzygy4H4R 6Kr0E8pMrUA0fa28sJNjdNKE3u8QHXRV4NDK+5H2d2Qg3nivYBHj+PMk89ykAhk7ptcFED RUO82IerL6UjP7/djxxEwbC7D/r+NMI= X-MC-Rep: binary re single Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-468-vUiKzhviPNOEM3Fecr1XkQ-1; Thu, 3 Dec 2026 15:04:44 +0000 X-MC-Unique: vUiKzhviPNOEM3Fecr1XkQ-1 X-Mimecast-MFC-AGG-ID: vUiKzhviPNOEM3Fecr1XkQ_1796310284 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8B7EA189D54A; Thu, 3 Dec 2026 15:04:43 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7F836B91; Thu, 3 Dec 2026 15:04:42 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH v2] netlink: Ignore routes via gateways from another address family Date: Thu, 3 Dec 2026 10:04:41 -0500 Message-ID: <20261203150441.3175883-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mXPnj2qLHqlX3MsUf6Fyf3HNUEzjQK92InvhBso9W5A_1796310284 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: RD3GLB53WM64VEA2ZFBBRK4LJ2W5A7VL X-Message-ID-Hash: RD3GLB53WM64VEA2ZFBBRK4LJ2W5A7VL X-MailFrom: jmaloy@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: zerica@callcc.eu X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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