samples/bpf: Fix possible deadlock in xdpsock
authorMagnus Karlsson <magnus.karlsson@intel.com>
Thu, 10 Sep 2020 08:31:05 +0000 (10:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:43:17 +0000 (11:43 +0100)
commit7762afa04fd4810e88f380cf066c1d5945fb7b7b
tree077c5d9351d905ea0f1981b8a9c619fe80dbbe31
parent58c80462e4671f9f146d6424328f1d68412769fa
samples/bpf: Fix possible deadlock in xdpsock

[ Upstream commit 5a2a0dd88f0f267ac5953acd81050ae43a82201f ]

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>
samples/bpf/xdpsock_user.c