GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	Pavel Begunkov <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	io-uring Mailing List <[email protected]>,
	Linux Kernel Mailing List <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [RFC PATCH liburing v1 1/2] liburing: Add `io_uring_prep_sendto()`
Date: Sat, 15 Apr 2023 23:58:20 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

A sendto(2) request can be done using:

   io_uring_prep_send() + io_uring_prep_send_set_addr()

Create a wrapper function, io_uring_prep_sendto().

Signed-off-by: Ammar Faizi <[email protected]>
---
 src/include/liburing.h | 25 +++++++++++++++++--------
 src/liburing-ffi.map   |  1 +
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index fbc65b60788a4d44..70c177431faf9f75 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -758,6 +758,23 @@ IOURINGINLINE void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd,
 	sqe->msg_flags = (__u32) flags;
 }
 
+IOURINGINLINE void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
+						const struct sockaddr *dest_addr,
+						__u16 addr_len)
+{
+	sqe->addr2 = (unsigned long)(const void *)dest_addr;
+	sqe->addr_len = addr_len;
+}
+
+IOURINGINLINE void io_uring_prep_sendto(struct io_uring_sqe *sqe, int sockfd,
+					const void *buf, size_t len, int flags,
+					const struct sockaddr *addr,
+					socklen_t addrlen)
+{
+	io_uring_prep_send(sqe, sockfd, buf, len, flags);
+	io_uring_prep_send_set_addr(sqe, addr, addrlen);
+}
+
 IOURINGINLINE void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
 					 const void *buf, size_t len, int flags,
 					 unsigned zc_flags)
@@ -786,14 +803,6 @@ IOURINGINLINE void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd,
 	sqe->opcode = IORING_OP_SENDMSG_ZC;
 }
 
-IOURINGINLINE void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
-						const struct sockaddr *dest_addr,
-						__u16 addr_len)
-{
-	sqe->addr2 = (unsigned long)(const void *)dest_addr;
-	sqe->addr_len = addr_len;
-}
-
 IOURINGINLINE void io_uring_prep_recv(struct io_uring_sqe *sqe, int sockfd,
 				      void *buf, size_t len, int flags)
 {
diff --git a/src/liburing-ffi.map b/src/liburing-ffi.map
index c971bf8c858f3005..0a5e12ca764a2a1e 100644
--- a/src/liburing-ffi.map
+++ b/src/liburing-ffi.map
@@ -170,6 +170,7 @@ LIBURING_2.4 {
 		io_uring_prep_msg_ring_cqe_flags;
 		io_uring_prep_msg_ring_fd;
 		io_uring_prep_msg_ring_fd_alloc;
+		io_uring_prep_sendto;
 	local:
 		*;
 };
-- 
Ammar Faizi


  reply	other threads:[~2023-04-15 16:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15 16:58 [RFC PATCH liburing v1 0/2] io_uring sendto Ammar Faizi
2023-04-15 16:58 ` Ammar Faizi [this message]
2023-04-15 16:58 ` [RFC PATCH liburing v1 2/2] man: Add `io_uring_prep_sendto()` Ammar Faizi
2023-04-15 20:37 ` [RFC PATCH liburing v1 0/2] io_uring sendto Jens Axboe

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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