stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Youlun Zhang <zhangyoulun@bytedance.com>,
	Peilin Ye <peilin.ye@bytedance.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 030/112] bpf: Fix devs rx stats for bpf_redirect_peer traffic
Date: Thu, 30 Nov 2023 16:21:17 +0000	[thread overview]
Message-ID: <20231130162141.272536055@linuxfoundation.org> (raw)
In-Reply-To: <20231130162140.298098091@linuxfoundation.org>

6.6-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Peilin Ye <peilin.ye@bytedance.com>

[ Upstream commit 024ee930cb3c9ae49e4266aee89cfde0ebb407e1 ]

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 <zhangyoulun@bytedance.com>
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-6-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/dev.c    | 8 ++++++++
 net/core/filter.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 37444c8e22054..9bf90b2a75b6a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10054,6 +10054,14 @@ static int netdev_do_alloc_pcpu_stats(struct net_device *dev)
 {
 	void __percpu *v;
 
+	/* Drivers implementing ndo_get_peer_dev must support tstat
+	 * accounting, so that skb_do_redirect() can bump the dev's
+	 * RX stats upon network namespace switch.
+	 */
+	if (dev->netdev_ops->ndo_get_peer_dev &&
+	    dev->pcpu_stat_type != NETDEV_PCPU_STAT_TSTATS)
+		return -EOPNOTSUPP;
+
 	switch (dev->pcpu_stat_type) {
 	case NETDEV_PCPU_STAT_NONE:
 		return 0;
diff --git a/net/core/filter.c b/net/core/filter.c
index a094694899c99..b149a165c405c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2489,6 +2489,7 @@ int skb_do_redirect(struct sk_buff *skb)
 			     net_eq(net, dev_net(dev))))
 			goto out_drop;
 		skb->dev = dev;
+		dev_sw_netstats_rx_add(dev, skb->len);
 		return -EAGAIN;
 	}
 	return flags & BPF_F_NEIGH ?
-- 
2.42.0




  parent reply	other threads:[~2023-11-30 16:25 UTC|newest]

Thread overview: 128+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 16:20 [PATCH 6.6 000/112] 6.6.4-rc1 review Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 001/112] NFSD: Fix "start of NFS reply" pointer passed to nfsd_cache_update() Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 002/112] NFSD: Fix checksum mismatches in the duplicate reply cache Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 003/112] irqchip/gic-v3-its: Flush ITS tables correctly in non-coherent GIC designs Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 004/112] hv/hv_kvp_daemon: Some small fixes for handling NM keyfiles Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 005/112] sched/eevdf: Fix vruntime adjustment on reweight Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 006/112] sched/fair: Fix the decision for load balance Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 007/112] drm/msm/dsi: use the correct VREG_CTRL_1 value for 4nm cphy Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 008/112] s390/ism: ism driver implies smc protocol Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 009/112] rxrpc: Fix RTT determination to use any ACK as a source Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 010/112] rxrpc: Defer the response to a PING ACK until weve parsed it Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 011/112] afs: Fix afs_server_list to be cleaned up with RCU Greg Kroah-Hartman
2023-11-30 16:20 ` [PATCH 6.6 012/112] afs: Make error on cell lookup failure consistent with OpenAFS Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 013/112] blk-cgroup: avoid to warn !rcu_read_lock_held() in blkg_lookup() Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 014/112] drm/panel: auo,b101uan08.3: Fine tune the panel power sequence Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 015/112] fs: Pass AT_GETATTR_NOSEC flag to getattr interface function Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 016/112] drm/panel: simple: Fix Innolux G101ICE-L01 bus flags Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 017/112] drm/panel: simple: Fix Innolux G101ICE-L01 timings Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 018/112] net: wangxun: fix kernel panic due to null pointer Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 019/112] wireguard: use DEV_STATS_INC() Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 020/112] octeontx2-pf: Fix memory leak during interface down Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 021/112] ata: pata_isapnp: Add missing error check for devm_ioport_map() Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 022/112] drm/i915: do not clean GT table on error path Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 023/112] filemap: add a per-mapping stable writes flag Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 024/112] block: update the stable_writes flag in bdev_add Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 025/112] libfs: getdents() should return 0 after reaching EOD Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 026/112] drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 027/112] PM: tools: Fix sleepgraph syntax error Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 028/112] net, vrf: Move dstats structure to core Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 029/112] net: Move {l,t,d}stats allocation to core and convert veth & vrf Greg Kroah-Hartman
2023-11-30 16:21 ` Greg Kroah-Hartman [this message]
2023-11-30 16:21 ` [PATCH 6.6 031/112] accel/ivpu: Do not initialize parameters on power up Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 032/112] accel/ivpu/37xx: Fix hangs related to MMIO reset Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 033/112] HID: fix HID device resource race between HID core and debugging support Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 034/112] ipv4: Correct/silence an endian warning in __ip_do_redirect Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 035/112] drm/panel: boe-tv101wum-nl6: Fine tune Himax83102-j02 panel HFP and HBP Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 036/112] net: usb: ax88179_178a: fix failed operations during ax88179_reset Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 037/112] net/smc: avoid data corruption caused by decline Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 038/112] s390/ipl: add missing IPL_TYPE_ECKD_DUMP case to ipl_init() Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 039/112] arm64: mm: Fix "rodata=on" when CONFIG_RODATA_FULL_DEFAULT_ENABLED=y Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 040/112] arm/xen: fix xen_vcpu_info allocation alignment Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 041/112] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 042/112] net: veth: fix ethtool stats reporting Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 043/112] amd-xgbe: handle corner-case during sfp hotplug Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 044/112] amd-xgbe: handle the corner-case during tx completion Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 045/112] amd-xgbe: propagate the correct speed and duplex status Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 046/112] i40e: Fix adding unsupported cloud filters Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 047/112] vsock/test: fix SEQPACKET message bounds test Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 048/112] net: axienet: Fix check for partial TX checksum Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 049/112] net: ipa: fix one GSI register field width Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 050/112] afs: Return ENOENT if no cell DNS record can be found Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 051/112] afs: Fix file locking on R/O volumes to operate in local mode Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 052/112] nvme: blank out authentication fabrics options if not configured Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 053/112] nvmet: nul-terminate the NQNs passed in the connect command Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 054/112] USB: dwc3: qcom: fix resource leaks on probe deferral Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 055/112] USB: dwc3: qcom: fix ACPI platform device leak Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 056/112] lockdep: Fix block chain corruption Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 057/112] mm: add a NO_INHERIT flag to the PR_SET_MDWE prctl Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 058/112] prctl: Disable prctl(PR_SET_MDWE) on parisc Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 059/112] kselftest/arm64: Fix output formatting for za-fork Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 060/112] drm/msm/dpu: Add missing safe_lut_tbl in sc8280xp catalog Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 061/112] drm/ast: Disconnect BMC if physical connector is connected Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 062/112] thunderbolt: Set lane bonding bit only for downstream port Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 063/112] ACPI: video: Use acpi_device_fix_up_power_children() Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 064/112] ACPI: processor_idle: use raw_safe_halt() in acpi_idle_play_dead() Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 065/112] ACPI: resource: Skip IRQ override on ASUS ExpertBook B1402CVA Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 066/112] ACPI: PM: Add acpi_device_fix_up_power_children() function Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 067/112] swiotlb-xen: provide the "max_mapping_size" method Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 068/112] tls: fix NULL deref on tls_sw_splice_eof() with empty record Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 069/112] io_uring: fix off-by one bvec index Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 070/112] bcache: replace a mistaken IS_ERR() by IS_ERR_OR_NULL() in btree_gc_coalesce() Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 071/112] md: fix bi_status reporting in md_end_clone_io Greg Kroah-Hartman
2023-11-30 16:21 ` [PATCH 6.6 072/112] bcache: fixup multi-threaded bch_sectors_dirty_init() wake-up race Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 073/112] io_uring/fs: consider link->flags when getting path for LINKAT Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 074/112] s390/dasd: protect device queue against concurrent access Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 075/112] platform/x86: hp-bioscfg: Simplify return check in hp_add_other_attributes() Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 076/112] platform/x86: hp-bioscfg: move mutex_lock() down " Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 077/112] platform/x86: hp-bioscfg: Fix error handling " Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 078/112] dt-bindings: usb: microchip,usb5744: Add second supply Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 079/112] usb: misc: onboard-hub: add support for Microchip USB5744 Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 080/112] USB: serial: option: add Luat Air72*U series products Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 081/112] platform/x86/amd/pmc: adjust getting DRAM size behavior Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 082/112] platform/x86: ideapad-laptop: Set max_brightness before using it Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 083/112] hv_netvsc: fix race of netvsc and VF register_netdevice Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 084/112] hv_netvsc: Fix race of register_netdevice_notifier and VF register Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 085/112] hv_netvsc: Mark VF as slave before exposing it to user-mode Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 086/112] Revert "usb: phy: add usb phy notify port status API" Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 087/112] Revert "phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY" Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 088/112] Revert "phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY" Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 089/112] cifs: distribute channels across interfaces based on speed Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 090/112] cifs: account for primary channel in the interface list Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 091/112] cifs: fix leak of iface for primary channel Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 092/112] ALSA: hda: ASUS UM5302LA: Added quirks for cs35L41/10431A83 on i2c bus Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 093/112] ALSA: hda/realtek: Add quirks for ASUS 2024 Zenbooks Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 094/112] dm-delay: fix a race between delay_presuspend and delay_bio Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 095/112] veth: Use tstats per-CPU traffic counters Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 096/112] bcache: check return value from btree_node_alloc_replacement() Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 097/112] bcache: prevent potential division by zero error Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 098/112] bcache: fixup init dirty data errors Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 099/112] bcache: fixup lock c->root error Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 100/112] USB: xhci-plat: fix legacy PHY double init Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 101/112] usb: config: fix iteration issue in usb_get_bos_descriptor() Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 102/112] usb: cdnsp: Fix deadlock issue during using NCM gadget Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 103/112] USB: serial: option: add Fibocom L7xx modules Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 104/112] USB: serial: option: fix FM101R-GL defines Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 105/112] USB: serial: option: dont claim interface 4 for ZTE MF290 Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 106/112] usb: typec: tcpm: Fix sink caps op current check Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 107/112] usb: typec: tcpm: Skip hard reset when in error recovery Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 108/112] USB: dwc2: write HCINT with INTMASK applied Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 109/112] usb: dwc3: Fix default mode initialization Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 110/112] usb: dwc3: set the dma max_seg_size Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 111/112] USB: dwc3: qcom: fix software node leak on probe errors Greg Kroah-Hartman
2023-11-30 16:22 ` [PATCH 6.6 112/112] USB: dwc3: qcom: fix wakeup after probe deferral Greg Kroah-Hartman
2023-11-30 19:20 ` [PATCH 6.6 000/112] 6.6.4-rc1 review Florian Fainelli
2023-11-30 23:00 ` Takeshi Ogasawara
2023-12-01  0:08 ` Shuah Khan
2023-12-01  6:12 ` Harshit Mogalapalli
2023-12-01  7:42 ` Ron Economos
2023-12-01  7:45 ` Bagas Sanjaya
2023-12-01 10:58 ` Jon Hunter
2023-12-01 11:57 ` Frank Scheiner
2023-12-01 13:14 ` Naresh Kamboju
2023-12-01 13:14 ` Rudi Heitbaum
2023-12-01 13:21 ` Conor Dooley
2023-12-01 18:24 ` Justin Forbes
2023-12-01 20:31 ` Guenter Roeck
2023-12-02  0:39 ` SeongJae Park
2023-12-02 16:12 ` Ricardo B. Marliere

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231130162141.272536055@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=daniel@iogearbox.net \
    --cc=martin.lau@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=peilin.ye@bytedance.com \
    --cc=razor@blackwall.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zhangyoulun@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).