]> git.baikalelectronics.ru Git - kernel.git/commit
xsk: Fix handling of invalid descriptors in XSK TX batching API
authorMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Tue, 7 Jun 2022 14:22:00 +0000 (16:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:36:18 +0000 (18:36 +0200)
commita015c4655496ffd7f034166b35ce1286752a9e08
treec382fa8c8c8cbd1ea9e19ac248866ec6eba67f90
parent7bc23d13a0c062b2da91185b0fa544d592acca43
xsk: Fix handling of invalid descriptors in XSK TX batching API

[ Upstream commit dcc586fd07c89625358fe3df70082d49c716b2b6 ]

xdpxceiver run on a AF_XDP ZC enabled driver revealed a problem with XSK
Tx batching API. There is a test that checks how invalid Tx descriptors
are handled by AF_XDP. Each valid descriptor is followed by invalid one
on Tx side whereas the Rx side expects only to receive a set of valid
descriptors.

In current xsk_tx_peek_release_desc_batch() function, the amount of
available descriptors is hidden inside xskq_cons_peek_desc_batch(). This
can be problematic in cases where invalid descriptors are present due to
the fact that xskq_cons_peek_desc_batch() returns only a count of valid
descriptors. This means that it is impossible to properly update XSK
ring state when calling xskq_cons_release_n().

To address this issue, pull out the contents of
xskq_cons_peek_desc_batch() so that callers (currently only
xsk_tx_peek_release_desc_batch()) will always be able to update the
state of ring properly, as total count of entries is now available and
use this value as an argument in xskq_cons_release_n(). By
doing so, xskq_cons_peek_desc_batch() can be dropped altogether.

Fixes: 2039e6aa39c9 ("xsk: Introduce batched Tx descriptor interfaces")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20220607142200.576735-1-maciej.fijalkowski@intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xdp/xsk.c
net/xdp/xsk_queue.h