IORING_OP_BIND/LISTEN support
v2 cover IORING_OP_BIND/LISTEN support
This is the v2 of userspace support for OP_BIND/OP_LISTEN with wrappers, manpages and tests.
Beyond the requested fixes in v1, I completely rewrote the testcase to avoid pthreads and introduced more test cases. It also ensures the testcase is properly skipped for older kernels.
Gabriel Krisman Bertazi (5):
liburing: Add helper to prepare IORING_OP_BIND command
liburing: Add helper to prepare IORING_OP_LISTEN command
tests: Add test for bind/listen commands man/io_uring_prep_bind.3: Document the IORING_OP_BIND operation man/io_uring_prep_listen.3: Document IORING_OP_LISTEN operation
man/io_uring_prep_bind.3 | 54 +++++ man/io_uring_prep_listen.3 | 52 +++++ src/include/liburing.h | 13 ++ src/include/liburing/io_uring.h | 2 + src/liburing-ffi.map | 2 + test/Makefile | 1 + test/bind-listen.c | 381 ++++++++++++++++++++++++++++++++ 7 files changed, 505 insertions(+) create mode 100644 man/io_uring_prep_bind.3 create mode 100644 man/io_uring_prep_listen.3 create mode 100644 test/bind-listen.c
Signature · 1 line
2.45.2
PATCH v2 1/5 liburing: Add helper to prepare IORING_OP_BIND command
--- src/include/liburing.h | 7 +++++++ src/include/liburing/io_uring.h | 1 + src/liburing-ffi.map | 1 + 3 files changed, 9 insertions(+)
src/include/liburing.h +7 -0
@@ -669,6 +669,13 @@ IOURINGINLINE void io_uring_prep_connect(struct io_uring_sqe *sqe, int fd,io_uring_prep_rw (IORING_OP_CONNECT , sqe, fd, addr,0 , addrlen); } +IOURINGINLINE void io_uring_prep_bind(struct io_uring_sqe *sqe, int fd, +struct sockaddr *addr, +socklen_t addrlen) +{ +io_uring_prep_rw (IORING_OP_BIND , sqe, fd, addr,0 , addrlen); +} + IOURINGINLINE void io_uring_prep_files_update(struct io_uring_sqe *sqe,int *fds,unsigned nr_fds,int offset)
src/include/liburing/io_uring.h +1 -0
@@ -257,6 +257,7 @@ enum io_uring_op {IORING_OP_FUTEX_WAITV ,IORING_OP_FIXED_FD_INSTALL ,IORING_OP_FTRUNCATE , +IORING_OP_BIND ,/* this goes last, obviously */ IORING_OP_LAST,
src/liburing-ffi.map +1 -0
@@ -201,4 +201,5 @@ LIBURING_2.6 { LIBURING_2.7 { io_uring_prep_fadvise64; io_uring_prep_madvise64; + io_uring_prep_bind; } LIBURING_2.6;
Signature · 1 line
2.45.2
PATCH v2 2/5 liburing: Add helper to prepare IORING_OP_LISTEN command
In reply to Gabriel Krisman Bertazi--- src/include/liburing.h | 6 ++++++ src/include/liburing/io_uring.h | 1 + src/liburing-ffi.map | 1 + 3 files changed, 8 insertions(+)
src/include/liburing.h +6 -0
@@ -676,6 +676,12 @@ IOURINGINLINE void io_uring_prep_bind(struct io_uring_sqe *sqe, int fd,io_uring_prep_rw (IORING_OP_BIND , sqe, fd, addr,0 , addrlen); } +IOURINGINLINE void io_uring_prep_listen(struct io_uring_sqe *sqe, int fd, +int backlog) +{ +io_uring_prep_rw (IORING_OP_LISTEN , sqe, fd,0 , backlog,0 ); +} + IOURINGINLINE void io_uring_prep_files_update(struct io_uring_sqe *sqe,int *fds,unsigned nr_fds,int offset)
src/include/liburing/io_uring.h +1 -0
@@ -258,6 +258,7 @@ enum io_uring_op {IORING_OP_FIXED_FD_INSTALL ,IORING_OP_FTRUNCATE ,IORING_OP_BIND , +IORING_OP_LISTEN ,/* this goes last, obviously */ IORING_OP_LAST,
src/liburing-ffi.map +1 -0
@@ -202,4 +202,5 @@ LIBURING_2.7 { io_uring_prep_fadvise64; io_uring_prep_madvise64; io_uring_prep_bind; + io_uring_prep_listen; } LIBURING_2.6;
Signature · 1 line
2.45.2
PATCH v2 3/5 tests: Add test for bind/listen commands
In reply to Gabriel Krisman BertaziThis test implements verification for bind/listen commands. First, it creates a TCP connection with itself only using io_uring and verify it works by sending data over it. Then, some unit test verifies some failed cases of malformed bind and listen operations.
--- test/Makefile | 1 + test/bind-listen.c | 381 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 382 insertions(+) create mode 100644 test/bind-listen.c
test/Makefile +1 -0
@@ -52,6 +52,7 @@ test_srcs := \ across-fork.c \ b19062a56726.c \ b5837bd5311d.c \ + bind-listen.c \ buf-ring.c \ buf-ring-nommap.c \ buf-ring-put.c \
test/bind-listen.c new file +381 -0
381 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v2 4/5 man/io_uring_prep_bind.3: Document the IORING_OP_BIND operation
In reply to Gabriel Krisman Bertazi--- man/io_uring_prep_bind.3 | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 man/io_uring_prep_bind.3
man/io_uring_prep_bind.3 new file +54 -0
@@ -0,0 +1,54 @@ +.\" Copyright (C) 2024 SUSE LLC +.\" +.\" SPDX-License-Identifier: LGPL-2.0-or-later +.\" +.TH io_uring_prep_bind 3 "Jun 3, 2024" "liburing-2.7" "liburing Manual" +.SH NAME +io_uring_prep_bind \- prepare a bind request +.SH SYNOPSIS +.nf +.B #include <sys/socket.h> +.B #include <liburing.h> +.PP +.BI "void io_uring_prep_bind(struct io_uring_sqe *" sqe "," +.BI " int " sockfd "," +.BI " struct sockaddr *" addr "," +.BI " socklen_t " addrlen ");" +.fi +.SH DESCRIPTION +The +.BR io_uring_prep_bind (3) +function prepares a bind request. The submission queue entry +.I sqe +is setup to assign the network address at +.IR addr , +of length +.IR addrlen , +to the socket descriptor +.IR sockfd. + +This function prepares an async +.BR bind (2) +request. See that man page for details. + +.SH RETURN VALUE +None +.SH ERRORS +The CQE +.I res +field will contain the result of the operation. See the related man page for +details on possible values. Note that where synchronous system calls will return +.B -1 +on failure and set +.I errno +to the actual error value, io_uring never uses +.IR errno . +Instead it returns the negated +.I errno +directly in the CQE +.I res +field. +.SH SEE ALSO +.BR io_uring_get_sqe (3), +.BR io_uring_submit (3), +.BR bind (2)
Signature · 1 line
2.45.2
PATCH v2 5/5 man/io_uring_prep_listen.3: Document IORING_OP_LISTEN operation
In reply to Gabriel Krisman Bertazi--- man/io_uring_prep_listen.3 | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 man/io_uring_prep_listen.3
man/io_uring_prep_listen.3 new file +52 -0
@@ -0,0 +1,52 @@ +.\" Copyright (C) 2024 SUSE LLC. +.\" +.\" SPDX-License-Identifier: LGPL-2.0-or-later +.\" +.TH io_uring_prep_listen 3 "Jun 3, 2024" "liburing-2.7" "liburing Manual" +.SH NAME +io_uring_prep_listen \- prepare a listen request +.SH SYNOPSIS +.nf +.B #include <sys/socket.h> +.B #include <liburing.h> +.PP +.BI "void io_uring_prep_listen(struct io_uring_sqe *" sqe "," +.BI " int " sockfd "," +.BI " int" backlog ");" +.fi +.SH DESCRIPTION +The +.BR io_uring_prep_listen (3) +function prepares a listen request. The submission queue entry +.I sqe +is setup to place the socket file descriptor pointed by +.IR sockfd +into a state to accept incoming connections. The parameter +.IR backlog , +defines the maximum length of the queue of pending connections. + +This function prepares an async +.BR listen (2) +request. See that man page for details. + +.SH RETURN VALUE +None +.SH ERRORS +The CQE +.I res +field will contain the result of the operation. See the related man page for +details on possible values. Note that where synchronous system calls will return +.B -1 +on failure and set +.I errno +to the actual error value, io_uring never uses +.IR errno . +Instead it returns the negated +.I errno +directly in the CQE +.I res +field. +.SH SEE ALSO +.BR io_uring_get_sqe (3), +.BR io_uring_submit (3), +.BR listen (2)
Signature · 1 line
2.45.2
Quoted 8 lines · Gabriel Krisman Bertazi
This is the v2 of userspace support for OP_BIND/OP_LISTEN with wrappers, manpages and tests.
Beyond the requested fixes in v1, I completely rewrote the testcase to avoid pthreads and introduced more test cases. It also ensures the testcase is properly skipped for older kernels.
[...]
Applied, thanks!
[1/5] liburing: Add helper to prepare IORING_OP_BIND command
commit: bf7c4f6b817c040bcc0215b43c64f95f1f50172a
[2/5] liburing: Add helper to prepare IORING_OP_LISTEN command
commit: 7d515bb6a639efc64849223e179ea5d54ceaad0b
[3/5] tests: Add test for bind/listen commands
commit: 3815f772333c81409b95903ea7382ec8c687c0f9
[4/5] man/io_uring_prep_bind.3: Document the IORING_OP_BIND operation
commit: 7e9707fc3432b7c94fd2d59ad21bf105071660d8
[5/5] man/io_uring_prep_listen.3: Document IORING_OP_LISTEN operation
commit: a877fb11036d7fd025f6129f54848363dc3b5b31Best regards,
Signature · 1 line
Jens Axboe