From: David S. Miller Date: Tue, 18 Sep 2018 16:33:27 +0000 (-0700) Subject: Merge ra.kernel.org:/pub/scm/linux/kernel/git/davem/net X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e366fa435032db1ce1538a2c029714666985dd48;p=linux.git Merge ra./pub/scm/linux/kernel/git/davem/net Two new tls tests added in parallel in both net and net-next. Used Stephen Rothwell's linux-next resolution. Signed-off-by: David S. Miller --- e366fa435032db1ce1538a2c029714666985dd48 diff --cc net/tls/tls_sw.c index f4aa7cdb01cab,b9c6ecfbcfea7..5ff51bac8b469 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@@ -1106,9 -930,14 +1106,16 @@@ pick_next_record msg->msg_flags |= MSG_EOR; if (control != TLS_RECORD_TYPE_DATA) goto recv_end; + } else { + break; } + } else { + /* MSG_PEEK right now cannot look beyond current skb + * from strparser, meaning we cannot advance skb here + * and thus unpause strparser since we'd loose original + * one. + */ + break; } /* If we have a new message from strparser, continue now. */ diff --cc tools/testing/selftests/net/tls.c index 96fc6fe702939,8fdfeafaf8c00..11d54c36ae49a --- a/tools/testing/selftests/net/tls.c +++ b/tools/testing/selftests/net/tls.c @@@ -502,28 -502,55 +502,78 @@@ TEST_F(tls, recv_peek_multiple EXPECT_EQ(memcmp(test_str, buf, send_len), 0); } + TEST_F(tls, recv_peek_multiple_records) + { + char const *test_str = "test_read_peek_mult_recs"; + char const *test_str_first = "test_read_peek"; + char const *test_str_second = "_mult_recs"; + int len; + char buf[64]; + + len = strlen(test_str_first); + EXPECT_EQ(send(self->fd, test_str_first, len, 0), len); + + len = strlen(test_str_second) + 1; + EXPECT_EQ(send(self->fd, test_str_second, len, 0), len); + + len = sizeof(buf); + memset(buf, 0, len); + EXPECT_NE(recv(self->cfd, buf, len, MSG_PEEK), -1); + + /* MSG_PEEK can only peek into the current record. */ + len = strlen(test_str_first) + 1; + EXPECT_EQ(memcmp(test_str_first, buf, len), 0); + + len = sizeof(buf); + memset(buf, 0, len); + EXPECT_NE(recv(self->cfd, buf, len, 0), -1); + + /* Non-MSG_PEEK will advance strparser (and therefore record) + * however. + */ + len = strlen(test_str) + 1; + EXPECT_EQ(memcmp(test_str, buf, len), 0); + + /* MSG_MORE will hold current record open, so later MSG_PEEK + * will see everything. + */ + len = strlen(test_str_first); + EXPECT_EQ(send(self->fd, test_str_first, len, MSG_MORE), len); + + len = strlen(test_str_second) + 1; + EXPECT_EQ(send(self->fd, test_str_second, len, 0), len); + + len = sizeof(buf); + memset(buf, 0, len); + EXPECT_NE(recv(self->cfd, buf, len, MSG_PEEK), -1); + + len = strlen(test_str) + 1; + EXPECT_EQ(memcmp(test_str, buf, len), 0); + } + +TEST_F(tls, recv_peek_large_buf_mult_recs) +{ + char const *test_str = "test_read_peek_mult_recs"; + char const *test_str_first = "test_read_peek"; + char const *test_str_second = "_mult_recs"; + int len; + char buf[64]; + + len = strlen(test_str_first); + EXPECT_EQ(send(self->fd, test_str_first, len, 0), len); + + len = strlen(test_str_second) + 1; + EXPECT_EQ(send(self->fd, test_str_second, len, 0), len); + + len = sizeof(buf); + memset(buf, 0, len); + EXPECT_NE(recv(self->cfd, buf, len, MSG_PEEK), -1); + + len = strlen(test_str) + 1; + EXPECT_EQ(memcmp(test_str, buf, len), 0); +} + ++ TEST_F(tls, pollin) { char const *test_str = "test_poll";