diff options
| author | Sabrina Dubroca <sd@queasysnail.net> | 2025-10-14 12:17:01 +0300 | 
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2025-10-16 03:41:45 +0300 | 
| commit | f95fce1e953b8a7af3fbad84aaffe92804196e2d (patch) | |
| tree | 3abce67757009e011f38ed1f99aa186dd80e3950 | |
| parent | 7f846c65ca11e63d2409868ff039081f80e42ae4 (diff) | |
| download | linux-f95fce1e953b8a7af3fbad84aaffe92804196e2d.tar.xz | |
selftests: net: tls: add tests for cmsg vs MSG_MORE
We don't have a test to check that MSG_MORE won't let us merge records
of different types across sendmsg calls.
Add new tests that check:
 - MSG_MORE is only allowed for DATA records
 - a pending DATA record gets closed and pushed before a non-DATA
   record is processed
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/b34feeadefe8a997f068d5ed5617afd0072df3c0.1760432043.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | tools/testing/selftests/net/tls.c | 34 | 
1 files changed, 34 insertions, 0 deletions
| diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c index e788b84551ca..77e4e30b46cc 100644 --- a/tools/testing/selftests/net/tls.c +++ b/tools/testing/selftests/net/tls.c @@ -564,6 +564,40 @@ TEST_F(tls, msg_more)  	EXPECT_EQ(memcmp(buf, test_str, send_len), 0);  } +TEST_F(tls, cmsg_msg_more) +{ +	char *test_str =  "test_read"; +	char record_type = 100; +	int send_len = 10; + +	/* we don't allow MSG_MORE with non-DATA records */ +	EXPECT_EQ(tls_send_cmsg(self->fd, record_type, test_str, send_len, +				MSG_MORE), -1); +	EXPECT_EQ(errno, EINVAL); +} + +TEST_F(tls, msg_more_then_cmsg) +{ +	char *test_str = "test_read"; +	char record_type = 100; +	int send_len = 10; +	char buf[10 * 2]; +	int ret; + +	EXPECT_EQ(send(self->fd, test_str, send_len, MSG_MORE), send_len); +	EXPECT_EQ(recv(self->cfd, buf, send_len, MSG_DONTWAIT), -1); + +	ret = tls_send_cmsg(self->fd, record_type, test_str, send_len, 0); +	EXPECT_EQ(ret, send_len); + +	/* initial DATA record didn't get merged with the non-DATA record */ +	EXPECT_EQ(recv(self->cfd, buf, send_len * 2, 0), send_len); + +	EXPECT_EQ(tls_recv_cmsg(_metadata, self->cfd, record_type, +				buf, sizeof(buf), MSG_WAITALL), +		  send_len); +} +  TEST_F(tls, msg_more_unsent)  {  	char const *test_str = "test_read"; | 
