From: Stefano Brivio <sbrivio@redhat.com>
To: Lisanna Dettwyler <lisanna.dettwyler@gmail.com>
Cc: passt-dev@passt.top, David Gibson <david@gibson.dropbear.id.au>
Subject: Re: Startup fd to avoid busywaits
Date: Wed, 27 May 2026 21:39:25 +0200 (CEST) [thread overview]
Message-ID: <20260527213924.2586bca5@elisabeth> (raw)
In-Reply-To: <CAC-VXLYqvXu+yHsM=DUt-7MSGp_+o8Wt5zgGYzi1gdNvtoRK-A@mail.gmail.com>
Hi Lisanna,
On Wed, 27 May 2026 13:08:01 -0400
Lisanna Dettwyler <lisanna.dettwyler@gmail.com> wrote:
> Hello! I would like to propose a patch that allows the invoker to pass a
> "ready fd" on startup that gets written to once the setup has been
> completed, similar to slirp4netns's `--ready-fd` flag. Currently we have to
> poll the interface in a loop to wait for setup to be completed, and it
> would be much better if we could instead block on fd activity.
As I was implementing the first prototype of pasta, I spotted this in
slirp4netns and I was rather surprised because...
> Just wanted to check if such a contribution would be welcome before putting
> in the work of authoring it, or if there's already a better way to wait for
> the interface to come up.
...traditionally, well-behaved UNIX daemons fork to background when
they're ready, and that's what pasta does.
This fits quite naturally with typical UNIX-like tools and interfaces:
if you want to start pasta (as a daemon) from a script, just do:
[whatever comes before]
pasta
[whatever comes after, now that pasta is ready]
Instead of opening a file descriptor, starting a subshell, waiting for
that file descriptor, etc.
This is how other tools generally start pasta (and passt). Podman calls
exec.Command(), for example:
https://github.com/containers/common/blob/a5ccdae846b629b5ceaefa6ffd5c6511409c3487/libnetwork/pasta/pasta_linux.go#L71
> This is our current implementation:
> https://github.com/NixOS/nix/pull/15919/changes#diff-2a9176262efad1ef345d882b0779646e7a5aaf9ca8db33e9da7fc408594b5377R94-R125
Ouch, that looks rather painful. :( I read this comment, a bit above:
// Bring up pasta, for handling FOD networking. We don't let it daemonize
// itself for process managements reasons and kill it manually when done.
but it's not clear to me what "process managements reasons" might be.
Maybe we have another way to satisfy those requirements? I tried quite
hard to make it all as simple and as boring as possible.
About this other comment:
// FIXME ideally we want a notification when pasta exits, but we cannot do
// this at present [...]
...I think ideally the easiest would be to just let pasta terminate by
itself, given that you set up namespaces externally (just like Podman
and Docker/rootlesskit do).
But pasta can also write a PID file, and you could pidfd_open() on its
PID. I think that would be much cleaner.
While at it, a bit below:
// TODO these redirections are crimes. pasta closes all non-stdio file
// descriptors very early and lacks fd arguments for the namespaces we
// want it to join. we cannot have pasta join the namespaces via pids;
// doing so requires capabilities which pasta *also* drops very early.
...actually, pasta explicitly supports joining namespaces via PIDs, I'm
not entirely sure what would prevent it in Nix. Would there be some
capability we need to drop a bit later?
On that topic, you might be interested in:
https://bugs.passt.top/show_bug.cgi?id=204
and, perhaps more importantly, in these points coming from the NixPak /
bubblewrap usage:
https://bugs.passt.top/show_bug.cgi?id=204#c3
https://archives.passt.top/passt-user/671252c8-88f6-45b7-b719-b82786e84bb7@gnedt.at/
I'm not opposed to a --ready-fd (and a --keep-fds) option if that
solves issues for you, of course, but I'd say let's make sure we're not
duplicating existing (maybe more robust?) mechanisms first.
--
Stefano
prev parent reply other threads:[~2026-05-27 19:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 17:08 Lisanna Dettwyler
2026-05-27 19:39 ` Paul Holzinger
2026-05-27 19:39 ` 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=20260527213924.2586bca5@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=lisanna.dettwyler@gmail.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).