Skip to content

Commit

Permalink
xsk: Skip polling event check for unbound socket
Browse files Browse the repository at this point in the history
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: 1596dae ("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
  • Loading branch information
Yewon Choi authored and Daniel Borkmann committed Dec 5, 2023
1 parent dfce9cb commit e4d008d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/xdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down

0 comments on commit e4d008d

Please sign in to comment.