Skip to content

Commit e4d008d

Browse files
healwonborkmann
authored andcommitted
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: 1596dae ("xsk: check IFF_UP earlier in Tx path") Signed-off-by: Yewon Choi <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Magnus Karlsson <[email protected]> Link: https://lore.kernel.org/bpf/20231201061048.GA1510@libra05
1 parent dfce9cb commit e4d008d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

net/xdp/xsk.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
947947

948948
rcu_read_lock();
949949
if (xsk_check_common(xs))
950-
goto skip_tx;
950+
goto out;
951951

952952
pool = xs->pool;
953953

@@ -959,12 +959,11 @@ static __poll_t xsk_poll(struct file *file, struct socket *sock,
959959
xsk_generic_xmit(sk);
960960
}
961961

962-
skip_tx:
963962
if (xs->rx && !xskq_prod_is_empty(xs->rx))
964963
mask |= EPOLLIN | EPOLLRDNORM;
965964
if (xs->tx && xsk_tx_writeable(xs))
966965
mask |= EPOLLOUT | EPOLLWRNORM;
967-
966+
out:
968967
rcu_read_unlock();
969968
return mask;
970969
}

0 commit comments

Comments
 (0)