public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics
@ 2026-11-17 18:34 Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox v2 01/11] network-api: add missing getters Stefan Hanreich
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

## Introduction

This patch series adds status reporting for WireGuard fabrics to pvestatd and
exposes additional information about WireGuard interfaces and neighbors (=
peers) via the pre-existing interface/neighbors endpoints for fabrics.


## Implementation

This patch series uses the `wg show all dump` CLI command included in the
wireguard-tools package to obtain the current state of WireGuard interfaces and
neighbors. Matching peers to the respective section config entry happens based
on their public key, scoped to the interface the peer is configured on.
WireGuard identifies the peers of an interface by their public key, so it is
guaranteed to be unique per interface.

Status reporting for WireGuard is trickier than for the other protocols in the
stack, since there's not really a notion of up / down and no way of
distinguishing whether a connection hasn't been used for a while or has gone
down. Utilizing persistent keepalive can fix this, but this is currently
optional, so the status needs to work for both cases. The fabric status reported
by pvestatd therefore does not rely on handshakes, while the status of neighbors
only reports a peer as 'down' if persistent keepalive is enabled (see below).

The interfaces are taken from the fabric configuration, so that interfaces
missing from the `wg show` output still show up in the status. The general state
of an interface is determined by looking at the type and flags of the virtual
WireGuard interface and the `wg show` output. The possible states are:

* 'missing': the interface does not exist, e.g. because applying the
  configuration failed on the node
* 'error': the interface exists, but is not a WireGuard interface
* 'unknown': the interface exists, but `wg show` could not read it - it skips
  such interfaces and still exits successfully as long as at least one interface
  could be read
* 'down': the interface does not have the 'UP' flag set
* 'up': the interface has the 'UP' flag set

If WireGuard does not report the public key or listen port of an interface, the
interface status shows the values from the fabric configuration instead.

Values that WireGuard reports as unset, such as the endpoint before the first
handshake, a missing handshake or a disabled persistent keepalive, are omitted
from the neighbor status.

pvestatd reports a WireGuard fabric as 'ok' if all of its interfaces on the node
are 'up' and use their configured public key and listen port, and the running
WireGuard configuration of each interface contains exactly the peers of the SDN
running configuration, otherwise as 'not ok'. This catches nodes where applying
the configuration failed, including stale peers and failed key rotations.
Handshakes are not considered for this, since peers do not exchange any without
traffic, unless persistent keepalive is enabled.

pvestatd only calls `wg show` on nodes that are part of a WireGuard fabric. If
the command fails, the interface and neighbor endpoints return an error, while
pvestatd reports only the WireGuard fabrics as 'not ok' - the status of the
other fabrics is still reported.

The status of a neighbor is derived from its latest handshake:

* 'active': the latest handshake is less than 180 seconds old (with persistent
  keepalive: 180 seconds plus the keepalive interval plus 90 seconds)
* 'down': persistent keepalive is enabled, but there was no handshake in that
  time
* 'idle': persistent keepalive is disabled and there was no handshake within the
  last 180 seconds

180 seconds is the lifetime of WireGuard session keys. Keys older than that are
used neither for sending nor for receiving, so a handshake within that time
means that the peer has a working session. While traffic is sent, a new
handshake happens after 120 seconds, so the latest handshake of an active peer
stays below 180 seconds.

Without persistent keepalive, there are no handshakes without traffic, so an
unused but working peer cannot be distinguished from an unreachable one -
reporting it as 'down' would be misleading, so it is reported as 'idle'. With
persistent keepalive, a reachable peer exchanges a new handshake before its
session expires. The keepalive interval and the 90 seconds for which WireGuard
retries a handshake serve as margin before reporting a peer as 'down'.

The GUI shows additional columns for WireGuard fabrics in the interface and
neighbor panels (e.g. status, public key, allowed IPs, latest handshake and
transferred bytes), and the documentation describes the interface states, the
neighbor properties and how the fabric status is determined.


## Open questions

The return schema of the neighbor status endpoint had some non-optional strings.
This series makes 'uptime' optional, since it is not returned for the WireGuard
fabric, as well as 'neighbor', since the endpoint of a WireGuard peer is not
known before the first handshake if it has none configured. Initially, I
returned hard-coded strings for those fields for the WireGuard fabric, but
decided to omit them instead, since they could be potentially misleading and
don't really add anything. Still a bit unsure about this, since it is
technically a breaking API change. It should be easy to just add this in a new
iteration again - even if only 'n/a' or something similar is returned for the
non-optional fields.

The uptime of neighbors was omitted, since there's no way of obtaining the
uptime of the connection to a peer - the kernel simply doesn't track it. We
could track it ourselves in a runtime dir, but that seems clunky. It also
doesn't really add a lot in the case of WireGuard, as compared to BGP /
OpenFabric / OSPF.


## Dependencies

libpve-rs-perl depends on proxmox-network-api
libpve-rs-perl depends on proxmox-ve-config
libpve-rs-perl depends on proxmox-wireguard
pve-network depends on libpve-rs-perl
pve-manager depends on pve-network (libpve-network-api-perl)


## Changelog

Changes from v1 -> v2:
* rebased on top of current master
* drop the proxmox-iproute2 refactor to avoid additional churn
* use proxmox_sys::command::run_command and call wg directly instead of via sh
* match peers to the fabric configuration based on their public key
* report peers that are not part of the fabric configuration without a name,
  instead of failing the whole request
* show the interface of the referenced node in the name of internal neighbors
* base the interface list on the fabric configuration and report the new states
  'missing' and 'unknown'
* omit values that WireGuard reports as unset instead of returning (none) as
  string
* report the status of WireGuard neighbors ('active', 'down' or 'idle'), derived
  from their latest handshake
* document the new interface states, omitted values and how the fabric status is
  determined
* report WireGuard fabrics as 'not ok' in pvestatd if an interface is not up,
  does not use its configured public key or listen port, or the peers in the
  running WireGuard configuration differ from the configured ones
* improve test cases


proxmox:

Stefan Hanreich (3):
  network-api: add missing getters
  network-api: add support for parsing interface flags
  wireguard: derive additional traits for public key

 proxmox-network-api/src/config/helper.rs | 42 ++++++++++++++++++++++++
 proxmox-network-api/src/config/mod.rs    |  5 ++-
 proxmox-wireguard/src/lib.rs             |  5 ++-
 3 files changed, 50 insertions(+), 2 deletions(-)


proxmox-ve-rs:

Stefan Hanreich (2):
  ve-config: sdn: wireguard: add getters for interface listen port and
    public key
  ve-config: sdn: wireguard: add helper for resolving the peers of an
    interface

 proxmox-ve-config/src/sdn/fabric/mod.rs       | 88 ++++++++++++++++++-
 .../section_config/protocol/wireguard.rs      | 10 +++
 2 files changed, 97 insertions(+), 1 deletion(-)


proxmox-perl-rs:

Stefan Hanreich (3):
  sdn status: fabrics: add status reporting for wireguard
  sdn status: fabrics: check interfaces and peers for wireguard status
  sdn status: fabrics: report status of wireguard neighbors

 pve-rs/Cargo.toml                  |    1 +
 pve-rs/src/bindings/sdn/fabrics.rs |   62 +-
 pve-rs/src/sdn/status.rs           | 1315 +++++++++++++++++++++++++++-
 3 files changed, 1364 insertions(+), 14 deletions(-)


pve-network:

Stefan Hanreich (1):
  api: fabric status: add schema for wireguard properties

 src/PVE/API2/Network/SDN/Nodes/Fabric.pm | 80 +++++++++++++++++++++++-
 1 file changed, 77 insertions(+), 3 deletions(-)


pve-manager:

Stefan Hanreich (1):
  ui: fabric content: add wireguard protocol

 www/manager6/sdn/FabricsContentView.js | 179 +++++++++++++++++++------
 www/manager6/sdn/NetworkBrowser.js     |  40 +++---
 2 files changed, 160 insertions(+), 59 deletions(-)


pve-docs:

Stefan Hanreich (1):
  sdn: add documentation for wireguard status reporting

 pve-gui.adoc |  1 +
 pvesdn.adoc  | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+)


Summary over all repositories:
  13 files changed, 1848 insertions(+), 79 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH proxmox v2 01/11] network-api: add missing getters
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox v2 02/11] network-api: add support for parsing interface flags Stefan Hanreich
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

Not all parsed fields provided getters for their value. Make them
available at use sites by providing the missing getters.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 proxmox-network-api/src/config/helper.rs | 20 ++++++++++++++++++++
 proxmox-network-api/src/config/mod.rs    |  4 +++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/proxmox-network-api/src/config/helper.rs b/proxmox-network-api/src/config/helper.rs
index a9ae35fc..7feaaa51 100644
--- a/proxmox-network-api/src/config/helper.rs
+++ b/proxmox-network-api/src/config/helper.rs
@@ -132,6 +132,16 @@ pub struct LinkInfo {
     info_kind: Option<String>,
 }
 
+impl LinkInfo {
+    pub fn info_slave_data(&self) -> Option<&SlaveData> {
+        self.info_slave_data.as_ref()
+    }
+
+    pub fn info_kind(&self) -> Option<&String> {
+        self.info_kind.as_ref()
+    }
+}
+
 /// The fields specific to an interface of type `ether`.
 #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, serde::Deserialize)]
 pub struct EtherLink {
@@ -231,6 +241,16 @@ impl IpLink {
         None
     }
 
+    /// The [`LinkInfo`] for this link.
+    pub fn linkinfo(&self) -> Option<&LinkInfo> {
+        self.linkinfo.as_ref()
+    }
+
+    /// The operating state of the interface.
+    pub fn operstate(&self) -> &str {
+        &self.operstate
+    }
+
     /// Returns an iterator over the altnames of an interface.
     pub fn altnames(&self) -> impl Iterator<Item = &String> {
         self.altnames.iter()
diff --git a/proxmox-network-api/src/config/mod.rs b/proxmox-network-api/src/config/mod.rs
index 212abef1..25ddd13f 100644
--- a/proxmox-network-api/src/config/mod.rs
+++ b/proxmox-network-api/src/config/mod.rs
@@ -2,7 +2,9 @@ mod helper;
 mod lexer;
 mod parser;
 
-pub use helper::{AltnameMapping, IpLink, assert_ifupdown2_installed, network_reload, parse_cidr};
+pub use helper::{
+    AltnameMapping, IpLink, LinkInfo, assert_ifupdown2_installed, network_reload, parse_cidr,
+};
 
 use std::collections::{BTreeMap, HashMap, HashSet};
 use std::io::Write;
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH proxmox v2 02/11] network-api: add support for parsing interface flags
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox v2 01/11] network-api: add missing getters Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox v2 03/11] wireguard: derive additional traits for public key Stefan Hanreich
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

Interface flags were not available in the parsed ip link output. The
flags are required for determining the status of some interfaces,
since WireGuard for example always sets the operating state to
UNKNOWN, even if the interface is up and working.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 proxmox-network-api/src/config/helper.rs | 22 ++++++++++++++++++++++
 proxmox-network-api/src/config/mod.rs    |  3 ++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/proxmox-network-api/src/config/helper.rs b/proxmox-network-api/src/config/helper.rs
index 7feaaa51..d16adf76 100644
--- a/proxmox-network-api/src/config/helper.rs
+++ b/proxmox-network-api/src/config/helper.rs
@@ -172,6 +172,21 @@ pub enum Link {
     Unknown(UnknownLink),
 }
 
+#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, serde::Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum LinkFlag {
+    Pointopoint,
+    Noarp,
+    Up,
+    LowerUp,
+    Broadcast,
+    Multicast,
+    Loopback,
+    Promisc,
+    #[serde(untagged)]
+    Unknown(String),
+}
+
 /// An IpLink entry, as returned by `ip -details -json link show`.
 ///
 /// For now this parses only the fields that are used throughout our stack, the fields of this
@@ -187,6 +202,8 @@ pub struct IpLink {
     link_type: Link,
     linkinfo: Option<LinkInfo>,
     operstate: String,
+    #[serde(default)]
+    flags: Vec<LinkFlag>,
 }
 
 impl IpLink {
@@ -256,6 +273,11 @@ impl IpLink {
         self.altnames.iter()
     }
 
+    /// Returns the flags of this interface
+    pub fn flags(&self) -> impl Iterator<Item = &LinkFlag> {
+        self.flags.iter()
+    }
+
     /// Returns whether the interface is currently in an UP state.
     pub fn active(&self) -> bool {
         self.operstate == "UP"
diff --git a/proxmox-network-api/src/config/mod.rs b/proxmox-network-api/src/config/mod.rs
index 25ddd13f..9a9a0f07 100644
--- a/proxmox-network-api/src/config/mod.rs
+++ b/proxmox-network-api/src/config/mod.rs
@@ -3,7 +3,8 @@ mod lexer;
 mod parser;
 
 pub use helper::{
-    AltnameMapping, IpLink, LinkInfo, assert_ifupdown2_installed, network_reload, parse_cidr,
+    AltnameMapping, IpLink, LinkFlag, LinkInfo, assert_ifupdown2_installed, network_reload,
+    parse_cidr,
 };
 
 use std::collections::{BTreeMap, HashMap, HashSet};
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH proxmox v2 03/11] wireguard: derive additional traits for public key
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox v2 01/11] network-api: add missing getters Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox v2 02/11] network-api: add support for parsing interface flags Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox-ve-rs v2 04/11] ve-config: sdn: wireguard: add getters for interface listen port and " Stefan Hanreich
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 proxmox-wireguard/src/lib.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/proxmox-wireguard/src/lib.rs b/proxmox-wireguard/src/lib.rs
index 5c3ac674..d8338b1c 100644
--- a/proxmox-wireguard/src/lib.rs
+++ b/proxmox-wireguard/src/lib.rs
@@ -42,7 +42,7 @@ impl From<proxmox_ini::Error> for Error {
 }
 
 /// Public key of a WireGuard peer.
-#[derive(Clone, Copy, Deserialize, Serialize, Hash, Debug)]
+#[derive(Clone, Copy, Deserialize, Serialize, Hash, Debug, PartialEq, Eq, Ord, PartialOrd)]
 #[serde(transparent)]
 pub struct PublicKey(#[serde(with = "proxmox_serde::byte_array_as_base64")] [u8; 32]);
 
@@ -59,6 +59,9 @@ impl UpdaterType for PublicKey {
     type Updater = Option<PublicKey>;
 }
 
+proxmox_serde::forward_from_str_to_deserialize!(PublicKey);
+proxmox_serde::forward_display_to_serialize!(PublicKey);
+
 /// Private key of a WireGuard peer.
 #[derive(Clone, Copy, Deserialize, Serialize, Hash)]
 #[serde(transparent)]
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH proxmox-ve-rs v2 04/11] ve-config: sdn: wireguard: add getters for interface listen port and public key
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (2 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH proxmox v2 03/11] wireguard: derive additional traits for public key Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox-ve-rs v2 05/11] ve-config: sdn: wireguard: add helper for resolving the peers of an interface Stefan Hanreich
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

The fabric status reporting needs the configured values to describe
interfaces that are missing from the running WireGuard state.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 .../sdn/fabric/section_config/protocol/wireguard.rs    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/wireguard.rs b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/wireguard.rs
index 8e5df37c..1e92eb67 100644
--- a/proxmox-ve-config/src/sdn/fabric/section_config/protocol/wireguard.rs
+++ b/proxmox-ve-config/src/sdn/fabric/section_config/protocol/wireguard.rs
@@ -545,6 +545,16 @@ impl WireGuardInterfaceProperties {
         self.name = name
     }
 
+    /// Get the listen port of the interface.
+    pub fn listen_port(&self) -> u16 {
+        self.listen_port
+    }
+
+    /// Get the public key of the interface.
+    pub fn public_key(&self) -> &PublicKey {
+        &self.public_key
+    }
+
     /// Get the ip (IPv4) of the interface.
     pub fn ip(&self) -> Option<&Ipv4Cidr> {
         self.ip.as_ref()
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH proxmox-ve-rs v2 05/11] ve-config: sdn: wireguard: add helper for resolving the peers of an interface
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (3 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH proxmox-ve-rs v2 04/11] ve-config: sdn: wireguard: add getters for interface listen port and " Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 06/11] sdn status: fabrics: add status reporting for wireguard Stefan Hanreich
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

This function will be used by the status reporting, which requires the
ability to match a peer from the `wg show` output to the respective
node in the section config, in order to include the corresponding
node/interface in its informational output. This helps users matching
peers from the running WireGuard configuration to their respective
section config entry. It also allows checking whether the running
WireGuard configuration contains exactly the configured peers.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 proxmox-ve-config/src/sdn/fabric/mod.rs | 88 ++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 1 deletion(-)

diff --git a/proxmox-ve-config/src/sdn/fabric/mod.rs b/proxmox-ve-config/src/sdn/fabric/mod.rs
index 79bb1fd9..d4687fb1 100644
--- a/proxmox-ve-config/src/sdn/fabric/mod.rs
+++ b/proxmox-ve-config/src/sdn/fabric/mod.rs
@@ -7,6 +7,7 @@ use std::marker::PhantomData;
 use std::ops::Deref;
 
 use anyhow::Error;
+use proxmox_wireguard::PublicKey;
 use section_config::protocol::wireguard::WireGuardProperties;
 use serde::{Deserialize, Serialize};
 
@@ -34,7 +35,8 @@ use crate::sdn::fabric::section_config::protocol::ospf::{
     OspfNodePropertiesUpdater, OspfProperties, OspfPropertiesUpdater,
 };
 use crate::sdn::fabric::section_config::protocol::wireguard::{
-    WireGuardDeletableProperties, WireGuardNode, WireGuardNodeDeletableProperties,
+    ExternalWireGuardNode, InternalWireGuardNode, WireGuardDeletableProperties,
+    WireGuardInterfaceProperties, WireGuardNode, WireGuardNodeDeletableProperties,
     WireGuardNodePeer, WireGuardNodeUpdater, WireGuardPropertiesUpdater,
 };
 use crate::sdn::fabric::section_config::{FabricOrNode, Section};
@@ -215,6 +217,90 @@ impl_entry!(Ospf, OspfProperties, OspfNodeProperties);
 impl_entry!(WireGuard, WireGuardProperties, WireGuardNode);
 impl_entry!(Bgp, BgpProperties, BgpNode);
 
+/// A configured peer of a WireGuard interface, resolved to the node it refers to.
+pub enum WireGuardInterfacePeer<'a> {
+    /// A peer that refers to an interface of an internal node.
+    Internal {
+        node_id: &'a NodeId,
+        node: &'a InternalWireGuardNode,
+        interface: &'a WireGuardInterfaceProperties,
+    },
+    /// A peer that refers to an external node.
+    External {
+        node_id: &'a NodeId,
+        node: &'a ExternalWireGuardNode,
+    },
+}
+
+impl WireGuardInterfacePeer<'_> {
+    /// Returns the public key of the peer.
+    pub fn public_key(&self) -> &PublicKey {
+        match self {
+            Self::Internal { interface, .. } => interface.public_key(),
+            Self::External { node, .. } => &node.public_key,
+        }
+    }
+}
+
+impl Entry<WireGuardProperties, WireGuardNode> {
+    /// Resolve the configured peers of an interface on a node to the nodes they refer to.
+    ///
+    /// These are the same peers with the same public keys as in the generated WireGuard
+    /// configuration of the interface.
+    pub fn interface_peers(
+        &self,
+        local_node_id: &NodeId,
+        interface: &str,
+    ) -> Result<Vec<WireGuardInterfacePeer<'_>>, Error> {
+        let Node::WireGuard(wireguard_node) = self.get_node(local_node_id)? else {
+            anyhow::bail!("no wireguard node with id {local_node_id} found");
+        };
+
+        let WireGuardNode::Internal(internal_node) = wireguard_node.properties() else {
+            anyhow::bail!("wireguard node with id {local_node_id} is not an internal node");
+        };
+
+        let mut peers = Vec::new();
+
+        for peer in internal_node
+            .peers()
+            .filter(|peer| peer.iface().as_ref() == interface)
+        {
+            let referenced_wireguard_node = self.node_section(peer.node())?;
+
+            match (referenced_wireguard_node.properties(), peer) {
+                (
+                    WireGuardNode::Internal(referenced_internal_node),
+                    WireGuardNodePeer::Internal(internal_peer),
+                ) => {
+                    let referenced_interface = referenced_internal_node
+                        .interfaces()
+                        .find(|interface| interface.name() == &internal_peer.node_iface)
+                        .ok_or_else(|| anyhow::anyhow!("referenced interface does not exist"))?;
+
+                    peers.push(WireGuardInterfacePeer::Internal {
+                        node_id: peer.node(),
+                        node: referenced_internal_node,
+                        interface: referenced_interface,
+                    });
+                }
+                (
+                    WireGuardNode::External(referenced_external_node),
+                    WireGuardNodePeer::External(_),
+                ) => {
+                    peers.push(WireGuardInterfacePeer::External {
+                        node_id: peer.node(),
+                        node: referenced_external_node,
+                    });
+                }
+                _ => anyhow::bail!("invalid combination of peer / node types"),
+            }
+        }
+
+        Ok(peers)
+    }
+}
+
 /// All possible entries in a [`FabricConfig`].
 ///
 /// It utilizes the [`Entry`] struct to validate proper combinations of [`FabricSection`] and
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH proxmox-perl-rs v2 06/11] sdn status: fabrics: add status reporting for wireguard
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (4 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH proxmox-ve-rs v2 05/11] ve-config: sdn: wireguard: add helper for resolving the peers of an interface Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 07/11] sdn status: fabrics: check interfaces and peers for wireguard status Stefan Hanreich
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

Utilize the built-in `wg show` command to obtain the status of all
WireGuard interfaces that are configured on the node. Additionally,
utilize the status output from `ip link` to obtain additional
information about the state of the wireguard interfaces themselves.

In order to be able to match the peers from the `wg show` output to the
entities in the fabrics configuration, their public key is used, since
WireGuard identifies the peers of an interface by it. The reported
endpoint is the one that is currently used by WireGuard. Peers that are
not part of the fabrics configuration are reported without a name,
instead of failing the whole request.

Values that WireGuard reports as unset, such as the endpoint before the
first handshake or a disabled persistent keepalive, are omitted.

The interface list is based on the fabrics configuration rather than
the `wg show` output. Otherwise, interfaces that do not exist, e.g.
because applying the configuration failed on this node, would silently
vanish from the status. The same applies to interfaces that `wg show`
fails to read, since it skips them and still exits successfully as
long as at least one interface could be read. Such interfaces are
reported with the state 'missing' or 'unknown' respectively, and the
public key and listen port are taken from the configuration.

A line of the `wg show` output that belongs to an interface of the
fabric and cannot be parsed fails the whole request, since skipping it
would silently report incomplete information. This should not happen
in practice, since the format is fixed: fields are separated by tabs,
unset values are printed as '(none)' or 'off', and interface names
cannot contain whitespace. Lines of other interfaces are skipped
without being parsed.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 pve-rs/Cargo.toml                  |   1 +
 pve-rs/src/bindings/sdn/fabrics.rs |  39 +-
 pve-rs/src/sdn/status.rs           | 826 ++++++++++++++++++++++++++++-
 3 files changed, 859 insertions(+), 7 deletions(-)

diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml
index f22e3ae..6ecb634 100644
--- a/pve-rs/Cargo.toml
+++ b/pve-rs/Cargo.toml
@@ -38,6 +38,7 @@ proxmox-frr = { version = "0.6.0" }
 proxmox-http = { version = "1.0.2", features = ["client-sync", "client-trait"] }
 proxmox-http-error = "1"
 proxmox-log = "1"
+proxmox-network-api = { version = "1", features = ["impl"] }
 proxmox-network-types = "1.1.2"
 proxmox-notify = { version = "2", features = ["pve-context", "legacy-matchers"] }
 proxmox-oci = "0.2.2"
diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index 1d3e8b5..73fc898 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -14,6 +14,7 @@ pub mod pve_rs_sdn_fabrics {
 
     use anyhow::{Context, Error, format_err};
     use openssl::hash::{MessageDigest, hash};
+    use proxmox_network_api::get_network_interfaces;
     use proxmox_ve_config::sdn::fabric::section_config::node::api::{Node, NodeUpdater};
     use proxmox_ve_config::sdn::fabric::section_config::protocol::ospf::OspfRedistribution;
     use serde::{Deserialize, Serialize};
@@ -780,6 +781,14 @@ pub mod pve_rs_sdn_fabrics {
         Ok(interfaces)
     }
 
+    /// Get the output of `wg show all dump`.
+    fn get_wireguard_dump() -> Result<String, Error> {
+        let mut command = Command::new("wg");
+        command.args(["show", "all", "dump"]);
+
+        proxmox_sys::command::run_command(command, None)
+    }
+
     /// Read and parse the running-config and get the fabrics section
     ///
     /// This will return a valid FabricConfig. Note that we read the file manually and not through
@@ -956,7 +965,19 @@ pub mod pve_rs_sdn_fabrics {
                 )
                 .map(|v| v.into())
             }
-            FabricEntry::WireGuard(_) => Ok(status::NeighborStatus::WireGuard(Vec::new())),
+            FabricEntry::WireGuard(fabric_entry) => {
+                let wg_dump = get_wireguard_dump()?;
+
+                let node_name = proxmox_sys::nodename();
+                let current_node_id = NodeId::from_string(node_name.to_string())?;
+
+                status::wireguard::parse_wireguard_neighbors(
+                    &wg_dump,
+                    fabric_entry.node_section(&current_node_id)?,
+                    fabric_entry,
+                )
+                .map(Into::into)
+            }
             FabricEntry::Bgp(_) => {
                 let bgp_neighbors_string = String::from_utf8(
                     Command::new("sh")
@@ -1034,7 +1055,21 @@ pub mod pve_rs_sdn_fabrics {
                 )
                 .map(|v| v.into())
             }
-            FabricEntry::WireGuard(_) => Ok(status::InterfaceStatus::WireGuard(Vec::new())),
+            FabricEntry::WireGuard(fabric_entry) => {
+                let wg_dump = get_wireguard_dump()?;
+
+                let network_interfaces = get_network_interfaces()?;
+
+                let node_name = proxmox_sys::nodename();
+                let current_node_id = NodeId::from_string(node_name.to_string())?;
+
+                status::wireguard::parse_wireguard_interfaces(
+                    &wg_dump,
+                    fabric_entry.node_section(&current_node_id)?,
+                    &network_interfaces,
+                )
+                .map(Into::into)
+            }
             FabricEntry::Bgp(_) => {
                 let bgp_neighbors_string = String::from_utf8(
                     Command::new("sh")
diff --git a/pve-rs/src/sdn/status.rs b/pve-rs/src/sdn/status.rs
index 7a1334d..ddbe797 100644
--- a/pve-rs/src/sdn/status.rs
+++ b/pve-rs/src/sdn/status.rs
@@ -81,13 +81,345 @@ mod openfabric {
     }
 }
 
-mod wireguard {
+pub mod wireguard {
+    use std::collections::{HashMap, HashSet};
+
+    use anyhow::Context;
+    use proxmox_network_api::{IpLink, LinkFlag};
+    use proxmox_ve_config::sdn::fabric::{
+        Entry, WireGuardInterfacePeer,
+        section_config::{
+            node::NodeSection,
+            protocol::wireguard::{WireGuardNode, WireGuardProperties},
+        },
+    };
+    use proxmox_wireguard::PublicKey;
     use serde::Serialize;
 
-    #[derive(Debug, Serialize)]
-    pub struct NeighborStatus;
-    #[derive(Debug, Serialize)]
-    pub struct InterfaceStatus;
+    #[derive(Debug, Serialize, PartialEq, Eq, PartialOrd, Ord)]
+    #[serde(rename_all = "kebab-case")]
+    pub struct NeighborStatus {
+        #[serde(skip_serializing_if = "Option::is_none")]
+        pub neighbor: Option<String>,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        pub name: Option<String>,
+        pub interface: String,
+        pub public_key: PublicKey,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        pub allowed_ips: Option<String>,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        pub latest_handshake: Option<u64>,
+        pub bytes_rx: u64,
+        pub bytes_tx: u64,
+        #[serde(skip_serializing_if = "Option::is_none")]
+        pub persistent_keepalive: Option<u16>,
+    }
+
+    /// The state of a WireGuard interface on the node.
+    #[derive(Debug, Serialize, PartialEq, Eq, PartialOrd, Ord)]
+    #[serde(rename_all = "lowercase")]
+    pub enum WireGuardInterfaceState {
+        /// The interface exists and has the `UP` flag set.
+        Up,
+        /// The interface exists, but does not have the `UP` flag set.
+        Down,
+        /// The interface does not exist.
+        Missing,
+        /// The interface exists, but wg could not read its state.
+        Unknown,
+        /// The interface exists, but is not a WireGuard interface.
+        Error,
+    }
+
+    #[derive(Debug, Serialize, PartialEq, Eq, PartialOrd, Ord)]
+    #[serde(rename_all = "kebab-case")]
+    pub struct InterfaceStatus {
+        pub name: String,
+        #[serde(rename = "type")]
+        pub ty: String,
+        pub state: WireGuardInterfaceState,
+        pub public_key: PublicKey,
+        pub listen_port: u16,
+    }
+
+    fn is_wireguard_interface(network_interface: &IpLink) -> bool {
+        network_interface
+            .linkinfo()
+            .and_then(|link_info| link_info.info_kind())
+            .is_some_and(|info_kind| info_kind == "wireguard")
+    }
+
+    /// Determines the state of an interface from its network interface and whether wg could read
+    /// its state.
+    fn interface_state(
+        network_interface: Option<&IpLink>,
+        is_running: bool,
+    ) -> WireGuardInterfaceState {
+        let Some(network_interface) = network_interface else {
+            return WireGuardInterfaceState::Missing;
+        };
+
+        if !is_wireguard_interface(network_interface) {
+            return WireGuardInterfaceState::Error;
+        }
+
+        if !is_running {
+            return WireGuardInterfaceState::Unknown;
+        }
+
+        if network_interface.flags().any(|flag| *flag == LinkFlag::Up) {
+            WireGuardInterfaceState::Up
+        } else {
+            WireGuardInterfaceState::Down
+        }
+    }
+
+    /// Parses the lines describing the interfaces themselves in the `wg show all dump` output.
+    ///
+    /// Returns the public key, which is unset if the interface has no private key, and the listen
+    /// port of each interface in `interfaces`. Lines of other interfaces are skipped without being
+    /// parsed.
+    fn parse_running_interfaces<'a>(
+        wg_dump_output: &'a str,
+        interfaces: &HashSet<&str>,
+    ) -> Result<HashMap<&'a str, (Option<PublicKey>, u16)>, anyhow::Error> {
+        let mut running_interfaces = HashMap::new();
+        let mut last_interface = None;
+
+        for line in wg_dump_output.lines() {
+            let mut parts = line.split('\t');
+
+            let interface = parts.next().ok_or_else(|| {
+                anyhow::anyhow!("could not read interface name from `wg dump` output")
+            })?;
+
+            // the first line of each interface describes the interface itself, the following
+            // lines describe its peers
+            if last_interface == Some(interface) {
+                continue;
+            }
+
+            last_interface = Some(interface);
+
+            if !interfaces.contains(interface) {
+                continue;
+            }
+
+            // skip the private key
+            parts.next().ok_or_else(|| {
+                anyhow::anyhow!("could not read private key from `wg dump` output")
+            })?;
+
+            // wg prints "(none)" as public key if no private key is set
+            let public_key = match parts
+                .next()
+                .ok_or_else(|| anyhow::anyhow!("could not read public key from `wg dump` output"))?
+            {
+                "(none)" => None,
+                public_key => Some(
+                    public_key
+                        .parse()
+                        .with_context(|| "could not parse public key from `wg dump` output.")?,
+                ),
+            };
+
+            let listen_port: u16 = parts
+                .next()
+                .ok_or_else(|| anyhow::anyhow!("could not read listen port from `wg dump` output"))?
+                .parse()
+                .with_context(|| "could not parse listen_port from `wg dump` output")?;
+
+            running_interfaces.insert(interface, (public_key, listen_port));
+        }
+
+        Ok(running_interfaces)
+    }
+
+    pub fn parse_wireguard_interfaces(
+        wg_dump_output: &str,
+        node_section: &NodeSection<WireGuardNode>,
+        network_interfaces: &HashMap<String, IpLink>,
+    ) -> Result<Vec<InterfaceStatus>, anyhow::Error> {
+        let WireGuardNode::Internal(wireguard_node) = node_section.properties() else {
+            anyhow::bail!("is not an internal node");
+        };
+
+        let interfaces: HashSet<&str> = wireguard_node
+            .interfaces()
+            .map(|interface| interface.name().as_ref())
+            .collect();
+
+        let running_interfaces = parse_running_interfaces(wg_dump_output, &interfaces)?;
+
+        // Report every configured interface, so that interfaces which do not exist or whose
+        // state could not be read by wg do not silently vanish from the status.
+        let interface_status = wireguard_node
+            .interfaces()
+            .map(|interface| {
+                let name = interface.name().as_ref();
+                let running_interface = running_interfaces.get(name);
+
+                let state =
+                    interface_state(network_interfaces.get(name), running_interface.is_some());
+
+                let (public_key, listen_port) = match running_interface {
+                    Some((Some(public_key), listen_port)) => (*public_key, *listen_port),
+                    _ => (*interface.public_key(), interface.listen_port()),
+                };
+
+                InterfaceStatus {
+                    name: name.to_string(),
+                    ty: "wireguard".to_string(),
+                    state,
+                    public_key,
+                    listen_port,
+                }
+            })
+            .collect();
+
+        Ok(interface_status)
+    }
+
+    /// Returns `None` for values that wg prints as "(none)".
+    fn optional_value(value: &str) -> Option<&str> {
+        (value != "(none)").then_some(value)
+    }
+
+    pub fn parse_wireguard_neighbors(
+        wg_dump_output: &str,
+        node_section: &NodeSection<WireGuardNode>,
+        fabric: &Entry<WireGuardProperties, WireGuardNode>,
+    ) -> Result<Vec<NeighborStatus>, anyhow::Error> {
+        let WireGuardNode::Internal(wireguard_node) = node_section.properties() else {
+            anyhow::bail!("is not an internal node");
+        };
+
+        let mut neighbors = Vec::new();
+        let mut last_interface = None;
+
+        // the names of the configured peers of each interface, by their public key
+        let mut peer_names = HashMap::new();
+
+        for interface in wireguard_node.interfaces() {
+            let interface_name: &str = interface.name().as_ref();
+
+            let names: HashMap<PublicKey, String> = fabric
+                .interface_peers(node_section.id().node_id(), interface_name)?
+                .into_iter()
+                .map(|peer| {
+                    let name = match &peer {
+                        WireGuardInterfacePeer::Internal {
+                            node_id, interface, ..
+                        } => format!("{node_id} ({})", interface.name()),
+                        WireGuardInterfacePeer::External { node_id, .. } => node_id.to_string(),
+                    };
+
+                    (*peer.public_key(), name)
+                })
+                .collect();
+
+            peer_names.insert(interface_name, names);
+        }
+
+        for line in wg_dump_output.lines() {
+            let mut parts = line.split('\t');
+
+            let interface = parts.next().ok_or_else(|| {
+                anyhow::anyhow!("could not read interface name from `wg dump` output")
+            })?;
+
+            // the first line of each interface describes the interface itself, the following
+            // lines describe its peers
+            if last_interface != Some(interface) {
+                last_interface = Some(interface);
+                continue;
+            }
+
+            let Some(names) = peer_names.get(interface) else {
+                continue;
+            };
+
+            let public_key: PublicKey = parts
+                .next()
+                .ok_or_else(|| anyhow::anyhow!("could not read public key from `wg dump` output"))?
+                .parse()
+                .with_context(|| "could not parse public key from `wg dump` output.")?;
+
+            // skip the preshared key
+            parts.next().ok_or_else(|| {
+                anyhow::anyhow!("could not read preshared key from `wg dump` output")
+            })?;
+
+            // this is the endpoint currently used by WireGuard, which can differ from the
+            // configured one, e.g. if the peer is behind NAT
+            let neighbor = parts
+                .next()
+                .ok_or_else(|| anyhow::anyhow!("could not read neighbor from `wg dump` output"))
+                .map(optional_value)?
+                .map(str::to_string);
+
+            let allowed_ips = parts
+                .next()
+                .ok_or_else(|| anyhow::anyhow!("could not read allowed ips from `wg dump` output"))
+                .map(optional_value)?
+                .map(str::to_string);
+
+            // wg prints 0 if no handshake happened yet
+            let latest_handshake = parts
+                .next()
+                .ok_or_else(|| {
+                    anyhow::anyhow!("could not read latest handshake from `wg dump` output")
+                })?
+                .parse()
+                .map(|latest_handshake| (latest_handshake != 0).then_some(latest_handshake))
+                .with_context(|| "could not parse latest_handshake timestamp")?;
+
+            let bytes_rx = parts
+                .next()
+                .ok_or_else(|| {
+                    anyhow::anyhow!("could not read received bytes from `wg dump` output")
+                })?
+                .parse()
+                .with_context(|| "could not parse received bytes")?;
+
+            let bytes_tx = parts
+                .next()
+                .ok_or_else(|| {
+                    anyhow::anyhow!("could not read transmitted bytes from `wg dump` output")
+                })?
+                .parse()
+                .with_context(|| "could not parse transmitted bytes")?;
+
+            let persistent_keepalive = match parts.next().ok_or_else(|| {
+                anyhow::anyhow!("could not read persistent_keepalive from `wg dump` output")
+            })? {
+                "off" => None,
+                persistent_keepalive => Some(
+                    persistent_keepalive
+                        .parse()
+                        .with_context(|| "could not parse persistent_keepalive interval")?,
+                ),
+            };
+
+            // peers that are not part of the fabric configuration, e.g. because applying it
+            // failed on this node, are still reported, but without a name
+            let name = names.get(&public_key).cloned();
+
+            neighbors.push(NeighborStatus {
+                neighbor,
+                name,
+                interface: interface.to_string(),
+                public_key,
+                allowed_ips,
+                latest_handshake,
+                bytes_rx,
+                bytes_tx,
+                persistent_keepalive,
+            });
+        }
+
+        Ok(neighbors)
+    }
 }
 
 mod bgp {
@@ -129,6 +461,11 @@ impl From<Vec<ospf::NeighborStatus>> for NeighborStatus {
         NeighborStatus::Ospf(value)
     }
 }
+impl From<Vec<wireguard::NeighborStatus>> for NeighborStatus {
+    fn from(value: Vec<wireguard::NeighborStatus>) -> Self {
+        NeighborStatus::WireGuard(value)
+    }
+}
 impl From<Vec<bgp::NeighborStatus>> for NeighborStatus {
     fn from(value: Vec<bgp::NeighborStatus>) -> Self {
         NeighborStatus::Bgp(value)
@@ -155,6 +492,11 @@ impl From<Vec<ospf::InterfaceStatus>> for InterfaceStatus {
         InterfaceStatus::Ospf(value)
     }
 }
+impl From<Vec<wireguard::InterfaceStatus>> for InterfaceStatus {
+    fn from(value: Vec<wireguard::InterfaceStatus>) -> Self {
+        InterfaceStatus::WireGuard(value)
+    }
+}
 impl From<Vec<bgp::InterfaceStatus>> for InterfaceStatus {
     fn from(value: Vec<bgp::InterfaceStatus>) -> Self {
         InterfaceStatus::Bgp(value)
@@ -2778,4 +3120,478 @@ mod tests {
             assert_eq!(reference, output);
         }
     }
+
+    mod wireguard {
+        use std::str::FromStr;
+
+        use proxmox_network_api::IpLink;
+        use proxmox_section_config::typed::ApiSectionDataEntry;
+        use proxmox_ve_config::sdn::fabric::FabricEntry;
+        use proxmox_ve_config::sdn::fabric::section_config::node::NodeSection;
+        use proxmox_ve_config::sdn::fabric::section_config::protocol::wireguard::{
+            WireGuardNode, WireGuardProperties,
+        };
+
+        use super::super::wireguard::{
+            InterfaceStatus, NeighborStatus, WireGuardInterfaceState, parse_wireguard_interfaces,
+            parse_wireguard_neighbors,
+        };
+        use super::super::*;
+
+        /// Parses the fabric configuration that all tests use.
+        ///
+        /// The tests take the view of the node elementalist: it has the interfaces wg1 (with the
+        /// external peer stormweaver) and wg0 (with the internal peers occultist and chronomancer).
+        fn fabric_config() -> Valid<FabricConfig> {
+            let raw_config = r#"wireguard_fabric: test
+
+wireguard_node: test_chronomancer
+        endpoint 172.31.1.4
+        interfaces name=wg1,listen_port=51821,public_key=+RAKruThY8Qx/oLKRoqYZ4DZJwd9/BO3lVVAR6INNTo=
+        interfaces name=wg0,listen_port=51820,public_key=8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=,ip=198.51.100.4/24
+        peers type=internal,node=elementalist,node_iface=wg0,iface=wg0
+        peers type=internal,node=occultist,node_iface=wg0,iface=wg0
+        peers type=external,node=stormweaver,iface=wg1
+        role internal
+
+wireguard_node: test_elementalist
+        endpoint 172.31.1.1
+        interfaces name=wg1,listen_port=51821,public_key=Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=
+        interfaces name=wg0,listen_port=51820,public_key=AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=,ip=198.51.100.1/24
+        peers type=internal,node=occultist,node_iface=wg0,iface=wg0
+        peers type=internal,node=chronomancer,node_iface=wg0,iface=wg0
+        peers type=external,node=stormweaver,iface=wg1
+        role internal
+
+wireguard_node: test_occultist
+        allowed_ips 203.0.113.0/28
+        endpoint 172.31.1.2
+        interfaces name=wg1,listen_port=51821,public_key=UBvDcsMICJLpy/+aRpJXFbDfU4eZrBeWnHimjzla/SI=
+        interfaces name=wg0,listen_port=51820,public_key=+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=,ip=198.51.100.2/24
+        peers type=external,node=stormweaver,iface=wg1
+        peers type=internal,node=elementalist,node_iface=wg0,iface=wg0
+        peers type=internal,node=chronomancer,node_iface=wg0,iface=wg0
+        role internal
+
+wireguard_node: test_stormweaver
+        endpoint 172.31.1.10:51820
+        public_key aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=
+        role external"#;
+
+            let section_config = Section::parse_section_config("fabrics.cfg", raw_config)
+                .expect("valid section config");
+
+            FabricConfig::from_section_config(section_config).expect("valid fabric configuration")
+        }
+
+        fn wireguard_fabric(config: &FabricConfig) -> &Entry<WireGuardProperties, WireGuardNode> {
+            let fabric_id = FabricId::from_str("test").expect("valid fabric id");
+
+            let Ok(FabricEntry::WireGuard(fabric)) = config.get_fabric(&fabric_id) else {
+                panic!("fabric is not a wireguard fabric");
+            };
+
+            fabric
+        }
+
+        fn elementalist(
+            fabric: &Entry<WireGuardProperties, WireGuardNode>,
+        ) -> &NodeSection<WireGuardNode> {
+            let node_id = NodeId::from_str("elementalist").expect("valid node id");
+
+            fabric
+                .node_section(&node_id)
+                .expect("node exists in fabric")
+        }
+
+        /// Parses the output of `ip -details -json link show`.
+        fn network_interfaces(ip_link_output: &str) -> HashMap<String, IpLink> {
+            serde_json::from_str::<Vec<IpLink>>(ip_link_output)
+                .expect("valid ip link output")
+                .into_iter()
+                .map(|ip_link| (ip_link.name().to_string(), ip_link))
+                .collect()
+        }
+
+        #[test]
+        fn interfaces_up_and_down() {
+            // wg0 is up, wg1 is down
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "DOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![
+                InterfaceStatus {
+                    name: "wg1".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Down,
+                    public_key: "Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51821,
+                },
+                InterfaceStatus {
+                    name: "wg0".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Up,
+                    public_key: "AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51820,
+                },
+            ];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_interfaces(wg_dump, elementalist(fabric), &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn interface_missing() {
+            // wg1 does not exist on the node, so its values are taken from the configuration
+            let wg_dump = r#"wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![
+                InterfaceStatus {
+                    name: "wg1".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Missing,
+                    public_key: "Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51821,
+                },
+                InterfaceStatus {
+                    name: "wg0".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Up,
+                    public_key: "AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51820,
+                },
+            ];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_interfaces(wg_dump, elementalist(fabric), &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn interface_unknown() {
+            // wg1 exists, but is missing from the wg output, since wg could not read it
+            let wg_dump = r#"wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![
+                InterfaceStatus {
+                    name: "wg1".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Unknown,
+                    public_key: "Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51821,
+                },
+                InterfaceStatus {
+                    name: "wg0".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Up,
+                    public_key: "AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51820,
+                },
+            ];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_interfaces(wg_dump, elementalist(fabric), &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn interface_without_private_key() {
+            // wg0 has no private key, so its public key and listen port are taken from the configuration
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	(none)	(none)	0	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![
+                InterfaceStatus {
+                    name: "wg1".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Up,
+                    public_key: "Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51821,
+                },
+                InterfaceStatus {
+                    name: "wg0".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Up,
+                    public_key: "AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51820,
+                },
+            ];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_interfaces(wg_dump, elementalist(fabric), &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn interface_not_wireguard() {
+            // wg0 exists, but is not a WireGuard interface
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "ether", "address": "a2:5f:3c:11:22:33", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "dummy"}, "flags": ["BROADCAST", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![
+                InterfaceStatus {
+                    name: "wg1".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Up,
+                    public_key: "Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51821,
+                },
+                InterfaceStatus {
+                    name: "wg0".to_string(),
+                    ty: "wireguard".to_string(),
+                    state: WireGuardInterfaceState::Error,
+                    public_key: "AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M="
+                        .parse()
+                        .expect("valid public key"),
+                    listen_port: 51820,
+                },
+            ];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_interfaces(wg_dump, elementalist(fabric), &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn neighbors() {
+            // all configured peers are present, but there was no handshake yet
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![
+                NeighborStatus {
+                    neighbor: Some("172.31.1.10:51820".to_string()),
+                    name: Some("stormweaver".to_string()),
+                    interface: "wg1".to_string(),
+                    public_key: "aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0="
+                        .parse()
+                        .expect("valid public key"),
+                    allowed_ips: None,
+                    latest_handshake: None,
+                    bytes_rx: 0,
+                    bytes_tx: 0,
+                    persistent_keepalive: None,
+                },
+                NeighborStatus {
+                    neighbor: Some("172.31.1.2:51820".to_string()),
+                    name: Some("occultist (wg0)".to_string()),
+                    interface: "wg0".to_string(),
+                    public_key: "+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI="
+                        .parse()
+                        .expect("valid public key"),
+                    allowed_ips: Some("198.51.100.2/32,203.0.113.0/28".to_string()),
+                    latest_handshake: None,
+                    bytes_rx: 0,
+                    bytes_tx: 0,
+                    persistent_keepalive: None,
+                },
+                NeighborStatus {
+                    neighbor: Some("172.31.1.4:51820".to_string()),
+                    name: Some("chronomancer (wg0)".to_string()),
+                    interface: "wg0".to_string(),
+                    public_key: "8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA="
+                        .parse()
+                        .expect("valid public key"),
+                    allowed_ips: Some("198.51.100.4/32".to_string()),
+                    latest_handshake: None,
+                    bytes_rx: 0,
+                    bytes_tx: 0,
+                    persistent_keepalive: None,
+                },
+            ];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn neighbor_roamed() {
+            // occultist is reachable via a different address than its configured endpoint, e.g. due to NAT
+            let wg_dump = r#"wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	203.0.113.50:40123	198.51.100.2/32,203.0.113.0/28	1781234567	1024	2048	25"#;
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![NeighborStatus {
+                neighbor: Some("203.0.113.50:40123".to_string()),
+                name: Some("occultist (wg0)".to_string()),
+                interface: "wg0".to_string(),
+                public_key: "+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI="
+                    .parse()
+                    .expect("valid public key"),
+                allowed_ips: Some("198.51.100.2/32,203.0.113.0/28".to_string()),
+                latest_handshake: Some(1781234567),
+                bytes_rx: 1024,
+                bytes_tx: 2048,
+                persistent_keepalive: Some(25),
+            }];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn neighbor_without_endpoint() {
+            // chronomancer has no endpoint, since it has not connected yet
+            let wg_dump = r#"wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	(none)	198.51.100.4/32	0	0	0	off"#;
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![NeighborStatus {
+                neighbor: None,
+                name: Some("chronomancer (wg0)".to_string()),
+                interface: "wg0".to_string(),
+                public_key: "8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA="
+                    .parse()
+                    .expect("valid public key"),
+                allowed_ips: Some("198.51.100.4/32".to_string()),
+                latest_handshake: None,
+                bytes_rx: 0,
+                bytes_tx: 0,
+                persistent_keepalive: None,
+            }];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn neighbor_not_configured() {
+            // the peer is not part of the fabric configuration, so it has no name
+            let wg_dump = r#"wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=	(none)	(none)	(none)	0	0	0	off"#;
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            let expected = vec![NeighborStatus {
+                neighbor: None,
+                name: None,
+                interface: "wg0".to_string(),
+                public_key: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
+                    .parse()
+                    .expect("valid public key"),
+                allowed_ips: None,
+                latest_handshake: None,
+                bytes_rx: 0,
+                bytes_tx: 0,
+                persistent_keepalive: None,
+            }];
+
+            assert_eq!(
+                expected,
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                    .expect("can parse wireguard output")
+            );
+        }
+    }
 }
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH proxmox-perl-rs v2 07/11] sdn status: fabrics: check interfaces and peers for wireguard status
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (5 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 06/11] sdn status: fabrics: add status reporting for wireguard Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 08/11] sdn status: fabrics: report status of wireguard neighbors Stefan Hanreich
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

Previously, a WireGuard fabric was always reported as ok, since there
are no routes from a routing daemon that could be checked.

Instead, report a WireGuard fabric as ok if all of its interfaces on
the node are up and use their configured public key and listen port,
and the running WireGuard configuration of each interface contains
exactly the configured peers. The configuration is taken from the
running configuration, so this catches nodes where it is not in effect,
e.g. because applying it failed on this node. This includes interfaces
that do not exist or are down, interfaces without a private key or with
a different one (e.g. after a failed key rotation), interfaces
listening on a different port, peers that are missing and stale peers
that are still present.

Handshakes are not considered, since peers do not exchange any if no
traffic is sent and persistent keepalive is disabled, which would
report healthy fabrics as not ok.

`wg show` is only called if the node is part of a WireGuard fabric.
If it fails, or its output cannot be parsed, only the WireGuard
fabrics are reported as not ok, since their state cannot be
determined, while the status of the other fabrics is still reported.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 pve-rs/src/bindings/sdn/fabrics.rs |  22 +-
 pve-rs/src/sdn/status.rs           | 373 ++++++++++++++++++++++++++++-
 2 files changed, 386 insertions(+), 9 deletions(-)

diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index 73fc898..6726045 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -1095,7 +1095,8 @@ pub mod pve_rs_sdn_fabrics {
     ///
     /// Go through all fabrics in the config, then filter out the ones that exist on this node.
     /// Check if there are any routes in the routing table that use the interface specified in the
-    /// config. If there are, show "ok" as status, otherwise "not ok".
+    /// config. If there are, show "ok" as status, otherwise "not ok". For WireGuard fabrics, check
+    /// whether all configured interfaces are up and all configured peers are present instead.
     #[export]
     fn status() -> Result<HashMap<FabricId, status::Status>, Error> {
         // This gets called every few seconds from pve to get the status of the fabrics into the
@@ -1183,7 +1184,24 @@ pub mod pve_rs_sdn_fabrics {
             bgp: bgp_routes,
         };
 
-        status::get_status(config, route_status, proxmox_sys::nodename())
+        let node_name = proxmox_sys::nodename();
+
+        let has_wireguard_node = config.all_nodes().any(|(node_id, node)| {
+            node_id.as_str() == node_name && matches!(node, ConfigNode::WireGuard(_))
+        });
+
+        // a failure only marks the WireGuard fabrics as not ok, instead of failing the status of
+        // all fabrics
+        let wireguard = has_wireguard_node
+            .then(|| -> Result<status::WireGuardParsed, Error> {
+                Ok(status::WireGuardParsed {
+                    dump: get_wireguard_dump()?,
+                    network_interfaces: get_network_interfaces()?,
+                })
+            })
+            .and_then(Result::ok);
+
+        status::get_status(config, route_status, wireguard.as_ref(), node_name)
     }
 
     /// Get all the L3 routes for the passed zone.
diff --git a/pve-rs/src/sdn/status.rs b/pve-rs/src/sdn/status.rs
index ddbe797..64ffb98 100644
--- a/pve-rs/src/sdn/status.rs
+++ b/pve-rs/src/sdn/status.rs
@@ -6,6 +6,7 @@ use proxmox_network_types::mac_address::MacAddress;
 use serde::{Deserialize, Serialize};
 
 use proxmox_frr::de::{self};
+use proxmox_network_api::IpLink;
 use proxmox_ve_config::sdn::fabric::section_config::protocol::bgp::BgpNode;
 use proxmox_ve_config::sdn::fabric::section_config::protocol::ospf::{
     OspfNodeProperties, OspfProperties,
@@ -13,7 +14,7 @@ use proxmox_ve_config::sdn::fabric::section_config::protocol::ospf::{
 use proxmox_ve_config::{
     common::valid::Valid,
     sdn::fabric::{
-        Entry, FabricConfig,
+        Entry, FabricConfig, FabricEntry,
         section_config::{Section, fabric::FabricId, node::Node as ConfigNode, node::NodeId},
     },
 };
@@ -420,6 +421,82 @@ pub mod wireguard {
 
         Ok(neighbors)
     }
+
+    /// Checks whether WireGuard on this node matches the fabric configuration.
+    ///
+    /// This is the case if all configured interfaces are up and use their configured public key and
+    /// listen port, and the running WireGuard configuration of each interface contains exactly the
+    /// configured peers. Handshakes are not considered, since peers do not exchange any if no traffic is sent
+    /// and persistent keepalive is disabled.
+    pub fn is_node_ok(
+        wg_dump_output: &str,
+        node_section: &NodeSection<WireGuardNode>,
+        fabric: &Entry<WireGuardProperties, WireGuardNode>,
+        network_interfaces: &HashMap<String, IpLink>,
+    ) -> Result<bool, anyhow::Error> {
+        let interfaces =
+            parse_wireguard_interfaces(wg_dump_output, node_section, network_interfaces)?;
+
+        if interfaces
+            .iter()
+            .any(|interface| interface.state != WireGuardInterfaceState::Up)
+        {
+            return Ok(false);
+        }
+
+        let WireGuardNode::Internal(wireguard_node) = node_section.properties() else {
+            anyhow::bail!("is not an internal node");
+        };
+
+        let interface_names: HashSet<&str> = wireguard_node
+            .interfaces()
+            .map(|interface| interface.name().as_ref())
+            .collect();
+
+        let running_interfaces = parse_running_interfaces(wg_dump_output, &interface_names)?;
+
+        // peers only reach the interface with the configured public key and listen port, which can
+        // differ from the running ones if e.g. a key rotation failed to apply or the private key is
+        // unset
+        for interface in wireguard_node.interfaces() {
+            let Some((Some(public_key), listen_port)) =
+                running_interfaces.get(interface.name().as_ref())
+            else {
+                return Ok(false);
+            };
+
+            if public_key != interface.public_key() || *listen_port != interface.listen_port() {
+                return Ok(false);
+            }
+        }
+
+        let mut running_peers: HashMap<String, HashSet<PublicKey>> = HashMap::new();
+
+        for neighbor in parse_wireguard_neighbors(wg_dump_output, node_section, fabric)? {
+            running_peers
+                .entry(neighbor.interface)
+                .or_default()
+                .insert(neighbor.public_key);
+        }
+
+        for interface in interfaces {
+            let configured_peers: HashSet<PublicKey> = fabric
+                .interface_peers(node_section.id().node_id(), &interface.name)?
+                .into_iter()
+                .map(|peer| *peer.public_key())
+                .collect();
+
+            let running_peers = running_peers.remove(&interface.name).unwrap_or_default();
+
+            // peers that are missing as well as stale ones, e.g. because applying the
+            // configuration failed on this node, mean that the configuration is not in effect
+            if configured_peers != running_peers {
+                return Ok(false);
+            }
+        }
+
+        Ok(true)
+    }
 }
 
 mod bgp {
@@ -527,12 +604,14 @@ pub enum Protocol {
 }
 
 /// The status of a fabric.
-#[derive(Debug, Serialize)]
+#[derive(Debug, Serialize, PartialEq, Eq)]
 pub enum FabricStatus {
-    /// The fabric exists and has a route
+    /// The fabric exists and has a route, or for WireGuard, all interfaces are up and all peers
+    /// are present
     #[serde(rename = "ok")]
     Ok,
-    /// The fabric does not exist or doesn't distribute any routes
+    /// The fabric does not exist or doesn't distribute any routes, or for WireGuard, an interface
+    /// is not up or a peer is missing
     #[serde(rename = "not ok")]
     NotOk,
 }
@@ -552,6 +631,15 @@ pub struct Status {
     network_type: String,
 }
 
+/// Runtime state of WireGuard on this node
+///
+/// Consists of the output of `wg show all dump` and the network interfaces as reported by
+/// `ip link`.
+pub struct WireGuardParsed {
+    pub dump: String,
+    pub network_interfaces: HashMap<String, IpLink>,
+}
+
 /// Parsed routes for all protocols
 ///
 /// These are the routes parsed from the json output of:
@@ -868,6 +956,7 @@ pub struct BgpNeighborInfo {
 pub fn get_status(
     config: Valid<FabricConfig>,
     routes: RoutesParsed,
+    wireguard: Option<&WireGuardParsed>,
     hostname: &str,
 ) -> Result<HashMap<FabricId, Status>, anyhow::Error> {
     let mut stats: HashMap<FabricId, Status> = HashMap::new();
@@ -921,7 +1010,7 @@ pub fn get_status(
             Protocol::Openfabric if has_routes => FabricStatus::Ok,
             Protocol::Ospf if has_routes => FabricStatus::Ok,
             Protocol::Bgp if has_routes => FabricStatus::Ok,
-            Protocol::WireGuard => FabricStatus::Ok,
+            Protocol::WireGuard => get_wireguard_status(&config, node, wireguard),
             _ => FabricStatus::NotOk,
         };
 
@@ -937,6 +1026,35 @@ pub fn get_status(
 
     Ok(stats)
 }
+
+/// Determine the status of a WireGuard fabric on this node.
+///
+/// Errors only mark the WireGuard fabric as not ok, so that they do not affect the status of the
+/// other fabrics.
+fn get_wireguard_status(
+    config: &FabricConfig,
+    node: &ConfigNode,
+    wireguard: Option<&WireGuardParsed>,
+) -> FabricStatus {
+    let (ConfigNode::WireGuard(node_section), Some(wireguard)) = (node, wireguard) else {
+        return FabricStatus::NotOk;
+    };
+
+    let Ok(FabricEntry::WireGuard(fabric)) = config.get_fabric(node_section.id().fabric_id())
+    else {
+        return FabricStatus::NotOk;
+    };
+
+    match wireguard::is_node_ok(
+        &wireguard.dump,
+        node_section,
+        fabric,
+        &wireguard.network_interfaces,
+    ) {
+        Ok(true) => FabricStatus::Ok,
+        _ => FabricStatus::NotOk,
+    }
+}
 /// Common for nexthops, they can be either a interface name or a ip addr
 #[derive(Debug, Serialize, PartialEq, Eq)]
 #[serde(untagged)]
@@ -3133,8 +3251,8 @@ mod tests {
         };
 
         use super::super::wireguard::{
-            InterfaceStatus, NeighborStatus, WireGuardInterfaceState, parse_wireguard_interfaces,
-            parse_wireguard_neighbors,
+            InterfaceStatus, NeighborStatus, WireGuardInterfaceState, is_node_ok,
+            parse_wireguard_interfaces, parse_wireguard_neighbors,
         };
         use super::super::*;
 
@@ -3593,5 +3711,246 @@ wg0	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=	(none)	(none)	(none)	0	0	0	off"
                     .expect("can parse wireguard output")
             );
         }
+
+        #[test]
+        fn node_ok() {
+            // all interfaces are up and have exactly the configured peers
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn node_not_ok_interface_down() {
+            // wg1 is down
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "DOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                !is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn node_not_ok_interface_missing() {
+            // wg1 does not exist on the node
+            let wg_dump = r#"wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                !is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn node_not_ok_peer_missing() {
+            // chronomancer is missing from wg0
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                !is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn node_not_ok_stale_peer() {
+            // wg0 has a peer that is not part of the configuration
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off
+wg0	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=	(none)	(none)	(none)	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                !is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn node_not_ok_other_public_key() {
+            // wg0 uses a different key pair than the configured one
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	YJ8M0XCvVUu1x1Y2fdLmSQ8w1qtlDgFr3cZyfW8ivUc=	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                !is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn node_not_ok_without_private_key() {
+            // wg0 has no private key
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	(none)	(none)	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                !is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn node_not_ok_other_listen_port() {
+            // wg0 listens on 51899 instead of the configured 51820
+            let wg_dump = r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51899	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#;
+
+            let network_interfaces = network_interfaces(
+                r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#,
+            );
+
+            let config = fabric_config();
+            let fabric = wireguard_fabric(&config);
+
+            assert!(
+                !is_node_ok(wg_dump, elementalist(fabric), fabric, &network_interfaces)
+                    .expect("can parse wireguard output")
+            );
+        }
+
+        #[test]
+        fn fabric_status_ok() {
+            // the running WireGuard state matches the configuration
+            let wireguard = WireGuardParsed {
+                dump: r#"wg1	wF2D1my5Cj962/MOS2UXLvCddm3ozmCSSuBQ1Ey6v3I=	Um+Z4Ymq3r24txH2itVVtC86ra1PIrFs9AeMebESdWM=	51821	off
+wg1	aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0=	(none)	172.31.1.10:51820	(none)	0	0	0	off
+wg0	GDHQ8ivFvwz53U0bSmQ7uTD2bJ8GpcFCCxGeU1G9m2U=	AQkUKUJXOxR/QH6fjZLx8GO1ZnnD8PueRYMJNOCzc2M=	51820	off
+wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	172.31.1.2:51820	198.51.100.2/32,203.0.113.0/28	0	0	0	off
+wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.100.4/32	0	0	0	off"#.to_string(),
+                network_interfaces: network_interfaces(r#"[
+                {"ifname": "wg0", "ifindex": 25, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]},
+                {"ifname": "wg1", "ifindex": 24, "link_type": "none", "operstate": "UNKNOWN", "linkinfo": {"info_kind": "wireguard"}, "flags": ["POINTOPOINT", "NOARP", "UP", "LOWER_UP"]}
+            ]"#),
+            };
+
+            let routes = RoutesParsed {
+                openfabric: de::Routes::default(),
+                ospf: de::Routes::default(),
+                bgp: de::Routes::default(),
+            };
+
+            let status = get_status(fabric_config(), routes, Some(&wireguard), "elementalist")
+                .expect("can determine fabric status");
+
+            let fabric_id = FabricId::from_str("test").expect("valid fabric id");
+            assert_eq!(FabricStatus::Ok, status[&fabric_id].status);
+        }
+
+        #[test]
+        fn fabric_status_not_ok_without_wireguard_state() {
+            // the WireGuard state could not be determined, e.g. because wg failed
+            let routes = RoutesParsed {
+                openfabric: de::Routes::default(),
+                ospf: de::Routes::default(),
+                bgp: de::Routes::default(),
+            };
+
+            let status = get_status(fabric_config(), routes, None, "elementalist")
+                .expect("can determine fabric status");
+
+            let fabric_id = FabricId::from_str("test").expect("valid fabric id");
+            assert_eq!(FabricStatus::NotOk, status[&fabric_id].status);
+        }
     }
 }
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH proxmox-perl-rs v2 08/11] sdn status: fabrics: report status of wireguard neighbors
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (6 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 07/11] sdn status: fabrics: check interfaces and peers for wireguard status Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH pve-network v2 09/11] api: fabric status: add schema for wireguard properties Stefan Hanreich
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

WireGuard has no notion of a peer being up or down, so derive the
status of a neighbor from its latest handshake instead:

* 'active': the latest handshake is less than 180 seconds old
* 'idle': there was no handshake within the last 180 seconds and
  persistent keepalive is disabled
* 'down': persistent keepalive is enabled, but there was no handshake
  within the last 180 seconds plus the keepalive interval plus 90
  seconds

WireGuard does not use session keys that are older than 180 seconds
(REJECT_AFTER_TIME in the kernel), neither for sending nor for
receiving. A handshake within that time therefore means that the peer
has a working session. While traffic is sent, a new handshake happens
after 120 seconds (REKEY_AFTER_TIME), so the latest handshake of an
active peer stays below 180 seconds.

Without persistent keepalive, peers only exchange handshakes if traffic
is sent. A peer without a recent handshake can then not be
distinguished from an unreachable one, so it is reported as 'idle'
rather than 'down', which would be misleading for a working but unused
peer. With persistent keepalive, keepalive packets are sent regularly,
so a reachable peer exchanges a new handshake before its session
expires. The keepalive interval and the 90 seconds for which WireGuard
retries a handshake (90 / REKEY_TIMEOUT attempts) serve as margin
before reporting a peer as 'down'.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 pve-rs/src/bindings/sdn/fabrics.rs |   1 +
 pve-rs/src/sdn/status.rs           | 132 +++++++++++++++++++++++++++--
 2 files changed, 127 insertions(+), 6 deletions(-)

diff --git a/pve-rs/src/bindings/sdn/fabrics.rs b/pve-rs/src/bindings/sdn/fabrics.rs
index 6726045..0fd756d 100644
--- a/pve-rs/src/bindings/sdn/fabrics.rs
+++ b/pve-rs/src/bindings/sdn/fabrics.rs
@@ -975,6 +975,7 @@ pub mod pve_rs_sdn_fabrics {
                     &wg_dump,
                     fabric_entry.node_section(&current_node_id)?,
                     fabric_entry,
+                    proxmox_time::epoch_i64(),
                 )
                 .map(Into::into)
             }
diff --git a/pve-rs/src/sdn/status.rs b/pve-rs/src/sdn/status.rs
index 64ffb98..4fe8397 100644
--- a/pve-rs/src/sdn/status.rs
+++ b/pve-rs/src/sdn/status.rs
@@ -97,6 +97,60 @@ pub mod wireguard {
     use proxmox_wireguard::PublicKey;
     use serde::Serialize;
 
+    /// WireGuard does not use session keys that are older than this (`REJECT_AFTER_TIME`), so a peer
+    /// with a more recent handshake has a working session.
+    const REJECT_AFTER_TIME: u64 = 180;
+
+    /// WireGuard retries a handshake for this long before giving up.
+    const REKEY_ATTEMPT_TIME: u64 = 90;
+
+    /// The status of a WireGuard peer, derived from its latest handshake.
+    #[derive(Debug, Serialize, PartialEq, Eq, PartialOrd, Ord)]
+    #[serde(rename_all = "lowercase")]
+    pub enum PeerStatus {
+        /// The peer had a working session recently.
+        Active,
+        /// The peer is not reachable, which can only be determined with persistent keepalive.
+        Down,
+        /// The peer has no recent session, since no traffic was sent and persistent keepalive is
+        /// disabled.
+        Idle,
+    }
+
+    impl PeerStatus {
+        /// Determines the status of a peer at the time `now` (UNIX epoch).
+        ///
+        /// Without persistent keepalive, peers only exchange handshakes if traffic is sent, so a
+        /// peer without a recent handshake cannot be distinguished from an unreachable one. With
+        /// persistent keepalive, a reachable peer exchanges a new handshake before its session
+        /// expires after `REJECT_AFTER_TIME`, delayed by at most the keepalive interval and
+        /// `REKEY_ATTEMPT_TIME` of retries.
+        pub fn from_handshake(
+            latest_handshake: Option<u64>,
+            persistent_keepalive: Option<u16>,
+            now: i64,
+        ) -> Self {
+            let age = latest_handshake.map(|latest_handshake| {
+                u64::try_from(now)
+                    .unwrap_or(0)
+                    .saturating_sub(latest_handshake)
+            });
+
+            match persistent_keepalive {
+                None if age.is_some_and(|age| age < REJECT_AFTER_TIME) => PeerStatus::Active,
+                None => PeerStatus::Idle,
+                Some(interval)
+                    if age.is_some_and(|age| {
+                        age < REJECT_AFTER_TIME + u64::from(interval) + REKEY_ATTEMPT_TIME
+                    }) =>
+                {
+                    PeerStatus::Active
+                }
+                Some(_) => PeerStatus::Down,
+            }
+        }
+    }
+
     #[derive(Debug, Serialize, PartialEq, Eq, PartialOrd, Ord)]
     #[serde(rename_all = "kebab-case")]
     pub struct NeighborStatus {
@@ -104,6 +158,7 @@ pub mod wireguard {
         pub neighbor: Option<String>,
         #[serde(skip_serializing_if = "Option::is_none")]
         pub name: Option<String>,
+        pub status: PeerStatus,
         pub interface: String,
         pub public_key: PublicKey,
         #[serde(skip_serializing_if = "Option::is_none")]
@@ -286,10 +341,15 @@ pub mod wireguard {
         (value != "(none)").then_some(value)
     }
 
+    /// Parses the peers of the fabric interfaces in the `wg show all dump` output.
+    ///
+    /// `now` is the current time (UNIX epoch), which is used for determining the status of the
+    /// peers.
     pub fn parse_wireguard_neighbors(
         wg_dump_output: &str,
         node_section: &NodeSection<WireGuardNode>,
         fabric: &Entry<WireGuardProperties, WireGuardNode>,
+        now: i64,
     ) -> Result<Vec<NeighborStatus>, anyhow::Error> {
         let WireGuardNode::Internal(wireguard_node) = node_section.properties() else {
             anyhow::bail!("is not an internal node");
@@ -409,6 +469,7 @@ pub mod wireguard {
             neighbors.push(NeighborStatus {
                 neighbor,
                 name,
+                status: PeerStatus::from_handshake(latest_handshake, persistent_keepalive, now),
                 interface: interface.to_string(),
                 public_key,
                 allowed_ips,
@@ -472,7 +533,10 @@ pub mod wireguard {
 
         let mut running_peers: HashMap<String, HashSet<PublicKey>> = HashMap::new();
 
-        for neighbor in parse_wireguard_neighbors(wg_dump_output, node_section, fabric)? {
+        // the status of the peers does not matter here, only whether they are present
+        let now = proxmox_time::epoch_i64();
+
+        for neighbor in parse_wireguard_neighbors(wg_dump_output, node_section, fabric, now)? {
             running_peers
                 .entry(neighbor.interface)
                 .or_default()
@@ -3251,7 +3315,7 @@ mod tests {
         };
 
         use super::super::wireguard::{
-            InterfaceStatus, NeighborStatus, WireGuardInterfaceState, is_node_ok,
+            InterfaceStatus, NeighborStatus, PeerStatus, WireGuardInterfaceState, is_node_ok,
             parse_wireguard_interfaces, parse_wireguard_neighbors,
         };
         use super::super::*;
@@ -3577,6 +3641,7 @@ wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.
                 NeighborStatus {
                     neighbor: Some("172.31.1.10:51820".to_string()),
                     name: Some("stormweaver".to_string()),
+                    status: PeerStatus::Idle,
                     interface: "wg1".to_string(),
                     public_key: "aHnKVQ4yTtTdfwsk+r4Z12FrRlUnXXksjRcV7x41+G0="
                         .parse()
@@ -3590,6 +3655,7 @@ wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.
                 NeighborStatus {
                     neighbor: Some("172.31.1.2:51820".to_string()),
                     name: Some("occultist (wg0)".to_string()),
+                    status: PeerStatus::Idle,
                     interface: "wg0".to_string(),
                     public_key: "+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI="
                         .parse()
@@ -3603,6 +3669,7 @@ wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.
                 NeighborStatus {
                     neighbor: Some("172.31.1.4:51820".to_string()),
                     name: Some("chronomancer (wg0)".to_string()),
+                    status: PeerStatus::Idle,
                     interface: "wg0".to_string(),
                     public_key: "8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA="
                         .parse()
@@ -3617,7 +3684,7 @@ wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.
 
             assert_eq!(
                 expected,
-                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric, 1781234627)
                     .expect("can parse wireguard output")
             );
         }
@@ -3634,6 +3701,7 @@ wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	203.0.113.50:40123	198.5
             let expected = vec![NeighborStatus {
                 neighbor: Some("203.0.113.50:40123".to_string()),
                 name: Some("occultist (wg0)".to_string()),
+                status: PeerStatus::Active,
                 interface: "wg0".to_string(),
                 public_key: "+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI="
                     .parse()
@@ -3647,7 +3715,7 @@ wg0	+PA/xNCZ3G+Wy1DeqF251Us5mcZhBTGc9CT3AaJ89HI=	(none)	203.0.113.50:40123	198.5
 
             assert_eq!(
                 expected,
-                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric, 1781234627)
                     .expect("can parse wireguard output")
             );
         }
@@ -3664,6 +3732,7 @@ wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	(none)	198.51.100.4/32	0
             let expected = vec![NeighborStatus {
                 neighbor: None,
                 name: Some("chronomancer (wg0)".to_string()),
+                status: PeerStatus::Idle,
                 interface: "wg0".to_string(),
                 public_key: "8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA="
                     .parse()
@@ -3677,7 +3746,7 @@ wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	(none)	198.51.100.4/32	0
 
             assert_eq!(
                 expected,
-                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric, 1781234627)
                     .expect("can parse wireguard output")
             );
         }
@@ -3694,6 +3763,7 @@ wg0	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=	(none)	(none)	(none)	0	0	0	off"
             let expected = vec![NeighborStatus {
                 neighbor: None,
                 name: None,
+                status: PeerStatus::Idle,
                 interface: "wg0".to_string(),
                 public_key: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
                     .parse()
@@ -3707,7 +3777,7 @@ wg0	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=	(none)	(none)	(none)	0	0	0	off"
 
             assert_eq!(
                 expected,
-                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric)
+                parse_wireguard_neighbors(wg_dump, elementalist(fabric), fabric, 1781234627)
                     .expect("can parse wireguard output")
             );
         }
@@ -3952,5 +4022,55 @@ wg0	8ybxvVfiWqpBG160nMgH14acR3z31ZeceW7ita0zonA=	(none)	172.31.1.4:51820	198.51.
             let fabric_id = FabricId::from_str("test").expect("valid fabric id");
             assert_eq!(FabricStatus::NotOk, status[&fabric_id].status);
         }
+
+        #[test]
+        fn peer_status_without_keepalive() {
+            // without persistent keepalive, only a handshake within the last 180 seconds counts
+            let now = 1781234567;
+
+            assert_eq!(
+                PeerStatus::from_handshake(Some(now as u64 - 179), None, now),
+                PeerStatus::Active
+            );
+            assert_eq!(
+                PeerStatus::from_handshake(Some(now as u64 - 180), None, now),
+                PeerStatus::Idle
+            );
+            assert_eq!(
+                PeerStatus::from_handshake(None, None, now),
+                PeerStatus::Idle
+            );
+        }
+
+        #[test]
+        fn peer_status_with_keepalive() {
+            // with a keepalive interval of 25 seconds, a reachable peer exchanges a handshake
+            // within 180 + 25 + 90 seconds
+            let now = 1781234567;
+
+            assert_eq!(
+                PeerStatus::from_handshake(Some(now as u64 - 294), Some(25), now),
+                PeerStatus::Active
+            );
+            assert_eq!(
+                PeerStatus::from_handshake(Some(now as u64 - 295), Some(25), now),
+                PeerStatus::Down
+            );
+            assert_eq!(
+                PeerStatus::from_handshake(None, Some(25), now),
+                PeerStatus::Down
+            );
+        }
+
+        #[test]
+        fn peer_status_handshake_in_future() {
+            // a handshake in the future, e.g. due to clock adjustments, counts as recent
+            let now = 1781234567;
+
+            assert_eq!(
+                PeerStatus::from_handshake(Some(now as u64 + 10), None, now),
+                PeerStatus::Active
+            );
+        }
     }
 }
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH pve-network v2 09/11] api: fabric status: add schema for wireguard properties
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (7 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 08/11] sdn status: fabrics: report status of wireguard neighbors Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH pve-manager v2 10/11] ui: fabric content: add wireguard protocol Stefan Hanreich
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

The WireGuard fabric returns lots of addtional options in status
reporting, add the properties to the return schema. Additionally,
improve the description of the existing properties, so the format is
more clear.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 src/PVE/API2/Network/SDN/Nodes/Fabric.pm | 80 +++++++++++++++++++++++-
 1 file changed, 77 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/Network/SDN/Nodes/Fabric.pm b/src/PVE/API2/Network/SDN/Nodes/Fabric.pm
index 0202b81..f1d9594 100644
--- a/src/PVE/API2/Network/SDN/Nodes/Fabric.pm
+++ b/src/PVE/API2/Network/SDN/Nodes/Fabric.pm
@@ -115,17 +115,80 @@ __PACKAGE__->register_method({
             type => "object",
             properties => {
                 neighbor => {
-                    description => "The IP or hostname of the neighbor.",
+                    description =>
+                        "The IP or hostname of the neighbor. For WireGuard, the endpoint"
+                        . " currently used, including the port. Omitted for WireGuard peers"
+                        . " without a known endpoint.",
+                    format_description => '(<IP>|<Host>)[:<port>]',
                     type => 'string',
+                    optional => 1,
                 },
                 status => {
-                    description => "The status of the neighbor, as returned by FRR.",
+                    description =>
+                        "The status of the neighbor. As returned by FRR for OSPF, Openfabric and"
+                        . " BGP. For WireGuard, derived from the latest handshake: 'active' if"
+                        . " the peer has a recent session, 'down' if it is unreachable despite"
+                        . " persistent keepalive, 'idle' otherwise.",
                     type => 'string',
                 },
                 uptime => {
                     description =>
-                        "The uptime of this neighbor, as returned by FRR (e.g. 8h24m12s).",
+                        "The uptime of this neighbor, as returned by FRR, e.g. 8h24m12s (OSPF, Openfabric, BGP only)",
                     type => 'string',
+                    optional => 1,
+                },
+                name => {
+                    description =>
+                        "The name for this neighbor in the WireGuard fabric. Omitted for peers"
+                        . " that are not part of the fabric configuration. (WireGuard only)",
+                    format_description => '<node>[ (<interface>)]',
+                    type => 'string',
+                    optional => 1,
+                },
+                interface => {
+                    description =>
+                        "The name of the interface that uses this neighbor as peer (WireGuard only)",
+                    type => 'string',
+                    optional => 1,
+                },
+                'public-key' => {
+                    description => "The public key used for this neighbor (WireGuard only)",
+                    format_description => 'Base64-encoded Curve 25519 public key.',
+                    type => 'string',
+                    optional => 1,
+                },
+                'allowed-ips' => {
+                    description =>
+                        "The allowed IPs for this neighbor, omitted if there are none (WireGuard only)",
+                    type => 'string',
+                    format_description => 'Comma-separated list of CIDRs.',
+                    optional => 1,
+                },
+                'latest-handshake' => {
+                    description =>
+                        "UNIX Timestamp of the last successful handshake, omitted if no handshake"
+                        . " happened yet (WireGuard only)",
+                    type => 'number',
+                    optional => 1,
+                },
+                'bytes-rx' => {
+                    description =>
+                        "The amount of bytes received from this neighbor (WireGuard only)",
+                    type => 'number',
+                    optional => 1,
+                },
+                'bytes-tx' => {
+                    description =>
+                        "The amount of bytes transmitted to this neighbor (WireGuard only)",
+                    type => 'number',
+                    optional => 1,
+                },
+                'persistent-keepalive' => {
+                    description =>
+                        "The currently used persistent keepalive interval for this neighbor,"
+                        . " omitted if disabled (WireGuard only)",
+                    type => 'number',
+                    optional => 1,
                 },
             },
         },
@@ -173,6 +236,17 @@ __PACKAGE__->register_method({
                     description => "The current state of the interface.",
                     type => 'string',
                 },
+                'public-key' => {
+                    description => "The public key of the interface (WireGuard only).",
+                    format_description => 'Base64-encoded Curve 25519 public key.',
+                    type => 'string',
+                    optional => 1,
+                },
+                'listen-port' => {
+                    description => "The listen port of the interface (WireGuard only).",
+                    type => 'number',
+                    optional => 1,
+                },
             },
         },
     },
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH pve-manager v2 10/11] ui: fabric content: add wireguard protocol
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (8 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH pve-network v2 09/11] api: fabric status: add schema for wireguard properties Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-17 18:34 ` [PATCH pve-docs v2 11/11] sdn: add documentation for wireguard status reporting Stefan Hanreich
  2026-11-18 15:20 ` [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Arthur Bied-Charreton
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

WireGuard returns a lot of additional options compared to the other,
FRR-based, fabric types. Hide the routes panel completely and change
the neighbor / interface panel to add the additional columns if the
fabric has the type wireguard.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 www/manager6/sdn/FabricsContentView.js | 179 +++++++++++++++++++------
 www/manager6/sdn/NetworkBrowser.js     |  40 +++---
 2 files changed, 160 insertions(+), 59 deletions(-)

diff --git a/www/manager6/sdn/FabricsContentView.js b/www/manager6/sdn/FabricsContentView.js
index 47e8bce7..bbe4b77e 100644
--- a/www/manager6/sdn/FabricsContentView.js
+++ b/www/manager6/sdn/FabricsContentView.js
@@ -28,50 +28,149 @@ Ext.define('PVE.sdn.FabricNeighborsContentView', {
     extend: 'Ext.grid.GridPanel',
     alias: 'widget.pveSDNFabricNeighborsContentView',
 
-    columns: [
-        {
-            header: gettext('Neighbor'),
-            sortable: true,
-            dataIndex: 'neighbor',
-            flex: 1,
-        },
-        {
-            header: gettext('Status'),
-            sortable: true,
-            dataIndex: 'status',
-            flex: 0.5,
-        },
-        {
-            header: gettext('Uptime'),
-            sortable: true,
-            dataIndex: 'uptime',
-            flex: 0.5,
-        },
-    ],
+    protocol: null,
+
+    initComponent: function () {
+        let me = this;
+
+        me.columns = [
+            {
+                header: gettext('Neighbor'),
+                sortable: true,
+                dataIndex: 'neighbor',
+                flex: 1,
+            },
+        ];
+
+        if (me.protocol === 'wireguard') {
+            me.columns.unshift({
+                header: gettext('Name'),
+                sortable: true,
+                dataIndex: 'name',
+                flex: 1,
+            });
+
+            me.columns = me.columns.concat([
+                {
+                    header: gettext('Interface'),
+                    sortable: true,
+                    dataIndex: 'interface',
+                    flex: 0.5,
+                },
+                {
+                    header: gettext('Status'),
+                    sortable: true,
+                    dataIndex: 'status',
+                    flex: 0.5,
+                },
+                {
+                    header: gettext('Public Key'),
+                    sortable: true,
+                    dataIndex: 'public-key',
+                    flex: 1,
+                },
+                {
+                    header: gettext('Allowed IPs'),
+                    sortable: true,
+                    dataIndex: 'allowed-ips',
+                    flex: 1,
+                },
+                {
+                    header: gettext('Latest Handshake'),
+                    sortable: true,
+                    dataIndex: 'latest-handshake',
+                    flex: 1,
+                    renderer: function (value) {
+                        if (!value) {
+                            return '-';
+                        }
+
+                        return Proxmox.Utils.render_timestamp(value);
+                    },
+                },
+                {
+                    header: gettext('Bytes transmitted'),
+                    sortable: true,
+                    dataIndex: 'bytes-tx',
+                    flex: 0.5,
+                    renderer: Proxmox.Utils.render_size,
+                },
+                {
+                    header: gettext('Bytes received'),
+                    sortable: true,
+                    dataIndex: 'bytes-rx',
+                    flex: 0.5,
+                    renderer: Proxmox.Utils.render_size,
+                },
+            ]);
+        } else {
+            me.columns = me.columns.concat([
+                {
+                    header: gettext('Status'),
+                    sortable: true,
+                    dataIndex: 'status',
+                    flex: 0.5,
+                },
+                {
+                    header: gettext('Uptime'),
+                    sortable: true,
+                    dataIndex: 'uptime',
+                    flex: 0.5,
+                },
+            ]);
+        }
+
+        me.callParent();
+    },
 });
 
 Ext.define('PVE.sdn.FabricInterfacesContentView', {
     extend: 'Ext.grid.GridPanel',
     alias: 'widget.pveSDNFabricInterfacesContentView',
 
-    columns: [
-        {
-            header: gettext('Name'),
-            sortable: true,
-            dataIndex: 'name',
-            flex: 1,
-        },
-        {
-            header: gettext('Type'),
-            sortable: true,
-            dataIndex: 'type',
-            flex: 1,
-        },
-        {
-            header: gettext('State'),
-            sortable: true,
-            dataIndex: 'state',
-            flex: 1,
-        },
-    ],
+    protocol: null,
+
+    initComponent: function () {
+        let me = this;
+
+        me.columns = [
+            {
+                header: gettext('Name'),
+                sortable: true,
+                dataIndex: 'name',
+                flex: 1,
+            },
+            {
+                header: gettext('Type'),
+                sortable: true,
+                dataIndex: 'type',
+                flex: 1,
+            },
+            {
+                header: gettext('State'),
+                sortable: true,
+                dataIndex: 'state',
+                flex: 1,
+            },
+        ];
+
+        if (me.protocol === 'wireguard') {
+            me.columns = me.columns.concat([
+                {
+                    header: gettext('Public Key'),
+                    sortable: true,
+                    dataIndex: 'public-key',
+                    flex: 1,
+                },
+                {
+                    header: gettext('Listen Port'),
+                    sortable: true,
+                    dataIndex: 'listen-port',
+                    flex: 1,
+                },
+            ]);
+        }
+
+        me.callParent();
+    },
 });
diff --git a/www/manager6/sdn/NetworkBrowser.js b/www/manager6/sdn/NetworkBrowser.js
index f94b27d3..edb00fb3 100644
--- a/www/manager6/sdn/NetworkBrowser.js
+++ b/www/manager6/sdn/NetworkBrowser.js
@@ -26,27 +26,29 @@ Ext.define('PVE.network.Browser', {
         if (networkType === 'fabric') {
             me.onlineHelp = 'pvesdn_config_fabrics';
 
-            me.items.push({
-                nodename: node,
-                fabricId: name,
-                protocol: me.pveSelNode.data.protocol,
-                xtype: 'pveSDNFabricRoutesContentView',
-                title: gettext('Routes'),
-                iconCls: 'fa fa-exchange',
-                itemId: 'routes',
-                width: '100%',
-                store: {
-                    proxy: {
-                        type: 'proxmox',
-                        url: `/api2/json/nodes/${node}/sdn/fabrics/${name}/routes`,
-                        reader: {
-                            type: 'json',
-                            rootProperty: 'data',
+            if (me.pveSelNode.data.protocol !== 'wireguard') {
+                me.items.push({
+                    nodename: node,
+                    fabricId: name,
+                    protocol: me.pveSelNode.data.protocol,
+                    xtype: 'pveSDNFabricRoutesContentView',
+                    title: gettext('Routes'),
+                    iconCls: 'fa fa-exchange',
+                    itemId: 'routes',
+                    width: '100%',
+                    store: {
+                        proxy: {
+                            type: 'proxmox',
+                            url: `/api2/json/nodes/${node}/sdn/fabrics/${name}/routes`,
+                            reader: {
+                                type: 'json',
+                                rootProperty: 'data',
+                            },
                         },
+                        autoLoad: true,
                     },
-                    autoLoad: true,
-                },
-            });
+                });
+            }
 
             me.items.push({
                 nodename: node,
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH pve-docs v2 11/11] sdn: add documentation for wireguard status reporting
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (9 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH pve-manager v2 10/11] ui: fabric content: add wireguard protocol Stefan Hanreich
@ 2026-11-17 18:34 ` Stefan Hanreich
  2026-11-18 15:20 ` [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Arthur Bied-Charreton
  11 siblings, 0 replies; 13+ messages in thread
From: Stefan Hanreich @ 2026-11-17 18:34 UTC (permalink / raw)
  To: pve-devel

Explains the content of the returned fields and how to interpret them,
particularly how the status of an interface is determined.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 pve-gui.adoc |  1 +
 pvesdn.adoc  | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+)

diff --git a/pve-gui.adoc b/pve-gui.adoc
index 3a99eaf..dce5e26 100644
--- a/pve-gui.adoc
+++ b/pve-gui.adoc
@@ -149,6 +149,7 @@ Line Height :: Specify the absolute height of a line.
 
 
 
+[[gui_resource_tree]]
 Resource Tree
 ~~~~~~~~~~~~~
 
diff --git a/pvesdn.adoc b/pvesdn.adoc
index b701636..f97fc7c 100644
--- a/pvesdn.adoc
+++ b/pvesdn.adoc
@@ -958,6 +958,105 @@ Skip Route Generation:: The fabric will autogenerate routes in the kernel
 routing table for all allowed IPs of a peer. By setting this option, no routes
 will be inserted into the kernel routing table.
 
+
+[[pvesdn_fabric_status]]
+Status Reporting
+~~~~~~~~~~~~~~~~
+
+Fabrics report their current status for informational and debugging purposes. It
+can be accessed by clicking on the respective entry for the fabric in the
+xref:gui_resource_tree[Resource Tree]. Depending on the protocol, different
+metrics are reported.
+
+
+[[pvesdn_fabric_status_wireguard]]
+WireGuard
+^^^^^^^^^
+
+A WireGuard fabric is shown as 'ok' in the resource tree if all of its
+interfaces on the node are in the 'up' state, use their configured public key
+and listen port, and have exactly the peers of the applied fabric
+configuration. Otherwise, for example if an interface is missing or applying
+the configuration failed on the node, it is shown as 'not ok'. Pending changes
+are not taken into account. Neither are handshakes, since peers do not exchange
+handshakes if no traffic is sent and persistent keepalive is disabled.
+
+.Interfaces
+
+Provides information about the WireGuard interfaces of a specific node. The
+following properties are available:
+
+Name:: The name of the network interface on the host.
+
+Type:: Interfaces are always of type 'wireguard'.
+
+State:: The SDN stack performs several checks to determine the state of the
+interface. Possible states are:
++
+* 'up': The interface exists and has the `UP` flag set.
+* 'down': The interface exists, but does not have the `UP` flag set.
+* 'missing': The interface does not exist on the node, for example because
+  applying the configuration failed on the node.
+* 'unknown': The interface exists, but its WireGuard state could not be read.
+* 'error': The interface exists, but is not a WireGuard interface.
++
+If WireGuard does not report the public key or listen port of an interface,
+the values from the fabric configuration are shown.
+
+Public Key:: The public key that can be used for communicating with the
+WireGuard instance on this interface.
+
+Listen Port:: The port that can be used to reach this WireGuard instance.
+
+.Neighbors
+
+Provides information about the peers of all WireGuard interfaces on a specific
+node. The following properties are available:
+
+Name:: The name of the node in the fabric configuration. Additionally contains
+the name of the referenced interface in parentheses, if the node is an internal
+node. Peers are matched to the fabric configuration by their public key. Peers
+that are not part of the fabric configuration have no name.
+
+Neighbor:: The endpoint that is currently used to reach this peer (e.g.
+192.0.2.1:51820). WireGuard updates the endpoint to the address it last
+received traffic from, so this can differ from the configured endpoint, for
+example if the peer is behind NAT. Empty if the endpoint is not known yet.
+
+Interface:: The interface that has this neighbor configured.
+
+Status:: The status of the neighbor, derived from its latest handshake.
+WireGuard does not use session keys that are older than 180 seconds, so a
+handshake within that time means that the neighbor has a working session.
+Possible states are:
++
+* 'active': The latest handshake is less than 180 seconds old. With persistent
+  keepalive, the keepalive interval and another 90 seconds, for which WireGuard
+  retries a handshake, are added as margin.
+* 'down': Persistent keepalive is enabled, but there was no handshake in that
+  time. Since keepalive packets are sent regularly, a reachable neighbor would
+  have exchanged a new handshake.
+* 'idle': Persistent keepalive is disabled and there was no recent handshake.
+  Without traffic, WireGuard does not exchange handshakes, so an unused but
+  working neighbor cannot be distinguished from an unreachable one. Enable
+  persistent keepalive on the fabric for a reliable status.
+
+Public Key:: The public key of the neighbor.
+
+Allowed IPs:: A comma separated list of CIDRs. Those indicate the destination
+IPs that are allowed when sending traffic to this neighbor.
+
+Latest Handshake:: When the latest handshake with this neighbor occurred.
+Handshakes are exchanged every 120 seconds, *if* traffic is sent via this
+WireGuard interface. If no traffic is sent, then also no handshake is exchanged.
+Empty if no handshake happened yet.
+
+Bytes transmitted:: The amount of traffic that has been sent to this neighbor.
+
+Bytes received:: The amount of traffic that has been received from this
+neighbor.
+
+
 [[pvesdn_config_route_filtering]]
 Prefix Lists and Route Maps
 ---------------------------
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics
  2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
                   ` (10 preceding siblings ...)
  2026-11-17 18:34 ` [PATCH pve-docs v2 11/11] sdn: add documentation for wireguard status reporting Stefan Hanreich
@ 2026-11-18 15:20 ` Arthur Bied-Charreton
  11 siblings, 0 replies; 13+ messages in thread
From: Arthur Bied-Charreton @ 2026-11-18 15:20 UTC (permalink / raw)
  To: Stefan Hanreich; +Cc: pve-devel

On Tue, Nov 17, 2026 at 07:34:47PM +0100, Stefan Hanreich wrote:
> ## Introduction
> 
> This patch series adds status reporting for WireGuard fabrics to pvestatd and
> exposes additional information about WireGuard interfaces and neighbors (=
> peers) via the pre-existing interface/neighbors endpoints for fabrics.
> 
> 
[snip]
> ## Open questions
>
> The return schema of the neighbor status endpoint had some non-optional strings.
> This series makes 'uptime' optional, since it is not returned for the WireGuard
> fabric, as well as 'neighbor', since the endpoint of a WireGuard peer is not
> known before the first handshake if it has none configured. Initially, I
> returned hard-coded strings for those fields for the WireGuard fabric, but
> decided to omit them instead, since they could be potentially misleading and
> don't really add anything. Still a bit unsure about this, since it is
> technically a breaking API change. It should be easy to just add this in a new
> iteration again - even if only 'n/a' or something similar is returned for the
> non-optional fields.
fwiw i think omitting them is fine, returning a placeholder would be
more confusing IMO. 

[snip]

setup: 3-node mesh WG fabric

tested the following cases:
- neighbors are 'idle' without traffic with persistent-keepalive disabled
- traffic between node & neighbor changes neighbor status to 'active'
- neighbor drops back to 'idle' after some inactivity
- all neighbors become 'active' after setting persistent keepalive (25s)
- cutting a neighbor off drops it to 'down', re-allowing traffic sets it
  back to 'active'
- setting the wg0 link to down on a node reports it as 'down' and the 
  whole fabric as 'not ok' on that node
- deleting wg0 altogether shows it as 'missing', the whole fabric as
  'not ok' on that node
- adding another dummy link called wg0 shows it as 'error', the whole
  fabric as 'not ok' on that node
- removing a neighbor (wg set wg0 peer ... remove) reports the fabric as
  'not ok' on that node
- an extra peer that is not in the config appears in the neighbors list,
  fabric is shown as 'not ok' on that node
- removing the wg executable shows the fabric as 'not ok' on that node

just one question: would it make sense to log `wg show` failures
somehow? currently the fabric is just shown as 'not ok' but one does 
not see why anywhere. might be a bit spammy though since this is 
called regularly by pvestatd, but maybe it would be possible to only 
log on state changes? 

besides that i haven't run into any unexpected behavior while testing, 
therefore consider this series:

Tested-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com> 




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-11-18 15:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 18:34 [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox v2 01/11] network-api: add missing getters Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox v2 02/11] network-api: add support for parsing interface flags Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox v2 03/11] wireguard: derive additional traits for public key Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox-ve-rs v2 04/11] ve-config: sdn: wireguard: add getters for interface listen port and " Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox-ve-rs v2 05/11] ve-config: sdn: wireguard: add helper for resolving the peers of an interface Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 06/11] sdn status: fabrics: add status reporting for wireguard Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 07/11] sdn status: fabrics: check interfaces and peers for wireguard status Stefan Hanreich
2026-11-17 18:34 ` [PATCH proxmox-perl-rs v2 08/11] sdn status: fabrics: report status of wireguard neighbors Stefan Hanreich
2026-11-17 18:34 ` [PATCH pve-network v2 09/11] api: fabric status: add schema for wireguard properties Stefan Hanreich
2026-11-17 18:34 ` [PATCH pve-manager v2 10/11] ui: fabric content: add wireguard protocol Stefan Hanreich
2026-11-17 18:34 ` [PATCH pve-docs v2 11/11] sdn: add documentation for wireguard status reporting Stefan Hanreich
2026-11-18 15:20 ` [PATCH docs/manager/network/proxmox{,-ve-rs,-perl-rs} v2 00/11] Status reporting for WireGuard fabrics Arthur Bied-Charreton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal