public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
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	[thread overview]
Message-ID: <20261119232131.1409908-1-jmaloy@redhat.com> (raw)

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 <jmaloy@redhat.com>
---
 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


                 reply	other threads:[~2026-11-19 23:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261119232131.1409908-1-jmaloy@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --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).