Skip to content

Commit 0018d02

Browse files
magnus-karlssongregkh
authored andcommitted
samples/bpf: Fix possible deadlock in xdpsock
[ Upstream commit 5a2a0dd ] Fix a possible deadlock in the l2fwd application in xdpsock that can occur when there is no space in the Tx ring. There are two ways to get the kernel to consume entries in the Tx ring: calling sendto() to make it send packets and freeing entries from the completion ring, as the kernel will not send a packet if there is no space for it to add a completion entry in the completion ring. The Tx loop in l2fwd only used to call sendto(). This patches adds cleaning the completion ring in that loop. Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/1599726666-8431-3-git-send-email-magnus.karlsson@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4c210f8 commit 0018d02

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

samples/bpf/xdpsock_user.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ static void l2fwd(struct xsk_socket_info *xsk, struct pollfd *fds)
11111111
while (ret != rcvd) {
11121112
if (ret < 0)
11131113
exit_with_error(-ret);
1114+
complete_tx_l2fwd(xsk, fds);
11141115
if (xsk_ring_prod__needs_wakeup(&xsk->tx))
11151116
kick_tx(xsk);
11161117
ret = xsk_ring_prod__reserve(&xsk->tx, rcvd, &idx_tx);

0 commit comments

Comments
 (0)