Subject: Re: [PATCH bpf v6 06/12] bpf: sockmap, wake up polling after data copy

From: Jakub Sitnicki <[email-masked]>
Date: Thu, 13 Apr 2023 15:00:02 +0200

On Fri, Apr 07, 2023 at 10:16 AM -07, John Fastabend wrote:
> When TCP stack has data ready to read sk_data_ready() is called. Sockmap
> overwrites this with its own handler to call into BPF verdict program.
> But, the original TCP socket had sock_def_readable that would additionally
> wake up any user space waiters with sk_wake_async().
>
> Sockmap saved the callback when the socket was created so call the saved
> data ready callback and then we can wake up any epoll() logic waiting
> on the read.
>
> Note we call on 'copied >= 0' to account for returning 0 when a FIN is
> received because we need to wake up user for this as well so they
> can do the recvmsg() -> 0 and detect the shutdown.
>
> Fixes: 04919bed948dc ("tcp: Introduce tcp_read_skb()")
> Signed-off-by: John Fastabend <[email-masked]>
> ---

One observation. On the happy path, we will be hitting the recently
introduced sk_data_ready tracepoint [1] twice. However, we have the
caller IP there, so we can differentiate.

[1] 40e0b0908142 ("net/sock: Introduce trace_sk_data_ready()")

Reviewed-by: Jakub Sitnicki <[email-masked]>