[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <b9b17f87-007f-3ef9-d9e3-3080749cf01f@I-love.SAKURA.ne.jp>
Date: Sat, 8 Jul 2023 08:45:50 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: David Howells <dhowells@...hat.com>, Jakub Kicinski <kuba@...nel.org>
Cc: David Ahern <dsahern@...nel.org>, Jens Axboe <axboe@...nel.dk>,
Matthew Wilcox <willy@...radead.org>,
Network Development <netdev@...r.kernel.org>
Subject: [possible regression in 6.5-rc1] sendmsg()/splice() returns EBADMSG
(Branched from https://lkml.kernel.org/r/63006262-f808-50ab-97b8-c2193c7a9ba1@I-love.SAKURA.ne.jp .)
I found that the following program started returning EBADMSG. Bisection for sendmsg() reached
commit c5c37af6ecad ("tcp: Convert do_tcp_sendpages() to use MSG_SPLICE_PAGES") and bisection
for splice() reached commit 2dc334f1a63a ("splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather
than ->sendpage()"). Is this program doing something wrong?
6.4.0-rc5-00892-g2dc334f1a63a-dirty argc==1 ? splice()=EBADMSG, sendmsg()=EBADMSG : sendmsg()=success, splice()=EBADMSG
6.4.0-rc5-00891-g81840b3b91aa-dirty argc==1 ? splice()=success, sendmsg()=EBADMSG : sendmsg()=success, splice()=success
6.4.0-rc2-00520-gc5c37af6ecad-dirty argc==1 ? splice()=success, sendmsg()=EBADMSG : sendmsg()=success, splice()=success
6.4.0-rc2-00519-g270a1c3de47e-dirty argc==1 ? splice()=success, sendmsg()=success : sendmsg()=success, splice()=success
----------------------------------------
#define _GNU_SOURCE
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#define SOL_TCP 6
#define TCP_REPAIR 19
#define TCP_ULP 31
#define TLS_TX 1
int main(int argc, char *argv[])
{
struct iovec iov = {
.iov_base = "@@@@@@@@@@@@@@@@",
.iov_len = 16
};
struct msghdr hdr = {
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_flags = MSG_FASTOPEN
};
const struct sockaddr_in6 addr = { .sin6_family = AF_INET6, .sin6_addr = in6addr_loopback };
const int one = 1;
int ret_ignored = 0;
const int fd = socket(PF_INET6, SOCK_STREAM, IPPROTO_IP);
int pipe_fds[2] = { -1, -1 };
static char buf[32768] = { };
ret_ignored += pipe(pipe_fds);
setsockopt(fd, SOL_TCP, TCP_REPAIR, &one, sizeof(one));
connect(fd, (struct sockaddr *) &addr, sizeof(addr));
setsockopt(fd, SOL_TCP, TCP_ULP, "tls", 4);
setsockopt(fd, SOL_TLS, TLS_TX,"\3\0035\0%T\244\205\333\f0\362B\221\243\234\206\216\220\243u\347\342P|1\24}Q@\377\227\353\222B\354\264u[\346", 40);
ret_ignored += write(pipe_fds[1], buf, 2432);
ret_ignored += write(pipe_fds[1], buf, 10676);
ret_ignored += write(pipe_fds[1], buf, 17996);
if (argc == 1) {
ret_ignored += splice(pipe_fds[0], NULL, fd, NULL, 1048576, SPLICE_F_MORE);
ret_ignored += sendmsg(fd, &hdr, MSG_DONTWAIT | MSG_MORE);
} else {
ret_ignored += sendmsg(fd, &hdr, MSG_DONTWAIT | MSG_MORE);
ret_ignored += splice(pipe_fds[0], NULL, fd, NULL, 1048576, SPLICE_F_MORE);
}
return ret_ignored * 0;
}
----------------------------------------
Powered by blists - more mailing lists