summaryrefslogtreecommitdiffstats
path: root/net/xdp
diff options
context:
space:
mode:
authorYewon Choi <woni9911@gmail.com>2023-12-01 07:10:52 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2023-12-05 13:43:43 +0100
commite4d008d49a7135214e0ee70537405b6a069e3a3f (patch)
tree49a625866ba1bff1b71d541004e9045816a92b6c /net/xdp
parentbpf: Fix a verifier bug due to incorrect branch offset comparison with cpu=v4 (diff)
downloadlinux-e4d008d49a7135214e0ee70537405b6a069e3a3f.tar.xz
linux-e4d008d49a7135214e0ee70537405b6a069e3a3f.zip
xsk: Skip polling event check for unbound socket
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> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/bpf/20231201061048.GA1510@libra05
Diffstat (limited to 'net/xdp')
-rw-r--r--net/xdp/xsk.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index ae9f8cb611f6..3da0b52f308d 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,11 @@ 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;
}