mirror of
https://github.com/torvalds/linux.git
synced 2026-03-07 23:04:33 +01:00
xsk: Fix zero-copy AF_XDP fragment drop
AF_XDP should ensure that only a complete packet is sent to application.
In the zero-copy case, if the Rx queue gets full as fragments are being
enqueued, the remaining fragments are dropped.
For the multi-buffer case, add a check to ensure that the Rx queue has
enough space for all fragments of a packet before starting to enqueue
them.
Fixes: 24ea50127e ("xsk: support mbuf on ZC RX")
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
Link: https://patch.msgid.link/20260225000456.107806-3-nikhil.rao@amd.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
60abb0ac11
commit
f7387d6579
1 changed files with 16 additions and 10 deletions
|
|
@ -167,25 +167,31 @@ static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
|
|||
struct xdp_buff_xsk *pos, *tmp;
|
||||
struct list_head *xskb_list;
|
||||
u32 contd = 0;
|
||||
u32 num_desc;
|
||||
int err;
|
||||
|
||||
if (frags)
|
||||
contd = XDP_PKT_CONTD;
|
||||
|
||||
err = __xsk_rcv_zc(xs, xskb, len, contd);
|
||||
if (err)
|
||||
goto err;
|
||||
if (likely(!frags))
|
||||
if (likely(!frags)) {
|
||||
err = __xsk_rcv_zc(xs, xskb, len, contd);
|
||||
if (err)
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
contd = XDP_PKT_CONTD;
|
||||
num_desc = xdp_get_shared_info_from_buff(xdp)->nr_frags + 1;
|
||||
if (xskq_prod_nb_free(xs->rx, num_desc) < num_desc) {
|
||||
xs->rx_queue_full++;
|
||||
err = -ENOBUFS;
|
||||
goto err;
|
||||
}
|
||||
|
||||
__xsk_rcv_zc(xs, xskb, len, contd);
|
||||
xskb_list = &xskb->pool->xskb_list;
|
||||
list_for_each_entry_safe(pos, tmp, xskb_list, list_node) {
|
||||
if (list_is_singular(xskb_list))
|
||||
contd = 0;
|
||||
len = pos->xdp.data_end - pos->xdp.data;
|
||||
err = __xsk_rcv_zc(xs, pos, len, contd);
|
||||
if (err)
|
||||
goto err;
|
||||
__xsk_rcv_zc(xs, pos, len, contd);
|
||||
list_del_init(&pos->list_node);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue