aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-05-24 17:34:33 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-04 05:59:44 (GMT)
commit9904c83d0c50ca46a61a45f52fcddca6c5ea9d95 (patch)
treeb7a281758de2d4d9170dbed4548d953a9ca93b31
parent4e0cec52467d7148b9bfa14cc77afd322861ab06 (diff)
downloadkernel_replicant_linux-9904c83d0c50ca46a61a45f52fcddca6c5ea9d95.zip
kernel_replicant_linux-9904c83d0c50ca46a61a45f52fcddca6c5ea9d95.tar.gz
kernel_replicant_linux-9904c83d0c50ca46a61a45f52fcddca6c5ea9d95.tar.bz2
selftests/tls: add test for sleeping even though there is data
[ Upstream commit 043556d0917a1a5ea58795fe1656a2bce06d2649 ] Add a test which sends 15 bytes of data, and then tries to read 10 byes twice. Previously the second read would sleep indifinitely, since the record was already decrypted and there is only 5 bytes left, not full 10. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--tools/testing/selftests/net/tls.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index 01efbcd..278c861 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -442,6 +442,21 @@ TEST_F(tls, multiple_send_single_recv)
EXPECT_EQ(memcmp(send_mem, recv_mem + send_len, send_len), 0);
}
+TEST_F(tls, single_send_multiple_recv_non_align)
+{
+ const unsigned int total_len = 15;
+ const unsigned int recv_len = 10;
+ char recv_mem[recv_len * 2];
+ char send_mem[total_len];
+
+ EXPECT_GE(send(self->fd, send_mem, total_len, 0), 0);
+ memset(recv_mem, 0, total_len);
+
+ EXPECT_EQ(recv(self->cfd, recv_mem, recv_len, 0), recv_len);
+ EXPECT_EQ(recv(self->cfd, recv_mem + recv_len, recv_len, 0), 5);
+ EXPECT_EQ(memcmp(send_mem, recv_mem, total_len), 0);
+}
+
TEST_F(tls, recv_partial)
{
char const *test_str = "test_read_partial";