netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] xsk: skip polling event check for unbound socket
@ 2023-12-01  6:10 Yewon Choi
  2023-12-05  9:03 ` Magnus Karlsson
  2023-12-05 12:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Yewon Choi @ 2023-12-01  6:10 UTC (permalink / raw)
  To: Björn Töpel, Magnus Karlsson, Maciej Fijalkowski,
	Jonathan Lemon, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, netdev, bpf, linux-kernel
  Cc: threeearcat

In xsk_poll(), checking available events and setting mask bits should
be executed only when a socket has been bound. Setting mask bits for
unbound socket is meaningless.
Currently, it checks events even when xsk_check_common() failed.
To prevent this, we move goto location (skip_tx) after that checking.

Fixes: 1596dae2f17e ("xsk: check IFF_UP earlier in Tx path")
Signed-off-by: Yewon Choi <woni9911@gmail.com>
---
 net/xdp/xsk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index ae9f8cb611f6..1e5a65326d1d 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -947,7 +947,7 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
 
 	rcu_read_lock();
 	if (xsk_check_common(xs))
-		goto skip_tx;
+		goto out;
 
 	pool = xs->pool;
 
@@ -959,12 +959,12 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
 			xsk_generic_xmit(sk);
 	}
 
-skip_tx:
 	if (xs->rx && !xskq_prod_is_empty(xs->rx))
 		mask |= EPOLLIN | EPOLLRDNORM;
 	if (xs->tx && xsk_tx_writeable(xs))
 		mask |= EPOLLOUT | EPOLLWRNORM;
 
+out:
 	rcu_read_unlock();
 	return mask;
 }
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] xsk: skip polling event check for unbound socket
  2023-12-01  6:10 [PATCH bpf] xsk: skip polling event check for unbound socket Yewon Choi
@ 2023-12-05  9:03 ` Magnus Karlsson
  2023-12-05 12:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Magnus Karlsson @ 2023-12-05  9:03 UTC (permalink / raw)
  To: Yewon Choi
  Cc: Björn Töpel, Magnus Karlsson, Maciej Fijalkowski,
	Jonathan Lemon, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, netdev, bpf, linux-kernel,
	threeearcat

On Fri, 1 Dec 2023 at 07:11, Yewon Choi <woni9911@gmail.com> wrote:
>
> In xsk_poll(), checking available events and setting mask bits should
> be executed only when a socket has been bound. Setting mask bits for
> unbound socket is meaningless.
> Currently, it checks events even when xsk_check_common() failed.
> To prevent this, we move goto location (skip_tx) after that checking.

Thanks for the fix.

Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>

> Fixes: 1596dae2f17e ("xsk: check IFF_UP earlier in Tx path")
> Signed-off-by: Yewon Choi <woni9911@gmail.com>
> ---
>  net/xdp/xsk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index ae9f8cb611f6..1e5a65326d1d 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -947,7 +947,7 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
>
>         rcu_read_lock();
>         if (xsk_check_common(xs))
> -               goto skip_tx;
> +               goto out;
>
>         pool = xs->pool;
>
> @@ -959,12 +959,12 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
>                         xsk_generic_xmit(sk);
>         }
>
> -skip_tx:
>         if (xs->rx && !xskq_prod_is_empty(xs->rx))
>                 mask |= EPOLLIN | EPOLLRDNORM;
>         if (xs->tx && xsk_tx_writeable(xs))
>                 mask |= EPOLLOUT | EPOLLWRNORM;
>
> +out:
>         rcu_read_unlock();
>         return mask;
>  }
> --
> 2.37.3
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] xsk: skip polling event check for unbound socket
  2023-12-01  6:10 [PATCH bpf] xsk: skip polling event check for unbound socket Yewon Choi
  2023-12-05  9:03 ` Magnus Karlsson
@ 2023-12-05 12:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-12-05 12:50 UTC (permalink / raw)
  To: Yewon Choi
  Cc: bjorn, magnus.karlsson, maciej.fijalkowski, jonathan.lemon, davem,
	edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend, netdev,
	bpf, linux-kernel, threeearcat

Hello:

This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Fri, 1 Dec 2023 15:10:52 +0900 you wrote:
> In xsk_poll(), checking available events and setting mask bits should
> be executed only when a socket has been bound. Setting mask bits for
> unbound socket is meaningless.
> Currently, it checks events even when xsk_check_common() failed.
> To prevent this, we move goto location (skip_tx) after that checking.
> 
> Fixes: 1596dae2f17e ("xsk: check IFF_UP earlier in Tx path")
> Signed-off-by: Yewon Choi <woni9911@gmail.com>
> 
> [...]

Here is the summary with links:
  - [bpf] xsk: skip polling event check for unbound socket
    https://git.kernel.org/bpf/bpf/c/e4d008d49a71

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-05 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-01  6:10 [PATCH bpf] xsk: skip polling event check for unbound socket Yewon Choi
2023-12-05  9:03 ` Magnus Karlsson
2023-12-05 12:50 ` patchwork-bot+netdevbpf

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