Skip to content

Commit 552de91

Browse files
jrfastabborkmann
authored andcommitted
bpf: sk_msg, fix socket data_ready events
When a skb verdict program is in-use and either another BPF program redirects to that socket or the new SK_PASS support is used the data_ready callback does not wake up application. Instead because the stream parser/verdict is using the sk data_ready callback we wake up the stream parser/verdict block. Fix this by adding a helper to check if the stream parser block is enabled on the sk and if so call the saved pointer which is the upper layers wake up function. This fixes application stalls observed when an application is waiting for data in a blocking read(). Fixes: d829e9c ("tls: convert to generic sk_msg interface") Signed-off-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 5119940 commit 552de91

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

include/linux/skmsg.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,14 @@ static inline void sk_psock_put(struct sock *sk, struct sk_psock *psock)
417417
sk_psock_drop(sk, psock);
418418
}
419419

420+
static inline void sk_psock_data_ready(struct sock *sk, struct sk_psock *psock)
421+
{
422+
if (psock->parser.enabled)
423+
psock->parser.saved_data_ready(sk);
424+
else
425+
sk->sk_data_ready(sk);
426+
}
427+
420428
static inline void psock_set_prog(struct bpf_prog **pprog,
421429
struct bpf_prog *prog)
422430
{

net/core/skmsg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb)
403403
msg->skb = skb;
404404

405405
sk_psock_queue_msg(psock, msg);
406-
sk->sk_data_ready(sk);
406+
sk_psock_data_ready(sk, psock);
407407
return copied;
408408
}
409409

@@ -751,7 +751,7 @@ static int sk_psock_strp_parse(struct strparser *strp, struct sk_buff *skb)
751751
}
752752

753753
/* Called with socket lock held. */
754-
static void sk_psock_data_ready(struct sock *sk)
754+
static void sk_psock_strp_data_ready(struct sock *sk)
755755
{
756756
struct sk_psock *psock;
757757

@@ -799,7 +799,7 @@ void sk_psock_start_strp(struct sock *sk, struct sk_psock *psock)
799799
return;
800800

801801
parser->saved_data_ready = sk->sk_data_ready;
802-
sk->sk_data_ready = sk_psock_data_ready;
802+
sk->sk_data_ready = sk_psock_strp_data_ready;
803803
sk->sk_write_space = sk_psock_write_space;
804804
parser->enabled = true;
805805
}

net/ipv4/tcp_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
198198
msg->sg.start = i;
199199
msg->sg.size -= apply_bytes;
200200
sk_psock_queue_msg(psock, tmp);
201-
sk->sk_data_ready(sk);
201+
sk_psock_data_ready(sk, psock);
202202
} else {
203203
sk_msg_free(sk, tmp);
204204
kfree(tmp);

0 commit comments

Comments
 (0)