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 B0D795A0269 for ; Sun, 22 Nov 2026 23:15:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795385711; 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: in-reply-to:in-reply-to:references:references; bh=670TbMQNT9ASq+GoXLa/F3o5w2D36RpckBRbcrJxQrQ=; b=CkYQimgqP+9LN3jOqXsRWXVucR73RP1xMOdSiEJ/6sxssG84aBdDFUowat/nurT8OsV1fF dkOHPesyYbEr9qGjn9fut/b2IQv9RnO15rxr0+/inTA/zm//isS6k+k38l84lvEiZsuQtS S8v5x3flciNhwlJMlIQ+8eCwrCaEycw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-pkCTRph0McupEHMtNQcT_w-1; Sun, 22 Nov 2026 22:15:09 +0000 X-MC-Unique: pkCTRph0McupEHMtNQcT_w-1 X-Mimecast-MFC-AGG-ID: pkCTRph0McupEHMtNQcT_w_1795385708 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4a009f82bedso17693715e9.0 for ; Sun, 22 Nov 2026 14:15:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795385708; x=1795990508; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=670TbMQNT9ASq+GoXLa/F3o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Dwut40pwzeoMwbqDiD8pj4DBiilhnXJoIQ= X-Received: by 2002:a05:600c:5303:b0:4a2:1a:a11d with SMTP id 5b1f17b1804b1-4bb88785d24mr195128095e9.0.1795385708202; Sun, 22 Nov 2026 14:15:08 -0800 (PST) X-Received: by 2002:a05:600c:5303:b0:4a2:1a:a11d with SMTP id 5b1f17b1804b1-4bb88785d24mr195127835e9.0.1795385707623; Sun, 22 Nov 2026 14:15:07 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9687sm339161635e9.10.2026.11.22.14.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 14:15:07 -0800 (PST) From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH] netlink: Set default IPv4 route as on-link Message-ID: <20261122231505.276d47b3@elisabeth> In-Reply-To: <20261119232131.1409908-1-jmaloy@redhat.com> References: <20261119232131.1409908-1-jmaloy@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Sun, 22 Nov 2026 23:15:06 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: BCBZGT-eLDhGH5ShqnrjZ5LdVTCm6EW1qnYq63dNjZs_1795385708 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: NOG2MTNNZG3HR5Z5MNFK74NDA75SWXKM X-Message-ID-Hash: NOG2MTNNZG3HR5Z5MNFK74NDA75SWXKM X-MailFrom: sbrivio@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: david@gibson.dropbear.id.au, passt-dev@passt.top 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: On Thu, 19 Nov 2026 18:21:31 -0500 Jon Maloy wrote: > 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 shouldn't depend on a particular choice of the gateway address (but it seems to do, see below). It should be rather related to the fact that if routes aren't copied (which also happens in local mode), then you don't have a device route for the default gateway, that is: $ pasta -Ix -- sh -c '{ ip link set dev x up; ip addr add 10.0.0.2/24 dev x; ip ro add default via 10.0.0.1 dev x; pasta -4 --config-net -a 192.0.2.1 -- ip r; }' default via 10.0.0.1 dev x 10.0.0.0/24 dev x proto kernel scope link 192.0.2.0/24 dev x proto kernel scope link src 192.0.2.1 we copy the device route for 10.0.0.1 so it's reachable. Here, instead: $ pasta -Ix -- sh -c '{ ip link set dev x up; ip addr add 169.254.2.2/16 dev x; pasta -4 --config-net -a 192.0.2.1 -- ip r; }' No interfaces with usable IPv4 routes IPv4: no external interface as template, use local mode Couldn't set IPv4 route(s) in guest: Network is unreachable we don't have a device route, so it's unreachable and we can't set it as default gateway, as expected. However: $ pasta -Ix -- sh -c '{ ip link set dev x up; ip addr add 168.254.2.2/16 dev x; pasta -4 --config-net -a 192.0.2.1 -- ip r; }' 168.254.0.0/16 dev x proto kernel scope link 192.0.2.0/24 dev x proto kernel scope link src 192.0.2.1 ...this shouldn't work either. But it does. I think we should find out why and make it consistent if it's not. > 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. Regardless of that, RTNH_F_ONLINK *might* be a good idea, except that: > > Fixes: 14b84a7f077e ("treewide: Introduce 'local mode' for disconnected setups") ...I really intended it to work that way: if you override things so that the default gateway is unreachable, it should be unreachable. On the other hand, there's probably no harm in setting RTNH_F_ONLINK. It's a bit unexpected for me that things would work that way, but if they do, I don't think we're going to hide any dangerous detail from the user, and as you noted it all works ARP-wise, so it should simply improve usability. > 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); By the way, did you happen to find out why it works with IPv6 instead? It looks like the choice of the interface name is also inconsistent. This is without your patch: $ pasta -6 -Ix -- pasta --config-net -a 2001:db8::1 -- ip -6 r Couldn't get any nameserver address No interfaces with usable IPv4 routes No interfaces with usable IPv6 routes IPv4: no external interface as template, use local mode IPv6: no external interface as template, use local mode 2001:db8::/64 dev tap0 proto kernel metric 256 pref medium fe80::/64 dev tap0 proto kernel metric 256 pref medium default via fe80::1 dev tap0 metric 1024 pref medium -- Stefano