From: "John Ericson" <mail@johnericson.me>
To: "Cong Wang" <cwang@multikernel.io>
Cc: "Li Chen" <me@linux.beauty>, "Andy Lutomirski" <luto@kernel.org>,
"Christian Brauner" <brauner@kernel.org>,
"Jens Axboe" <axboe@kernel.dk>,
"network dev" <netdev@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
"Sergei Zimmerman" <sergei@zimmerman.foo>
Subject: Re: [RFC] connectat()/bindat() or an alternative design
Date: Wed, 01 Jul 2026 23:22:43 -0400 [thread overview]
Message-ID: <ec6c3206-ed41-4de0-b315-0b602b7faf41@app.fastmail.com> (raw)
In-Reply-To: <akWxrjOl4Up02Bvq@pop-os.localdomain>
On Wed, Jul 1, 2026, at 8:32 PM, Cong Wang wrote:
> Hm? Why not just setsockopt()? Something like:
>
> struct unix_lookup_ctx {
> int dirfd;
> __u64 resolve_flags; /* RESOLVE_BENEATH, RESOLVE_NO_SYMLINKS, etc. */
> __u64 op_flags; /* maybe future */
> };
>
> setsockopt(fd, SOL_UNIX, UNIX_NEXT_LOOKUP,
> &ctx, sizeof(ctx));
>
> bind(fd, (struct sockaddr *)&addr, addrlen);
> /* or connect(fd, ...) */
>
>
> Zero new syscall is needed.
If this supports the `AT_EMPTY_PATH` no filesystem at all use-case
(which is what I chose to highlight in the previous summary email), I'll
take it --- it hits my desiderata. But implementation-side, I don't
relish the thought of even more state for socket setup --- since we need
to persist the lookup context until the bind.
If setsockopt is the "ioctl of sockets" --- a convenient way to de facto
create syscalls without doing so de jure --- I would think it would be
better to just make it do the bind in one go so there is no state:
struct unix_bind_anon_ctx {
int *connect_fd; /* fd used to connect to this socket
written to this */
__u64 op_flags; /* future usage */
};
setsockopt(fd, SOL_UNIX, UNIX_BIND_ANON,
&ctx, sizeof(ctx));
Regular `linkat` can be used to place the "connect fd" in the filesystem
for regular file-based connecting (e.g. to cope with long paths), in
addition to how the "connect fd" can directly be used in the
`AT_EMPTY_PATH` case.
and for the connecting side:
struct unix_connect_at_ctx {
int dirfd;
const char *path;
__u64 resolve_flags; /* RESOLVE_BENEATH, RESOLVE_NO_SYMLINKS, etc. */
__u64 op_flags; /* SOMETHING_EMPTY_PATH, other future usage */
};
setsockopt(fd, SOL_UNIX, UNIX_CONNECT_AT,
&ctx, sizeof(ctx));
This is just what I had in my previous `summary email`, but with the new
system calls twisted into `setsockopt` variations instead. (I forgot to
mention the `linkat` usage in that email, oops, but it was always
intended to be part of the plan.)
Cheers,
John
prev parent reply other threads:[~2026-07-02 3:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 19:09 [RFC] connectat()/bindat() or an alternative design John Ericson
2026-06-08 19:45 ` Cong Wang
2026-06-11 2:08 ` John Ericson
2026-06-12 18:50 ` Cong Wang
2026-06-23 17:40 ` John Ericson
2026-06-30 20:22 ` John Ericson
2026-07-01 19:41 ` John Ericson
2026-07-02 0:32 ` Cong Wang
2026-07-02 3:22 ` John Ericson [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=ec6c3206-ed41-4de0-b315-0b602b7faf41@app.fastmail.com \
--to=mail@johnericson.me \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=cwang@multikernel.io \
--cc=linux-fsdevel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=me@linux.beauty \
--cc=netdev@vger.kernel.org \
--cc=sergei@zimmerman.foo \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox