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 8190B5A0269 for ; Fri, 20 Nov 2026 00:21:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795130498; 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=Mpe+g+rd0+52/TJz7hbmsNKTH8f5V/uY/I26VjAyoLs=; b=SBi93IiVqJ/hv3ALOsrKRk6sGTh0jFsr2AhhqQUNA45pDPLTWsps1AVOIQNk9WiLtbvc0o SuxJIEK7wcu+XHlr4v07jW8kM0tjodnMXSbkB2IkByOiNfiv640Pw+HOVv/O90b4zL6wxN Pr8ytrGjNByu4ameveoBC8BFTm2HHQ4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-HP1zvF3ZP36PDzP3__cg_g-1; Thu, 19 Nov 2026 23:21:34 +0000 X-MC-Unique: HP1zvF3ZP36PDzP3__cg_g-1 X-Mimecast-MFC-AGG-ID: HP1zvF3ZP36PDzP3__cg_g_1795130493 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 68F7B1800A79; Thu, 19 Nov 2026 23:21:33 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB9F71956047; Thu, 19 Nov 2026 23:21:31 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH] netlink: Set default IPv4 route as on-link Date: Thu, 19 Nov 2026 18:21:31 -0500 Message-ID: <20261119232131.1409908-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: x1OenE7_mtbAbia9DjBrgSTKWC-xA2WZZVJFPT9UaF0_1795130493 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: PKCHGTXUXSY5XMR3C2M2QMDMSRPPTUVP X-Message-ID-Hash: PKCHGTXUXSY5XMR3C2M2QMDMSRPPTUVP 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: In local mode, the default IPv4 gateway is 169.254.2.2. If the user assigns an address outside 169.254.0.0/16 with -a, the gateway isn't covered by any prefix on the namespace interface, and if pasta is run with --config-net, setting the default route fails. This can be reproduced from a namespace without routes, e.g. one created by pasta without --config-net: $ pasta # pasta --config-net -a 10.0.0.1/24 -- ip route ... Couldn't set IPv4 route(s) in guest: Network is unreachable We reply to ARP requests for any address other than the guest's own, so the gateway is always reachable on the link. Therefore, flag the default route with RTNH_F_ONLINK, so that the kernel doesn't require the gateway to be within an assigned prefix. Fixes: 14b84a7f077e ("treewide: Introduce 'local mode' for disconnected setups") Signed-off-by: Jon Maloy --- netlink.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/netlink.c b/netlink.c index 225b666a..8d7f2e7b 100644 --- a/netlink.c +++ b/netlink.c @@ -520,6 +520,13 @@ int nl_route_set_def(int s, unsigned int ifi, sa_family_t af, const void *gw) memcpy(&req.set.r4.a, gw, sizeof(req.set.r4.a)); req.set.r4.rta_gw.rta_type = RTA_GATEWAY; req.set.r4.rta_gw.rta_len = rta_len; + + /* The gateway might not be covered by any assigned prefix, + * e.g. the 169.254.2.2 default of local mode with a + * user-provided address. Since we answer ARP requests for + * any address other than the guest's, treat it as on-link + */ + req.rtm.rtm_flags = RTNH_F_ONLINK; } return nl_do(s, &req, RTM_NEWROUTE, NLM_F_CREATE | NLM_F_EXCL, len); -- 2.56.1