Skip to content

Commit

Permalink
tls splice: check SPLICE_F_NONBLOCK instead of MSG_DONTWAIT
Browse files Browse the repository at this point in the history
In tls_sw_splice_read, checkout MSG_* is inappropriate, should use
SPLICE_*, update tls_wait_data to accept nonblock arguments instead
of flags for recvmsg and splice.

Fixes: c46234e ("tls: RX path for ktls")
Signed-off-by: Jim Ma <majinjing3@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
jim3ma authored and davem330 committed May 14, 2021
1 parent 7501689 commit 974271e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions net/tls/tls_sw.c
Expand Up @@ -37,6 +37,7 @@

#include <linux/sched/signal.h>
#include <linux/module.h>
#include <linux/splice.h>
#include <crypto/aead.h>

#include <net/strparser.h>
Expand Down Expand Up @@ -1281,7 +1282,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
}

static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
int flags, long timeo, int *err)
bool nonblock, long timeo, int *err)
{
struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
Expand All @@ -1306,7 +1307,7 @@ static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
if (sock_flag(sk, SOCK_DONE))
return NULL;

if ((flags & MSG_DONTWAIT) || !timeo) {
if (nonblock || !timeo) {
*err = -EAGAIN;
return NULL;
}
Expand Down Expand Up @@ -1786,7 +1787,7 @@ int tls_sw_recvmsg(struct sock *sk,
bool async_capable;
bool async = false;

skb = tls_wait_data(sk, psock, flags, timeo, &err);
skb = tls_wait_data(sk, psock, flags & MSG_DONTWAIT, timeo, &err);
if (!skb) {
if (psock) {
int ret = sk_msg_recvmsg(sk, psock, msg, len,
Expand Down Expand Up @@ -1990,9 +1991,9 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,

lock_sock(sk);

timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
timeo = sock_rcvtimeo(sk, flags & SPLICE_F_NONBLOCK);

skb = tls_wait_data(sk, NULL, flags, timeo, &err);
skb = tls_wait_data(sk, NULL, flags & SPLICE_F_NONBLOCK, timeo, &err);
if (!skb)
goto splice_read_end;

Expand Down

0 comments on commit 974271e

Please sign in to comment.