Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Felipe Pereira Stival via B4 Rel...
Wed, 18 Nov 2026 20:35
[PATCH net 2/2] selftests: tls: add a poll test for a queued KeyUpdate
Author: Felipe Pereira Stival via B4 Rel...
Date: Wed, 18 Nov 2026 20:35
Date: Wed, 18 Nov 2026 20:35
67 lines
12520 bytes
12520 bytes
From: Felipe Pereira Stival <v0idpwn@gmail.com>
Check that poll() reports a read event when a recv() for data has
decrypted and queued a KeyUpdate. Once the KeyUpdate has been read,
check that poll() doesn't report a record sent with the new key.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Felipe Pereira Stival <v0idpwn@gmail.com>
---
tools/testing/selftests/net/tls.c | 40 +++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index bd2797f9f61..59e403b5f12 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -2421,6 +2421,46 @@ TEST_F(tls, rekey_poll_delay)
}
}
+TEST_F(tls, rekey_poll_queued)
+{
+ char const *test_str = "test_message";
+ struct tls_crypto_info_keys tls12;
+ struct pollfd pfd = { };
+ char buf[100];
+ int send_len;
+
+ if (self->notls)
+ SKIP(return, "no TLS support");
+
+ if (variant->tls_version != TLS_1_3_VERSION)
+ return;
+
+ /* data followed by a KeyUpdate */
+ send_len = strlen(test_str) + 1;
+ EXPECT_EQ(send(self->fd, test_str, send_len, 0), send_len);
+ tls_send_keyupdate(_metadata, self->fd);
+
+ /* reading the data decrypts the KeyUpdate and leaves it queued */
+ EXPECT_EQ(recv(self->cfd, buf, sizeof(buf), MSG_WAITALL), send_len);
+ EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
+
+ /* KeyUpdate hasn't been read, expect cfd to be readable */
+ pfd.fd = self->cfd;
+ pfd.events = POLLIN;
+ EXPECT_EQ(poll(&pfd, 1, 0), 1);
+
+ /* get KeyUpdate */
+ tls_recv_keyupdate(_metadata, self->cfd, 0);
+
+ /* update TX key and send with it */
+ tls_crypto_info_init(variant->tls_version, variant->cipher_type, &tls12, 1);
+ EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, tls12.len), 0);
+ EXPECT_EQ(send(self->fd, test_str, send_len, 0), send_len);
+
+ /* key hasn't been updated, expect cfd to be non-readable */
+ EXPECT_EQ(poll(&pfd, 1, 0), 0);
+}
+
struct raw_rec {
unsigned int plain_len;
unsigned char plain_data[100];
--
2.56.0
Re: [PATCH net 2/2] selftests: tls: add a poll test for a queued KeyUpdate
Author: Simon Horman
Date: Wed, 25 Nov 2026 12:36
Date: Wed, 25 Nov 2026 12:36
10 lines
8442 bytes
8442 bytes
On Wed, Nov 18, 2026 at 05:35:49PM -0300, Felipe Pereira Stival wrote: > Check that poll() reports a read event when a recv() for data has > decrypted and queued a KeyUpdate. Once the KeyUpdate has been read, > check that poll() doesn't report a record sent with the new key. > > Assisted-by: Claude:claude-fable-5-2 > Signed-off-by: Felipe Pereira Stival <v0idpwn@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org>
Re: [PATCH net 2/2] selftests: tls: add a poll test for a queued KeyUpdate
Author: Sabrina Dubroca
Date: Wed, 25 Nov 2026 16:40
Date: Wed, 25 Nov 2026 16:40
18 lines
13554 bytes
13554 bytes
2026-11-18, 17:35:49 -0300, Felipe Pereira Stival via B4 Relay wrote: > From: Felipe Pereira Stival <v0idpwn@gmail.com> > > Check that poll() reports a read event when a recv() for data has > decrypted and queued a KeyUpdate. Once the KeyUpdate has been read, > check that poll() doesn't report a record sent with the new key. > > Assisted-by: Claude:claude-fable-5-2 > Signed-off-by: Felipe Pereira Stival <v0idpwn@gmail.com> > --- > tools/testing/selftests/net/tls.c | 40 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> -- Sabrina
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads