Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xsk: proper Rx drop statistics update

Previously, rx_dropped could be updated incorrectly, e.g. if the XDP
program redirected the frame to a socket bound to a different queue
than where the XDP program was executing.

Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Björn Töpel and committed by
Daniel Borkmann
a509a955 4e64c835

+5 -5
+5 -5
net/xdp/xsk.c
··· 48 48 if (xs->dev != xdp->rxq->dev || xs->queue_id != xdp->rxq->queue_index) 49 49 return -EINVAL; 50 50 51 - if (!xskq_peek_id(xs->umem->fq, &id)) 51 + if (!xskq_peek_id(xs->umem->fq, &id)) { 52 + xs->rx_dropped++; 52 53 return -ENOSPC; 54 + } 53 55 54 56 buffer = xdp_umem_get_data_with_headroom(xs->umem, id); 55 57 memcpy(buffer, xdp->data, len); ··· 59 57 xs->umem->frame_headroom); 60 58 if (!err) 61 59 xskq_discard_id(xs->umem->fq); 60 + else 61 + xs->rx_dropped++; 62 62 63 63 return err; 64 64 } ··· 72 68 err = __xsk_rcv(xs, xdp); 73 69 if (likely(!err)) 74 70 xdp_return_buff(xdp); 75 - else 76 - xs->rx_dropped++; 77 71 78 72 return err; 79 73 } ··· 89 87 err = __xsk_rcv(xs, xdp); 90 88 if (!err) 91 89 xsk_flush(xs); 92 - else 93 - xs->rx_dropped++; 94 90 95 91 return err; 96 92 }