mirror of https://gitee.com/openkylin/linux.git
bpf, devmap: Remove drops variable from bq_xmit_all()
As Colin pointed out, the first drops assignment after declaration will
be overwritten by the second drops assignment before using, which makes
it useless.
Since the drops variable will be used only once. Just remove it and
use "cnt - sent" in trace_xdp_devmap_xmit().
Fixes: cb261b594b
("bpf: Run devmap xdp_prog on flush instead of bulk enqueue")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210528024356.24333-1-liuhangbin@gmail.com
This commit is contained in:
parent
fc8c262e0e
commit
e8e0f0f484
|
@ -370,8 +370,8 @@ static int dev_map_bpf_prog_run(struct bpf_prog *xdp_prog,
|
||||||
static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
|
static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
|
||||||
{
|
{
|
||||||
struct net_device *dev = bq->dev;
|
struct net_device *dev = bq->dev;
|
||||||
int sent = 0, drops = 0, err = 0;
|
|
||||||
unsigned int cnt = bq->count;
|
unsigned int cnt = bq->count;
|
||||||
|
int sent = 0, err = 0;
|
||||||
int to_send = cnt;
|
int to_send = cnt;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -388,8 +388,6 @@ static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
|
||||||
to_send = dev_map_bpf_prog_run(bq->xdp_prog, bq->q, cnt, dev);
|
to_send = dev_map_bpf_prog_run(bq->xdp_prog, bq->q, cnt, dev);
|
||||||
if (!to_send)
|
if (!to_send)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
drops = cnt - to_send;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sent = dev->netdev_ops->ndo_xdp_xmit(dev, to_send, bq->q, flags);
|
sent = dev->netdev_ops->ndo_xdp_xmit(dev, to_send, bq->q, flags);
|
||||||
|
@ -408,9 +406,8 @@ static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
|
||||||
xdp_return_frame_rx_napi(bq->q[i]);
|
xdp_return_frame_rx_napi(bq->q[i]);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
drops = cnt - sent;
|
|
||||||
bq->count = 0;
|
bq->count = 0;
|
||||||
trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, drops, err);
|
trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, cnt - sent, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* __dev_flush is called from xdp_do_flush() which _must_ be signaled
|
/* __dev_flush is called from xdp_do_flush() which _must_ be signaled
|
||||||
|
|
Loading…
Reference in New Issue