diff options
| author | Peilin Ye <[email protected]> | 2023-11-14 00:42:17 +0000 |
|---|---|---|
| committer | Martin KaFai Lau <[email protected]> | 2023-11-20 18:15:16 +0000 |
| commit | 024ee930cb3c9ae49e4266aee89cfde0ebb407e1 (patch) | |
| tree | 06be9235f5eaf8e273fdaf855b488b83effb846d /drivers/net/netkit.c | |
| parent | veth: Use tstats per-CPU traffic counters (diff) | |
| download | kernel-024ee930cb3c9ae49e4266aee89cfde0ebb407e1.tar.gz kernel-024ee930cb3c9ae49e4266aee89cfde0ebb407e1.zip | |
bpf: Fix dev's rx stats for bpf_redirect_peer traffic
Traffic redirected by bpf_redirect_peer() (used by recent CNIs like Cilium)
is not accounted for in the RX stats of supported devices (that is, veth
and netkit), confusing user space metrics collectors such as cAdvisor [0],
as reported by Youlun.
Fix it by calling dev_sw_netstats_rx_add() in skb_do_redirect(), to update
RX traffic counters. Devices that support ndo_get_peer_dev _must_ use the
@tstats per-CPU counters (instead of @lstats, or @dstats).
To make this more fool-proof, error out when ndo_get_peer_dev is set but
@tstats are not selected.
[0] Specifically, the "container_network_receive_{byte,packet}s_total"
counters are affected.
Fixes: 9aa1206e8f48 ("bpf: Add redirect_peer helper")
Reported-by: Youlun Zhang <[email protected]>
Signed-off-by: Peilin Ye <[email protected]>
Co-developed-by: Daniel Borkmann <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Reviewed-by: Nikolay Aleksandrov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
Diffstat (limited to 'drivers/net/netkit.c')
0 files changed, 0 insertions, 0 deletions
