From: Jakob Klocker <j.klocker@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Jakob Klocker <j.klocker@proxmox.com>
Subject: [PATCH proxmox-backup 2/2] fix #7198: metric collection: count veth uplink when running in a container
Date: Tue, 7 Jul 2026 12:56:01 +0200 [thread overview]
Message-ID: <20260707105601.309299-3-j.klocker@proxmox.com> (raw)
In-Reply-To: <20260707105601.309299-1-j.klocker@proxmox.com>
When PBS runs inside an LXC container, the network uplink is one end of
a veth pair rather than a physical NIC, so is_physical() returns false
and the interface is excluded from network utilization stats unless its
name happens to match PHYSICAL_NIC_REGEX. This drops graph data for
interfaces with custom names (e.g. wan0).
Check whether we are running in a container (via /run/systemd/container,
cached in a OnceLock) and, if so, also count veth interfaces as physical
for metric collection. This mirrors how a VM's NIC is already counted.
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7198
Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
src/server/metric_collection/mod.rs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/server/metric_collection/mod.rs b/src/server/metric_collection/mod.rs
index 18625b1a5..47882eb89 100644
--- a/src/server/metric_collection/mod.rs
+++ b/src/server/metric_collection/mod.rs
@@ -148,6 +148,11 @@ impl NetdevStat {
}
static NETWORK_INTERFACE_CACHE: OnceLock<HashMap<String, IpLink>> = OnceLock::new();
+static IN_CONTAINER_CACHE: OnceLock<bool> = OnceLock::new();
+
+fn running_in_container() -> bool {
+ Path::new("/run/systemd/container").exists()
+}
fn collect_netdev_stats() -> Option<Vec<NetdevStat>> {
use proxmox_sys::linux::procfs::read_proc_net_dev;
@@ -175,10 +180,11 @@ fn collect_netdev_stats() -> Option<Vec<NetdevStat>> {
};
let mut stat_devs = Vec::with_capacity(net_devs.len());
+ let in_container = *IN_CONTAINER_CACHE.get_or_init(running_in_container);
for net_dev in net_devs {
if let Some(ip_link) = ip_links.get(&net_dev.device) {
- let ty = if ip_link.is_physical() {
+ let ty = if ip_link.is_physical() || (in_container && ip_link.is_veth()) {
NetdevType::Physical
} else {
NetdevType::Virtual
--
2.47.3
next prev parent reply other threads:[~2026-07-07 10:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 10:55 [RFC proxmox{,-backup} 0/2] fix #7198: count veth uplink for PBS running in an LXC Jakob Klocker
2026-07-07 10:56 ` [PATCH proxmox 1/2] network-api: add is_veth helper to IpLink Jakob Klocker
2026-07-07 10:56 ` Jakob Klocker [this message]
2026-07-07 11:17 ` [RFC proxmox{,-backup} 0/2] fix #7198: count veth uplink for PBS running in an LXC Jakob Klocker
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=20260707105601.309299-3-j.klocker@proxmox.com \
--to=j.klocker@proxmox.com \
--cc=pve-devel@lists.proxmox.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