public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Caleb Sander Mateos <csander@purestorage.com>
To: Gabriel Krisman Bertazi <krisman@suse.de>
Cc: axboe@kernel.dk, io-uring@vger.kernel.org
Subject: Re: [PATCH liburing 1/4] liburing: Introduce getsockname operation
Date: Fri, 24 Oct 2025 09:22:04 -0700	[thread overview]
Message-ID: <CADUfDZpefFLDygAeAMruskenTL+e9-yT7uBNZkME4xjbmbE5Mw@mail.gmail.com> (raw)
In-Reply-To: <20251024155135.798465-2-krisman@suse.de>

On Fri, Oct 24, 2025 at 8:52 AM Gabriel Krisman Bertazi <krisman@suse.de> wrote:
>
> This implements the functionality of getsockname(2) and getpeername(2)
> under a single operation.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
> ---
>  src/include/liburing.h          | 12 ++++++++++++
>  src/include/liburing/io_uring.h |  1 +
>  2 files changed, 13 insertions(+)
>
> diff --git a/src/include/liburing.h b/src/include/liburing.h
> index 83819eb7..77b0a135 100644
> --- a/src/include/liburing.h
> +++ b/src/include/liburing.h
> @@ -1572,6 +1572,18 @@ IOURINGINLINE void io_uring_prep_cmd_sock(struct io_uring_sqe *sqe,
>         sqe->level = level;
>  }
>
> +IOURINGINLINE void io_uring_prep_cmd_getsockname(struct io_uring_sqe *sqe,
> +                                                int fd, struct sockaddr *sockaddr,
> +                                                socklen_t *sockaddr_len,
> +                                                int peer)
> +       LIBURING_NOEXCEPT
> +{
> +       io_uring_prep_rw(IORING_OP_URING_CMD, sqe, fd, sockaddr, 0, 0);
> +       sqe->cmd_op = SOCKET_URING_OP_GETSOCKNAME;

Can this use the recently implemented io_uring_prep_uring_cmd() helper
instead? io_uring_prep_rw() assigns to the 8-byte field sqe->off and
sqe->cmd_op later assigns to 4 of the bytes unioned with it. That
leaves sqe->__pad1 initialized even though the kernel requires it to
be 0, as Keith described in the patch adding
io_uring_prep_uring_cmd().

Best,
Caleb

> +       sqe->addr3 = (unsigned long) (uintptr_t) sockaddr_len;
> +       sqe->optlen = peer;
> +}
> +
>  IOURINGINLINE void io_uring_prep_waitid(struct io_uring_sqe *sqe,
>                                         idtype_t idtype,
>                                         id_t id,
> diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
> index 44ce8229..365f0584 100644
> --- a/src/include/liburing/io_uring.h
> +++ b/src/include/liburing/io_uring.h
> @@ -950,6 +950,7 @@ enum io_uring_socket_op {
>         SOCKET_URING_OP_GETSOCKOPT,
>         SOCKET_URING_OP_SETSOCKOPT,
>         SOCKET_URING_OP_TX_TIMESTAMP,
> +       SOCKET_URING_OP_GETSOCKNAME,
>  };
>
>  /*
> --
> 2.51.0
>
>

  reply	other threads:[~2025-10-24 16:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 15:51 [PATCH liburing 0/4] liburing: getsockname support Gabriel Krisman Bertazi
2025-10-24 15:51 ` [PATCH liburing 1/4] liburing: Introduce getsockname operation Gabriel Krisman Bertazi
2025-10-24 16:22   ` Caleb Sander Mateos [this message]
2025-10-24 15:51 ` [PATCH liburing 2/4] test/bind-listen.t: Use ephemeral port Gabriel Krisman Bertazi
2025-10-24 15:51 ` [PATCH liburing 3/4] bind-listen.t: Add tests for getsockname Gabriel Krisman Bertazi
2025-10-24 15:51 ` [PATCH liburing 4/4] man/io_uring_prep_getsockname.3: Add man page Gabriel Krisman Bertazi

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=CADUfDZpefFLDygAeAMruskenTL+e9-yT7uBNZkME4xjbmbE5Mw@mail.gmail.com \
    --to=csander@purestorage.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=krisman@suse.de \
    /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