From: Stefano Brivio <sbrivio@redhat.com>
To: Jon Maloy <jmaloy@redhat.com>
Cc: david@gibson.dropbear.id.au, passt-dev@passt.top
Subject: Re: [PATCH v2] netlink: Set default route as on-link
Date: Tue, 24 Nov 2026 13:14:53 +0100 (CET) [thread overview]
Message-ID: <20261124131452.36195d46@elisabeth> (raw)
In-Reply-To: <20261124041350.3347277-1-jmaloy@redhat.com>
On Mon, 23 Nov 2026 23:13:50 -0500
Jon Maloy <jmaloy@redhat.com> wrote:
> Commit da54641f140e ("conf, pasta: With --config-net, copy all routes
> by default") made it possible to use a default gateway that's not on
> the same subnet as any address assigned to the namespace interface,
> as copying all routes from the template interface also copies the
> device route for the gateway.
>
> If pasta sets the default route itself instead, that is, with -g or
> --no-copy-routes, or in local mode, there's no such device route, and
> the kernel refuses a gateway that's not covered by any assigned
> prefix:
>
> $ pasta -Ix -- sh -c 'ip link set dev x up; \
> ip addr add 10.0.0.2/24 dev x; \
> ip route add default via 10.0.0.1 dev x; \
> pasta -4 --config-net -a 192.0.2.1 -g 10.0.0.1 -- ip route'
> Couldn't set IPv4 route(s) in guest: Network is unreachable
>
> $ pasta -6 -Ix -- sh -c 'ip link set dev x up; \
> ip addr add 2001:db8:1::2/64 dev x nodad; \
> ip -6 route add default via 2001:db8:1::1 dev x; \
> pasta -6 --config-net -a 2001:db8:2::1 -g 2001:db8:1::1 -- \
> ip -6 route'
> Couldn't set IPv6 route(s) in guest: No route to host
>
> The same happens in local mode for IPv4, where the default gateway is
> 169.254.2.2, with -a and any address outside 169.254.0.0/16. In local
> mode for IPv6, the default gateway is the link-local address fe80::1,
> which is always covered by the fe80::/64 device route.
>
> We reply to ARP requests and neighbour solicitations for any address
> other than the guest's own, so the gateway is in fact always reachable
> on the link. Flag the default route with RTNH_F_ONLINK, so that the
> kernel doesn't require the gateway to be within an assigned prefix.
> This doesn't hide anything from the user, and makes these
> configurations usable. With this change:
>
> default via 10.0.0.1 dev x onlink
> 192.0.2.0/24 dev x proto kernel scope link src 192.0.2.1
>
> and:
>
> default via 2001:db8:1::1 dev x metric 1024 onlink pref medium
>
> Note that RTNH_F_ONLINK is supported for IPv6 routes since Linux 4.16.
>
> Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Applied, thanks for the explanation about the current behaviour, it
finally makes sense to me now.
--
Stefano
prev parent reply other threads:[~2026-11-24 12:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 4:13 Jon Maloy
2026-11-24 12:14 ` Stefano Brivio [this message]
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=20261124131452.36195d46@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=jmaloy@redhat.com \
--cc=passt-dev@passt.top \
/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).