RE: [Patch bpf v2 3/4] net: implement ->sock_is_readable for UDP and AF_UNIX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cong Wang wrote:
> From: Cong Wang <cong.wang@xxxxxxxxxxxxx>
> 
> 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@xxxxxxxxx>
> Cc: John Fastabend <john.fastabend@xxxxxxxxx>
> Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
> Cc: Jakub Sitnicki <jakub@xxxxxxxxxxxxxx>
> Cc: Lorenz Bauer <lmb@xxxxxxxxxxxxxx>
> Signed-off-by: Cong Wang <cong.wang@xxxxxxxxxxxxx>
> ---

[...]
  
>  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);

[...]



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux