Skip to content

Commit ccd1479

Browse files
committed
Merge branch 'net-tls-fix-poll-wake-up'
Jakub Kicinski says: ==================== net/tls: fix poll() wake up This small fix + selftest series is very similar to the previous commit 04b25a5 ("net/tls: fix no wakeup on partial reads"). This time instead of recvmsg we're fixing poll wake up. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 537de0c + 81a89ef commit ccd1479

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

net/tls/tls_sw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,8 @@ bool tls_sw_stream_read(const struct sock *sk)
19581958
ingress_empty = list_empty(&psock->ingress_msg);
19591959
rcu_read_unlock();
19601960

1961-
return !ingress_empty || ctx->recv_pkt;
1961+
return !ingress_empty || ctx->recv_pkt ||
1962+
!skb_queue_empty(&ctx->rx_list);
19621963
}
19631964

19641965
static int tls_read_size(struct strparser *strp, struct sk_buff *skb)

tools/testing/selftests/net/tls.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,32 @@ TEST_F(tls, poll_wait)
644644
EXPECT_EQ(recv(self->cfd, recv_mem, send_len, MSG_WAITALL), send_len);
645645
}
646646

647+
TEST_F(tls, poll_wait_split)
648+
{
649+
struct pollfd fd = { 0, 0, 0 };
650+
char send_mem[20] = {};
651+
char recv_mem[15];
652+
653+
fd.fd = self->cfd;
654+
fd.events = POLLIN;
655+
/* Send 20 bytes */
656+
EXPECT_EQ(send(self->fd, send_mem, sizeof(send_mem), 0),
657+
sizeof(send_mem));
658+
/* Poll with inf. timeout */
659+
EXPECT_EQ(poll(&fd, 1, -1), 1);
660+
EXPECT_EQ(fd.revents & POLLIN, 1);
661+
EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), MSG_WAITALL),
662+
sizeof(recv_mem));
663+
664+
/* Now the remaining 5 bytes of record data are in TLS ULP */
665+
fd.fd = self->cfd;
666+
fd.events = POLLIN;
667+
EXPECT_EQ(poll(&fd, 1, -1), 1);
668+
EXPECT_EQ(fd.revents & POLLIN, 1);
669+
EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0),
670+
sizeof(send_mem) - sizeof(recv_mem));
671+
}
672+
647673
TEST_F(tls, blocking)
648674
{
649675
size_t data = 100000;

0 commit comments

Comments
 (0)