Skip to content

Commit b841b90

Browse files
dhowellskuba-moo
authored andcommitted
net: Declare MSG_SPLICE_PAGES internal sendmsg() flag
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 <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> cc: Jens Axboe <[email protected]> cc: Matthew Wilcox <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 57910a4 commit b841b90

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

include/linux/socket.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ struct ucred {
327327
*/
328328

329329
#define MSG_ZEROCOPY 0x4000000 /* Use user data in kernel path */
330+
#define MSG_SPLICE_PAGES 0x8000000 /* Splice the pages from the iterator in sendmsg() */
330331
#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
331332
#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file
332333
descriptor received through
@@ -337,6 +338,8 @@ struct ucred {
337338
#define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */
338339
#endif
339340

341+
/* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */
342+
#define MSG_INTERNAL_SENDMSG_FLAGS (MSG_SPLICE_PAGES)
340343

341344
/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
342345
#define SOL_IP 0

io_uring/net.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
389389
if (flags & MSG_WAITALL)
390390
min_ret = iov_iter_count(&msg.msg_iter);
391391

392+
flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
392393
msg.msg_flags = flags;
393394
ret = sock_sendmsg(sock, &msg);
394395
if (ret < min_ret) {
@@ -1136,6 +1137,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
11361137
msg_flags |= MSG_DONTWAIT;
11371138
if (msg_flags & MSG_WAITALL)
11381139
min_ret = iov_iter_count(&msg.msg_iter);
1140+
msg_flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
11391141

11401142
msg.msg_flags = msg_flags;
11411143
msg.msg_ubuf = &io_notif_to_data(zc->notif)->uarg;

net/socket.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,7 @@ int __sys_sendto(int fd, void __user *buff, size_t len, unsigned int flags,
21382138
msg.msg_name = (struct sockaddr *)&address;
21392139
msg.msg_namelen = addr_len;
21402140
}
2141+
flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
21412142
if (sock->file->f_flags & O_NONBLOCK)
21422143
flags |= MSG_DONTWAIT;
21432144
msg.msg_flags = flags;
@@ -2483,6 +2484,7 @@ static int ____sys_sendmsg(struct socket *sock, struct msghdr *msg_sys,
24832484
msg_sys->msg_control = ctl_buf;
24842485
msg_sys->msg_control_is_user = false;
24852486
}
2487+
flags &= ~MSG_INTERNAL_SENDMSG_FLAGS;
24862488
msg_sys->msg_flags = flags;
24872489

24882490
if (sock->file->f_flags & O_NONBLOCK)

0 commit comments

Comments
 (0)