bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>, netdev@vger.kernel.org
Cc: bpf@vger.kernel.org, Cong Wang <cong.wang@bytedance.com>,
	Yucong Sun <sunyucong@gmail.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jakub Sitnicki <jakub@cloudflare.com>,
	Lorenz Bauer <lmb@cloudflare.com>
Subject: RE: [Patch bpf v2 3/4] net: implement ->sock_is_readable for UDP and AF_UNIX
Date: Thu, 30 Sep 2021 14:44:00 -0700	[thread overview]
Message-ID: <61562fa0b3f74_6c4e4208c1@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20210928002212.14498-4-xiyou.wangcong@gmail.com>

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. Now we can overwrite >sock_is_readable() and
> implement and invoke it for UDP and AF_UNIX sockets.

nit: instead of 'because we never poll any psock queue...' how about
'because we do not poll the psock queues in ->poll(), except
for TCP.'
> 
> 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>
> ---

[...]
  
>  static inline void sk_msg_check_to_free(struct sk_msg *msg, u32 i, u32 bytes)
>  {
> diff --git a/net/core/skmsg.c b/net/core/skmsg.c
> index 2d6249b28928..93ae48581ad2 100644
> --- a/net/core/skmsg.c
> +++ b/net/core/skmsg.c
> @@ -474,6 +474,20 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
>  }
>  EXPORT_SYMBOL_GPL(sk_msg_recvmsg);
>  
> +bool sk_msg_is_readable(struct sock *sk)
> +{
> +	struct sk_psock *psock;
> +	bool empty = true;
> +
> +	psock = sk_psock_get_checked(sk);

We shouldn't need the checked version here right? We only get here because
we hooked the sk with the callbacks from *_bpf_rebuild_rpotos. Then we
can just use sk_psock() and save a few extra insns/branch.

> +	if (IS_ERR_OR_NULL(psock))
> +		return false;
> +	empty = sk_psock_queue_empty(psock);
> +	sk_psock_put(sk, psock);
> +	return !empty;
> +}
> +EXPORT_SYMBOL_GPL(sk_msg_is_readable);

[...]

  reply	other threads:[~2021-09-30 21:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28  0:22 [Patch bpf v2 0/4] sock_map: fix ->poll() and update selftests Cong Wang
2021-09-28  0:22 ` [Patch bpf v2 1/4] skmsg: introduce sk_psock_get_checked() Cong Wang
2021-09-28  0:22 ` [Patch bpf v2 2/4] net: rename ->stream_memory_read to ->sock_is_readable Cong Wang
2021-09-28  0:22 ` [Patch bpf v2 3/4] net: implement ->sock_is_readable for UDP and AF_UNIX Cong Wang
2021-09-30 21:44   ` John Fastabend [this message]
2021-10-02  0:00     ` Cong Wang
2021-09-28  0:22 ` [Patch bpf v2 4/4] selftests/bpf: use recv_timeout() instead of retries Cong Wang

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=61562fa0b3f74_6c4e4208c1@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=daniel@iogearbox.net \
    --cc=jakub@cloudflare.com \
    --cc=lmb@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=sunyucong@gmail.com \
    --cc=xiyou.wangcong@gmail.com \
    --subject='RE: [Patch bpf v2 3/4] net: implement ->sock_is_readable for UDP and AF_UNIX' \
    /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

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).