public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 6/7] io_uring/net: unify *mshot_prep calls with compat
Date: Wed, 26 Feb 2025 11:41:20 +0000	[thread overview]
Message-ID: <94e62386dec570f83b4a4270a46ac60bc415fb71.1740569495.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Instead of duplicating a io_recvmsg_mshot_prep() call in the compat
path, let the common code handle it. For that, copy necessary compat
fields into struct user_msghdr. Note, it zeroes user_msghdr to be on the
safe side as compat is not that interesting and overhead shouldn't be
high.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/net.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/io_uring/net.c b/io_uring/net.c
index 8a9ec4783a2b..de2d6bd44ef0 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -716,20 +716,20 @@ static int io_recvmsg_copy_hdr(struct io_kiocb *req,
 	iomsg->msg.msg_name = &iomsg->addr;
 	iomsg->msg.msg_iter.nr_segs = 0;
 
-#ifdef CONFIG_COMPAT
 	if (io_is_compat(req->ctx)) {
+#ifdef CONFIG_COMPAT
 		struct compat_msghdr cmsg;
 
 		ret = io_compat_msg_copy_hdr(req, iomsg, &cmsg, ITER_DEST,
 					     &iomsg->uaddr);
-		if (unlikely(ret))
-			return ret;
-		return io_recvmsg_mshot_prep(req, iomsg, cmsg.msg_namelen,
-						cmsg.msg_controllen);
-	}
+		memset(&msg, 0, sizeof(msg));
+		msg.msg_namelen = cmsg.msg_namelen;
+		msg.msg_controllen = cmsg.msg_controllen;
 #endif
+	} else {
+		ret = io_msg_copy_hdr(req, iomsg, &msg, ITER_DEST, &iomsg->uaddr);
+	}
 
-	ret = io_msg_copy_hdr(req, iomsg, &msg, ITER_DEST, &iomsg->uaddr);
 	if (unlikely(ret))
 		return ret;
 	return io_recvmsg_mshot_prep(req, iomsg, msg.msg_namelen,
-- 
2.48.1


  parent reply	other threads:[~2025-02-26 11:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 11:41 [PATCH 0/7] improve net msghdr / iovec handlng Pavel Begunkov
2025-02-26 11:41 ` [PATCH 1/7] io_uring/net: remove unnecessary REQ_F_NEED_CLEANUP Pavel Begunkov
2025-02-26 11:41 ` [PATCH 2/7] io_uring/net: simplify compat selbuf iov parsing Pavel Begunkov
2025-02-26 11:41 ` [PATCH 3/7] io_uring/net: isolate msghdr copying code Pavel Begunkov
2025-02-26 11:41 ` [PATCH 4/7] io_uring/net: verify msghdr before copying iovec Pavel Begunkov
2025-02-26 11:41 ` [PATCH 5/7] io_uring/net: derive iovec storage later Pavel Begunkov
2025-02-26 11:41 ` Pavel Begunkov [this message]
2025-02-26 11:41 ` [PATCH 7/7] io_uring/net: extract iovec import into a helper Pavel Begunkov
2025-02-26 17:41 ` [PATCH 0/7] improve net msghdr / iovec handlng 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 \
    --in-reply-to=94e62386dec570f83b4a4270a46ac60bc415fb71.1740569495.git.asml.silence@gmail.com \
    [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