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 9AA795A0269 for ; Wed, 02 Dec 2026 23:51:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796251912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=428NvMXxqFDplhA+Uc3NlPTCChf9OTHQBnCBUbt5aZ4=; b=MYIBPtyrLA+hSPQ8v3Z619D7n4/B7+DzxaIvGTeoPUtMt4+ABz4VSla+odpzEL7r9Ldcqk oYyprThTw9/ZdrDtq67EVfACdV+RLyTt60AIIN22ksOL0Zpt6hC3tZkAC21FJFDCmSD1XH 23v3S01RThTU9iQ8KbbtRvhvcmy7wn0= X-MC-Rep: binary re single Received: from mx-prod-mc-05.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-518-KdZhcYKUNbu-fPm3dN0wJA-1; Wed, 2 Dec 2026 22:51:50 +0000 X-MC-Unique: KdZhcYKUNbu-fPm3dN0wJA-1 X-Mimecast-MFC-AGG-ID: KdZhcYKUNbu-fPm3dN0wJA_1796251909 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1C55A191AF2D for ; Wed, 2 Dec 2026 22:51:49 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 59FB0300039D; Wed, 2 Dec 2026 22:51:48 +0000 (UTC) From: Jon Maloy 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 Message-ID: <20261202225147.2903249-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mX5ZkCsZ5YNm0XTQYpV1N2L7-gKRSCzIp4MNFmbncwQ_1796251909 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: QEFBZMPZ4MRKWTVDCGJNZ6MWIQJ7AWFP X-Message-ID-Hash: QEFBZMPZ4MRKWTVDCGJNZ6MWIQJ7AWFP 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 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 Suggested-by: Stefano Brivio Signed-off-by: Jon Maloy --- 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