From: John Fastabend <john.fastabend@gmail.com>
To: Liu Jian <liujian56@huawei.com>,
john.fastabend@gmail.com, jakub@cloudflare.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, daniel@iogearbox.net, ast@kernel.org,
netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: liujian56@huawei.com
Subject: RE: [PATCH bpf] skmsg: schedule psock work if the cached skb exists on the psock
Date: Thu, 22 Sep 2022 11:19:49 -0700 [thread overview]
Message-ID: <632ca74533409_3c2b220835@john.notmuch> (raw)
In-Reply-To: <20220907071311.60534-1-liujian56@huawei.com>
Liu Jian wrote:
> In sk_psock_backlog function, for ingress direction skb, if no new data
> packet arrives after the skb is cached, the cached skb does not have a
> chance to be added to the receive queue of psock. As a result, the cached
> skb cannot be received by the upper-layer application.
>
> Fix this by reschedule the psock work to dispose the cached skb in
> sk_msg_recvmsg function.
>
> Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")
> Signed-off-by: Liu Jian <liujian56@huawei.com>
> ---
Yep thanks. We have another fix coming for a similar case with ENOMEM
through backlog. I'll post here before end of week.
Acked-by: John Fastabend <john.fastabend@gmail.com>
> net/core/skmsg.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/net/core/skmsg.c b/net/core/skmsg.c
> index 188f8558d27d..ca70525621c7 100644
> --- a/net/core/skmsg.c
> +++ b/net/core/skmsg.c
> @@ -434,8 +434,10 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
> if (copied + copy > len)
> copy = len - copied;
> copy = copy_page_to_iter(page, sge->offset, copy, iter);
> - if (!copy)
> - return copied ? copied : -EFAULT;
> + if (!copy) {
> + copied = copied ? copied : -EFAULT;
> + goto out;
> + }
>
> copied += copy;
> if (likely(!peek)) {
> @@ -455,7 +457,7 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
> * didn't copy the entire length lets just break.
> */
> if (copy != sge->length)
> - return copied;
> + goto out;
> sk_msg_iter_var_next(i);
> }
>
> @@ -477,7 +479,9 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
> }
> msg_rx = sk_psock_peek_msg(psock);
> }
> -
> +out:
> + if (psock->work_state.skb && copied > 0)
> + schedule_work(&psock->work);
> return copied;
> }
> EXPORT_SYMBOL_GPL(sk_msg_recvmsg);
> --
> 2.17.1
>
next prev parent reply other threads:[~2022-09-22 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 7:13 [PATCH bpf] skmsg: schedule psock work if the cached skb exists on the psock Liu Jian
2022-09-22 18:19 ` John Fastabend [this message]
2022-09-26 16:00 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=632ca74533409_3c2b220835@john.notmuch \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jakub@cloudflare.com \
--cc=kuba@kernel.org \
--cc=liujian56@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox