all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address
@ 2025-08-06 14:29 Stefan Hanreich
  2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional Stefan Hanreich
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stefan Hanreich @ 2025-08-06 14:29 UTC (permalink / raw)
  To: pbs-devel

As reported in the forum by [1], there are types of interfaces that do not have
a MAC address, so the address field in IpLink need to be optional instead of
required.

[1] https://forum.proxmox.com/threads/proxmox-backup-proxy-seemingly-crashes-after-being-accessed-through-reverse-proxy-after-update-to-4-0.169313/

proxmox:

Stefan Hanreich (1):
  network-api: make address field optional

 proxmox-network-api/src/config/helper.rs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)


proxmox-network-interface-pinning:

Stefan Hanreich (1):
  network-interface-pinning: adapt to optional mac address

 src/main.rs | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)


Summary over all repositories:
  2 files changed, 20 insertions(+), 15 deletions(-)

-- 
Generated by git-murpp 0.8.0

_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional
  2025-08-06 14:29 [pbs-devel] [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address Stefan Hanreich
@ 2025-08-06 14:29 ` Stefan Hanreich
  2025-08-08  7:29   ` Christian Ebner
  2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox-network-interface-pinning 1/1] network-interface-pinning: adapt to optional mac address Stefan Hanreich
  2025-08-08 11:56 ` [pbs-devel] superseded: [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address Stefan Hanreich
  2 siblings, 1 reply; 6+ messages in thread
From: Stefan Hanreich @ 2025-08-06 14:29 UTC (permalink / raw)
  To: pbs-devel

Certain network interfaces do not have a MAC address, for instance
tailscale is layer-3 only, therefore the interfaces do not have a MAC
address. Make the address field optional to prevent the network
interface parsing logic from throwing an error in such cases.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 proxmox-network-api/src/config/helper.rs | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/proxmox-network-api/src/config/helper.rs b/proxmox-network-api/src/config/helper.rs
index 4f17b9ee..ca80d47f 100644
--- a/proxmox-network-api/src/config/helper.rs
+++ b/proxmox-network-api/src/config/helper.rs
@@ -137,7 +137,7 @@ pub struct IpLink {
     altnames: Vec<String>,
     ifindex: i64,
     link_type: String,
-    address: MacAddress,
+    address: Option<MacAddress>,
     linkinfo: Option<LinkInfo>,
     operstate: String,
 }
@@ -157,12 +157,10 @@ impl IpLink {
         &self.ifname
     }
 
-    pub fn permanent_mac(&self) -> MacAddress {
+    pub fn permanent_mac(&self) -> Option<MacAddress> {
         if let Some(link_info) = &self.linkinfo {
             if let Some(info_slave_data) = &link_info.info_slave_data {
-                if let Some(perm_hw_addr) = info_slave_data.perm_hw_addr {
-                    return perm_hw_addr;
-                }
+                return info_slave_data.perm_hw_addr;
             }
         }
 
-- 
2.47.2


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* [pbs-devel] [PATCH proxmox-network-interface-pinning 1/1] network-interface-pinning: adapt to optional mac address
  2025-08-06 14:29 [pbs-devel] [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address Stefan Hanreich
  2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional Stefan Hanreich
@ 2025-08-06 14:29 ` Stefan Hanreich
  2025-08-08 11:56 ` [pbs-devel] superseded: [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address Stefan Hanreich
  2 siblings, 0 replies; 6+ messages in thread
From: Stefan Hanreich @ 2025-08-06 14:29 UTC (permalink / raw)
  To: pbs-devel

MAC addresses can be optional, so the return value of permanent_mac()
has changed to Option<MacAddress>. Adapt all call sites to gracefully
handle the case where a link has no permanent MAC address.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 src/main.rs | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 4e1fa4f..bff0660 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -63,7 +63,12 @@ impl InterfaceMapping {
 
         for ip_link in sorted_links {
             if let Some(new_name) = self.mapping.get(ip_link.name()) {
-                let link_file = LinkFile::new_ether(ip_link.permanent_mac(), new_name.to_string());
+                let link_file = LinkFile::new_ether(
+                    ip_link
+                        .permanent_mac()
+                        .ok_or_else(|| anyhow!("trying to pin interface without a MAC address!"))?,
+                    new_name.to_string(),
+                );
 
                 std::fs::write(
                     format!("{}/{}", SYSTEMD_LINK_FILE_PATH, link_file.file_name()),
@@ -407,10 +412,11 @@ impl PinningTool {
             .get(interface_name)
             .ok_or_else(|| anyhow!("cannot find interface with name {interface_name}"))?;
 
-        if self
-            .pinned_interfaces
-            .contains_key(&ip_link.permanent_mac())
-        {
+        let Some(mac_address) = ip_link.permanent_mac() else {
+            bail!("Interface does not have a MAC address, so it cannot be pinned!");
+        };
+
+        if self.pinned_interfaces.contains_key(&mac_address) {
             bail!("pin already exists for interface {interface_name}");
         }
 
@@ -483,11 +489,12 @@ impl PinningTool {
             .ip_links
             .values()
             .filter(|ip_link| {
-                ip_link.is_physical()
-                    && self
-                        .pinned_interfaces
-                        .get(&ip_link.permanent_mac())
-                        .is_none()
+                if let Some(mac_address) = ip_link.permanent_mac() {
+                    return ip_link.is_physical()
+                        && self.pinned_interfaces.get(&mac_address).is_none();
+                }
+
+                false
             })
             .cloned()
             .map(IpLink::from)
-- 
2.47.2


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* Re: [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional
  2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional Stefan Hanreich
@ 2025-08-08  7:29   ` Christian Ebner
  2025-08-08  8:01     ` Stefan Hanreich
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Ebner @ 2025-08-08  7:29 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Stefan Hanreich

Tested this with success on a device with wwan interface, reporting a 
link type `link/none` in `ip link show` output!

Unfortunately this does not fix the issue on a host were I have an IPv6 
tunnel set up. The link there reports as `link/sit 0.0.0.0 peer <peer-ip>`.

So it would be probably best to bundle mac address and link type ether 
in a struct or named tuple, and leave the option for other link types 
which might have different, non-mac hardware addresses.


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* Re: [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional
  2025-08-08  7:29   ` Christian Ebner
@ 2025-08-08  8:01     ` Stefan Hanreich
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hanreich @ 2025-08-08  8:01 UTC (permalink / raw)
  To: Christian Ebner, Proxmox Backup Server development discussion

On 8/8/25 9:29 AM, Christian Ebner wrote:
> Tested this with success on a device with wwan interface, reporting a
> link type `link/none` in `ip link show` output!
> 
> Unfortunately this does not fix the issue on a host were I have an IPv6
> tunnel set up. The link there reports as `link/sit 0.0.0.0 peer <peer-ip>`.
> 
> So it would be probably best to bundle mac address and link type ether
> in a struct or named tuple, and leave the option for other link types
> which might have different, non-mac hardware addresses.

Thanks for testing this, I'll look into implementing your suggestion!


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

* [pbs-devel] superseded: [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address
  2025-08-06 14:29 [pbs-devel] [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address Stefan Hanreich
  2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional Stefan Hanreich
  2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox-network-interface-pinning 1/1] network-interface-pinning: adapt to optional mac address Stefan Hanreich
@ 2025-08-08 11:56 ` Stefan Hanreich
  2 siblings, 0 replies; 6+ messages in thread
From: Stefan Hanreich @ 2025-08-08 11:56 UTC (permalink / raw)
  To: pbs-devel

https://lore.proxmox.com/pbs-devel/20250808102333.121994-1-s.hanreich@proxmox.com/

On 8/6/25 4:31 PM, Stefan Hanreich wrote:
> As reported in the forum by [1], there are types of interfaces that do not have
> a MAC address, so the address field in IpLink need to be optional instead of
> required.
> 
> [1] https://forum.proxmox.com/threads/proxmox-backup-proxy-seemingly-crashes-after-being-accessed-through-reverse-proxy-after-update-to-4-0.169313/
> 
> proxmox:
> 
> Stefan Hanreich (1):
>   network-api: make address field optional
> 
>  proxmox-network-api/src/config/helper.rs | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> 
> proxmox-network-interface-pinning:
> 
> Stefan Hanreich (1):
>   network-interface-pinning: adapt to optional mac address
> 
>  src/main.rs | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 deletions(-)
> 
> 
> Summary over all repositories:
>   2 files changed, 20 insertions(+), 15 deletions(-)
> 



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


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

end of thread, other threads:[~2025-08-08 11:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-06 14:29 [pbs-devel] [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address Stefan Hanreich
2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox 1/1] network-api: make address field optional Stefan Hanreich
2025-08-08  7:29   ` Christian Ebner
2025-08-08  8:01     ` Stefan Hanreich
2025-08-06 14:29 ` [pbs-devel] [PATCH proxmox-network-interface-pinning 1/1] network-interface-pinning: adapt to optional mac address Stefan Hanreich
2025-08-08 11:56 ` [pbs-devel] superseded: [PATCH proxmox{, -network-interface-pinning} 0/2] fix reading ip link output for interfaces without MAC address Stefan Hanreich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal