bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>, Cong Wang <cong.wang@bytedance.com>,
	Yucong Sun <sunyucong@gmail.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Jakub Sitnicki <jakub@cloudflare.com>,
	Lorenz Bauer <lmb@cloudflare.com>
Subject: Re: [Patch bpf v3 3/4] net: implement ->sock_is_readable() for UDP and AF_UNIX
Date: Thu, 7 Oct 2021 13:53:25 -0700	[thread overview]
Message-ID: <CAM_iQpXy5HOHOU=T_FVVydBniL=tOW9sYTAMsc_nRWcZsqo8Yg@mail.gmail.com> (raw)
In-Reply-To: <582ff8e9-c7b7-88c1-6cf0-e143da92836f@iogearbox.net>

On Thu, Oct 7, 2021 at 1:00 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 10/2/21 2:37 AM, Cong Wang wrote:
> > From: Cong Wang <cong.wang@bytedance.com>
> >
> > Yucong noticed we can't poll() sockets in sockmap even
> > when they are the destination sockets of redirections.
> > This is because we never poll any psock queues in ->poll(),
> > except for TCP. With ->sock_is_readable() now we can
> > overwrite >sock_is_readable(), invoke and implement it for
> > both UDP and AF_UNIX sockets.
> >
> > Reported-by: Yucong Sun <sunyucong@gmail.com>
> > Cc: John Fastabend <john.fastabend@gmail.com>
> > Cc: Daniel Borkmann <daniel@iogearbox.net>
> > Cc: Jakub Sitnicki <jakub@cloudflare.com>
> > Cc: Lorenz Bauer <lmb@cloudflare.com>
> > Signed-off-by: Cong Wang <cong.wang@bytedance.com>
> > ---
> >   net/ipv4/udp.c      | 2 ++
> >   net/ipv4/udp_bpf.c  | 1 +
> >   net/unix/af_unix.c  | 4 ++++
> >   net/unix/unix_bpf.c | 2 ++
> >   4 files changed, 9 insertions(+)
> >
> > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> > index 2a7825a5b842..4a7e15a43a68 100644
> > --- a/net/ipv4/udp.c
> > +++ b/net/ipv4/udp.c
> > @@ -2866,6 +2866,8 @@ __poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait)
> >           !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1)
> >               mask &= ~(EPOLLIN | EPOLLRDNORM);
> >
> > +     if (sk_is_readable(sk))
> > +             mask |= EPOLLIN | EPOLLRDNORM;
>
> udp_poll() has this extra logic around first_packet_length() which drops all bad csum'ed
> skbs. How does this stand in relation to sk_msg_is_readable()? Is this a concern as well
> there? Maybe makes sense to elaborate a bit more in the commit message for context / future
> reference.

We don't validate UDP checksums on sockmap RX path, so
it is okay to leave it as it is, but it is worth a comment like
you suggest. I will add a comment in this code.

If we really need to validate the checksum, it should be addressed
in a separate patch(set), not in this one.

Thanks.

  reply	other threads:[~2021-10-07 20:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-02  0:37 [Patch bpf v3 0/4] sock_map: fix ->poll() and update selftests Cong Wang
2021-10-02  0:37 ` [Patch bpf v3 1/4] net: rename ->stream_memory_read to ->sock_is_readable Cong Wang
2021-10-02  0:37 ` [Patch bpf v3 2/4] skmsg: extract and reuse sk_msg_is_readable() Cong Wang
2021-10-02  0:37 ` [Patch bpf v3 3/4] net: implement ->sock_is_readable() for UDP and AF_UNIX Cong Wang
2021-10-07 20:00   ` Daniel Borkmann
2021-10-07 20:53     ` Cong Wang [this message]
2021-10-08 15:26       ` John Fastabend
2021-10-02  0:37 ` [Patch bpf v3 4/4] selftests/bpf: use recv_timeout() instead of retries Cong Wang
2021-10-06 15:24 ` [Patch bpf v3 0/4] sock_map: fix ->poll() and update selftests John Fastabend

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='CAM_iQpXy5HOHOU=T_FVVydBniL=tOW9sYTAMsc_nRWcZsqo8Yg@mail.gmail.com' \
    --to=xiyou.wangcong@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=daniel@iogearbox.net \
    --cc=jakub@cloudflare.com \
    --cc=john.fastabend@gmail.com \
    --cc=lmb@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=sunyucong@gmail.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;
as well as URLs for NNTP newsgroup(s).