]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: Declare MSG_SPLICE_PAGES internal sendmsg() flag
authorDavid Howells <dhowells@redhat.com>
Mon, 22 May 2023 12:11:10 +0000 (13:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jan 2024 16:10:27 +0000 (17:10 +0100)
[ Upstream commit b841b901c452d92610f739a36e54978453528876 ]

Declare MSG_SPLICE_PAGES, an internal sendmsg() flag, that hints to a
network protocol that it should splice pages from the source iterator
rather than copying the data if it can.  This flag is added to a list that
is cleared by sendmsg syscalls on entry.

This is intended as a replacement for the ->sendpage() op, allowing a way
to splice in several multipage folios in one go.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: a0002127cd74 ("udp: move udp->no_check6_tx to udp->udp_flags")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/socket.h
io_uring/net.c
net/socket.c

index 1db29aab8f9c3caf66de143505a4aad6c54719ba..b3c58042bd254551b369220e7e22df14ebcedbe1 100644 (file)
@@ -324,6 +324,7 @@ struct ucred {
                                          */
 
 #define MSG_ZEROCOPY   0x4000000       /* Use user data in kernel path */
+#define MSG_SPLICE_PAGES 0x8000000     /* Splice the pages from the iterator in sendmsg() */
 #define MSG_FASTOPEN   0x20000000      /* Send data in TCP SYN */
 #define MSG_CMSG_CLOEXEC 0x40000000    /* Set close_on_exec for file
                                           descriptor received through
@@ -334,6 +335,8 @@ struct ucred {
 #define MSG_CMSG_COMPAT        0               /* We never have 32 bit fixups */
 #endif
 
+/* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */
+#define MSG_INTERNAL_SENDMSG_FLAGS (MSG_SPLICE_PAGES)
 
 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
 #define SOL_IP         0
index 57c626cb4d1a5c4aead326510f0925d036e65b9c..67f09a40bcb211a4d48184f63aba7d07e6d15f36 100644 (file)
@@ -389,6 +389,7 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
        if (flags & MSG_WAITALL)
                min_ret = iov_iter_count(&msg.msg_iter);
 
+       flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
        msg.msg_flags = flags;
        ret = sock_sendmsg(sock, &msg);
        if (ret < min_ret) {
@@ -1137,6 +1138,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
                msg_flags |= MSG_DONTWAIT;
        if (msg_flags & MSG_WAITALL)
                min_ret = iov_iter_count(&msg.msg_iter);
+       msg_flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
 
        msg.msg_flags = msg_flags;
        msg.msg_ubuf = &io_notif_to_data(zc->notif)->uarg;
index 0104617b440dc1250c2c58c635e3be08c3e9f51f..6f39f7b0cc85c838a171a2edb3759a19778199df 100644 (file)
@@ -2131,6 +2131,7 @@ int __sys_sendto(int fd, void __user *buff, size_t len, unsigned int flags,
                msg.msg_name = (struct sockaddr *)&address;
                msg.msg_namelen = addr_len;
        }
+       flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
        if (sock->file->f_flags & O_NONBLOCK)
                flags |= MSG_DONTWAIT;
        msg.msg_flags = flags;
@@ -2482,6 +2483,7 @@ static int ____sys_sendmsg(struct socket *sock, struct msghdr *msg_sys,
                msg_sys->msg_control = ctl_buf;
                msg_sys->msg_control_is_user = false;
        }
+       flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
        msg_sys->msg_flags = flags;
 
        if (sock->file->f_flags & O_NONBLOCK)