linux/drivers/net
Peilin Ye 7ca7b6649b veth: Use tstats per-CPU traffic counters
[ Upstream commit 6f2684bf2b ]

Currently veth devices use the lstats per-CPU traffic counters, which only
cover TX traffic. veth_get_stats64() actually populates RX stats of a veth
device from its peer's TX counters, based on the assumption that a veth
device can _only_ receive packets from its peer, which is no longer true:

For example, recent CNIs (like Cilium) can use the bpf_redirect_peer() BPF
helper to redirect traffic from NIC's tc ingress to veth's tc ingress (in
a different netns), skipping veth's peer device. Unfortunately, this kind
of traffic isn't currently accounted for in veth's RX stats.

In preparation for the fix, use tstats (instead of lstats) to maintain
both RX and TX counters for each veth device. We'll use RX counters for
bpf_redirect_peer() traffic, and keep using TX counters for the usual
"peer-to-peer" traffic. In veth_get_stats64(), calculate RX stats by
_adding_ RX count to peer's TX count, in order to cover both kinds of
traffic.

veth_stats_rx() might need a name change (perhaps to "veth_stats_xdp()")
for less confusion, but let's leave it to another patch to keep the fix
minimal.

Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
Co-developed-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://lore.kernel.org/r/20231114004220.6495-5-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2024-12-14 19:54:54 +01:00
..
appletalk net: appletalk: remove Apple/Farallon LocalTalk PC support 2022-05-11 13:08:38 +01:00
arcnet arcnet: restoring support for multiple Sohard Arcnet cards 2023-12-13 18:39:07 +01:00
bonding bonding: add ns target multicast address to slave device 2024-11-22 15:37:30 +01:00
caif caif_virtio: fix race between virtio_device_ready() and ndo_open() 2022-06-27 08:04:30 -04:00
can can: mcp251xfd: mcp251xfd_get_tef_len(): work around erratum DS80000789E 6. 2024-12-14 19:54:32 +01:00
dsa dsa: qca8k: Use nested lock to avoid splat 2024-12-14 19:54:44 +01:00
ethernet gve: Fixes for napi_poll when budget is 0 2024-12-14 19:54:53 +01:00
fddi net: defxx: Fix missing err handling in dfx_init() 2022-12-31 13:32:26 +01:00
fjes fjes: fix memleaks in fjes_hw_setup 2024-01-31 16:17:06 -08:00
hamradio hamradio: baycom_epp: Fix return type of baycom_send_packet() 2022-12-31 13:33:00 +01:00
hippi net: hippi: Add missing pci_disable_device() in rr_init_one() 2022-09-26 13:22:39 -07:00
hyperv hv_netvsc: Fix VF namespace also in synthetic NIC NETDEV_REGISTER event 2024-11-01 01:56:06 +01:00
ieee802154 net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq() 2024-10-17 15:21:31 +02:00
ipa net: ipa: only reset hashed tables when supported 2023-08-11 12:08:09 +02:00
ipvlan ipvlan: Dont Use skb->sk in ipvlan_process_v{4,6}_outbound 2024-06-12 11:03:59 +02:00
mctp mctp i2c: handle NULL header address 2024-11-08 16:26:46 +01:00
mdio net: mdio-ipq4019: add missing error check 2024-12-14 19:53:50 +01:00
netdevsim netdevsim: copy addresses for both in and out paths 2024-12-14 19:53:28 +01:00
pcs net: pcs: xpcs: Return EINVAL in the internal methods 2024-04-13 13:04:58 +02:00
phy net: sfp: change quirks for Alcatel Lucent G-010S-P 2024-12-14 19:54:42 +01:00
plip net: plip: fix break; causing plip to never transmit 2024-11-01 01:56:04 +01:00
ppp ppp: fix ppp_async_encode() illegal access 2024-10-17 15:22:23 +02:00
pse-pd net: pse-pd: PSE_REGULATOR should depend on REGULATOR 2022-10-05 20:32:28 -07:00
slip slip: make slhc_remember() more robust against malicious packets 2024-10-17 15:22:23 +02:00
team team: Fix use-after-free when an option instance allocation fails 2023-12-20 17:00:25 +01:00
usb net: usb: lan78xx: Fix refcounting and autosuspend on invalid WoL configuration 2024-12-14 19:53:50 +01:00
vmxnet3 vmxnet3: use gro callback when UPT is enabled 2023-04-06 12:10:52 +02:00
vxlan vxlan: Handle error of rtnl_register_module(). 2024-10-17 15:22:23 +02:00
wan drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close() 2023-10-10 22:00:40 +02:00
wireguard wireguard: send: annotate intentional data race in checking empty queue 2024-07-18 13:18:41 +02:00
wireless wifi: brcmfmac: Fix oops due to NULL pointer dereference in brcmf_sdiod_sglist_rw() 2024-12-14 19:54:44 +01:00
wwan net: wwan: t7xx: Fix off-by-one error in t7xx_dpmaif_rx_buf_alloc() 2024-11-14 13:15:16 +01:00
xen-netback net/xen-netback: prevent UAF in xenvif_flush_hash() 2024-10-17 15:21:35 +02:00
amt.c amt: do not use overwrapped cb area 2024-01-25 15:27:49 -08:00
bareudp.c bareudp: Pull inner IP header on xmit. 2024-10-17 15:20:43 +02:00
dummy.c net: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:07 -07:00
eql.c net: rename reference+tracking helpers 2022-06-09 21:52:55 -07:00
geneve.c geneve: do not assume mac header is set in geneve_xmit_skb() 2024-12-14 19:54:23 +01:00
gtp.c gtp: allow -1 to be specified as file description from userspace 2024-11-08 16:26:41 +01:00
ifb.c net: ifb: support ethtools stats 2021-11-29 20:15:03 -08:00
Kconfig - Yu Zhao's Multi-Gen LRU patches are here. They've been under test in 2022-10-10 17:53:04 -07:00
LICENSE.SRC Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
loopback.c net: loopback: use NET_NAME_PREDICTABLE for name_assign_type 2022-11-25 09:39:05 +00:00
macsec.c macsec: Fix use-after-free while sending the offloading packet 2024-11-08 16:26:41 +01:00
macvlan.c macvlan: Don't propagate promisc change to lower dev in passthru 2023-11-28 17:07:06 +00:00
macvtap.c net: macvtap: add __init/__exit annotations to module init/exit funcs 2022-09-21 18:22:30 -07:00
Makefile net: Always descend into dsa/ folder with CONFIG_NET_DSA enabled 2024-06-12 11:03:50 +02:00
mdio.c net: mdio: Correct function name mdio45_links_ok() in comment 2021-03-29 13:42:44 -07:00
mhi_net.c net: mhi: Fix memory leak in mhi_net_dellink() 2022-11-14 11:21:02 +00:00
mii.c net: mii: make mii_ethtool_gset() return void 2021-08-19 13:06:53 +01:00
net_failover.c net/net_failover: fix txq exceeding warning 2023-04-06 12:10:46 +02:00
netconsole.c net: netconsole: Disable target before netpoll cleanup 2024-08-03 08:49:30 +02:00
nlmon.c net: don't include ethtool.h from netdevice.h 2020-11-23 17:27:04 -08:00
ntb_netdev.c net: ntb_netdev: Move ntb_netdev_rx_handler() to call netif_rx() from __netif_rx() 2024-07-11 12:47:11 +02:00
rionet.c net: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:07 -07:00
sb1000.c net: dev: Makes sure netif_rx() can be invoked in any context. 2022-02-14 13:38:35 +00:00
Space.c net: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:07 -07:00
sungem_phy.c net: sungem_phy: Add of_node_put() for reference returned by of_get_parent() 2022-07-21 19:04:19 -07:00
tap.c tap: add missing verification for short frame 2024-07-27 11:32:19 +02:00
thunderbolt.c net: thunderbolt: Fix TCPv6 GSO checksum calculation 2023-10-06 14:57:04 +02:00
tun.c tun: add missing verification for short frame 2024-07-27 11:32:19 +02:00
veth.c veth: Use tstats per-CPU traffic counters 2024-12-14 19:54:54 +01:00
virtio_net.c virtio_net: Add hash_key_length check 2024-11-14 13:15:12 +01:00
vrf.c net: Move {l,t,d}stats allocation to core and convert veth & vrf 2024-12-14 19:54:54 +01:00
vsockmon.c net: don't include ethtool.h from netdevice.h 2020-11-23 17:27:04 -08:00
xen-netfront.c xen-netfront: Add missing skb_mark_for_recycle 2024-04-10 16:28:24 +02:00