Skip to content

Commit 3667e9b

Browse files
qsnkuba-moo
authored andcommitted
selftests: tls: add test for short splice due to full skmsg
We don't have a test triggering a partial splice caused by a full skmsg. Add one, based on a program by Jann Horn. Use MAX_FRAGS=48 to make sure the skmsg will be full for any allowed value of CONFIG_MAX_SKB_FRAGS (17..45). Signed-off-by: Sabrina Dubroca <[email protected]> Link: https://patch.msgid.link/1d129a15f526ea3602f3a2b368aa0b6f7e0d35d5.1760432043.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f95fce1 commit 3667e9b

File tree

1 file changed

+31
-0
lines changed
  • tools/testing/selftests/net

1 file changed

+31
-0
lines changed

tools/testing/selftests/net/tls.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,37 @@ TEST_F(tls, peek_and_splice)
946946
EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0);
947947
}
948948

949+
#define MAX_FRAGS 48
950+
TEST_F(tls, splice_short)
951+
{
952+
struct iovec sendchar_iov;
953+
char read_buf[0x10000];
954+
char sendbuf[0x100];
955+
char sendchar = 'S';
956+
int pipefds[2];
957+
int i;
958+
959+
sendchar_iov.iov_base = &sendchar;
960+
sendchar_iov.iov_len = 1;
961+
962+
memset(sendbuf, 's', sizeof(sendbuf));
963+
964+
ASSERT_GE(pipe2(pipefds, O_NONBLOCK), 0);
965+
ASSERT_GE(fcntl(pipefds[0], F_SETPIPE_SZ, (MAX_FRAGS + 1) * 0x1000), 0);
966+
967+
for (i = 0; i < MAX_FRAGS; i++)
968+
ASSERT_GE(vmsplice(pipefds[1], &sendchar_iov, 1, 0), 0);
969+
970+
ASSERT_EQ(write(pipefds[1], sendbuf, sizeof(sendbuf)), sizeof(sendbuf));
971+
972+
EXPECT_EQ(splice(pipefds[0], NULL, self->fd, NULL, MAX_FRAGS + 0x1000, 0),
973+
MAX_FRAGS + sizeof(sendbuf));
974+
EXPECT_EQ(recv(self->cfd, read_buf, sizeof(read_buf), 0), MAX_FRAGS + sizeof(sendbuf));
975+
EXPECT_EQ(recv(self->cfd, read_buf, sizeof(read_buf), MSG_DONTWAIT), -1);
976+
EXPECT_EQ(errno, EAGAIN);
977+
}
978+
#undef MAX_FRAGS
979+
949980
TEST_F(tls, recvmsg_single)
950981
{
951982
char const *test_str = "test_recvmsg_single";

0 commit comments

Comments
 (0)