UPSTREAM: 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. Change-Id: I830abcc50f9b6062b4e6e4a52fb402796979d754 Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
parent
d2784b2375
commit
15ef86d16b
1 changed files with 5 additions and 5 deletions
|
|
@ -46,8 +46,10 @@ static int __xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
|
|||
if (xs->dev != xdp->rxq->dev || xs->queue_id != xdp->rxq->queue_index)
|
||||
return -EINVAL;
|
||||
|
||||
if (!xskq_peek_id(xs->umem->fq, &id))
|
||||
if (!xskq_peek_id(xs->umem->fq, &id)) {
|
||||
xs->rx_dropped++;
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
buffer = xdp_umem_get_data_with_headroom(xs->umem, id);
|
||||
memcpy(buffer, xdp->data, len);
|
||||
|
|
@ -55,6 +57,8 @@ static int __xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
|
|||
xs->umem->frame_headroom);
|
||||
if (!err)
|
||||
xskq_discard_id(xs->umem->fq);
|
||||
else
|
||||
xs->rx_dropped++;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
@ -66,8 +70,6 @@ int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
|
|||
err = __xsk_rcv(xs, xdp);
|
||||
if (likely(!err))
|
||||
xdp_return_buff(xdp);
|
||||
else
|
||||
xs->rx_dropped++;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
@ -85,8 +87,6 @@ int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
|
|||
err = __xsk_rcv(xs, xdp);
|
||||
if (!err)
|
||||
xsk_flush(xs);
|
||||
else
|
||||
xs->rx_dropped++;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue