all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer v2 10/15] post-hook: add network interface name and pinning status
Date: Thu, 30 Oct 2025 12:06:12 +0100	[thread overview]
Message-ID: <20251030110627.812398-11-c.heiss@proxmox.com> (raw)
In-Reply-To: <20251030110627.812398-1-c.heiss@proxmox.com>

Adds a new `name` and `is-pinned` attribute to each reported network interface in
the post-hook data.

Also increments the minor schema version by one, as it is a
backwards-compatible change.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v1 -> v2:
  * no changes

 proxmox-post-hook/src/main.rs | 39 +++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/proxmox-post-hook/src/main.rs b/proxmox-post-hook/src/main.rs
index 0a9e661..ce64533 100644
--- a/proxmox-post-hook/src/main.rs
+++ b/proxmox-post-hook/src/main.rs
@@ -76,6 +76,8 @@ struct DiskInfo {
 #[derive(Serialize)]
 #[serde(rename_all = "kebab-case")]
 struct NetworkInterfaceInfo {
+    /// Name of the interface
+    name: String,
     /// MAC address of the interface
     mac: String,
     /// (Designated) IP address of the interface
@@ -85,6 +87,10 @@ struct NetworkInterfaceInfo {
     /// installation.
     #[serde(skip_serializing_if = "bool_is_false")]
     is_management: bool,
+    /// Set to true if the network interface name was pinned based on the MAC
+    /// address during the installation.
+    #[serde(skip_serializing_if = "bool_is_false")]
+    is_pinned: bool,
     /// Properties about the device as given by udev.
     udev_properties: UdevProperties,
 }
@@ -151,7 +157,7 @@ struct PostHookInfoSchema {
 }
 
 impl PostHookInfoSchema {
-    const SCHEMA_VERSION: &str = "1.1";
+    const SCHEMA_VERSION: &str = "1.2";
 }
 
 impl Default for PostHookInfoSchema {
@@ -386,23 +392,24 @@ impl PostHookInfo {
                     })?
                     .clone();
 
-                if config.mngmt_nic == nic.name {
+                let is_pinned = config.network_interface_pin_map.contains_key(&nic.mac);
+                let ifname = config
+                    .network_interface_pin_map
+                    .get(&nic.mac)
+                    .unwrap_or(&nic.name);
+
+                let is_management = config.mngmt_nic == *ifname;
+
+                anyhow::Ok(NetworkInterfaceInfo {
+                    name: ifname.clone(),
+                    mac: nic.mac.clone(),
                     // Use the actual IP address from the low-level install config, as the runtime info
                     // contains the original IP address from DHCP.
-                    anyhow::Ok(NetworkInterfaceInfo {
-                        mac: nic.mac.clone(),
-                        address: Some(config.cidr.clone()),
-                        is_management: true,
-                        udev_properties,
-                    })
-                } else {
-                    anyhow::Ok(NetworkInterfaceInfo {
-                        mac: nic.mac.clone(),
-                        address: None,
-                        is_management: false,
-                        udev_properties,
-                    })
-                }
+                    address: is_management.then_some(config.cidr.clone()),
+                    is_management,
+                    is_pinned,
+                    udev_properties,
+                })
             })
             .collect())
     }
-- 
2.51.0



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


  parent reply	other threads:[~2025-10-30 11:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-30 11:06 [pve-devel] [PATCH installer v2 00/15] support network interface name pinning Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 01/15] test: parse-kernel-cmdline: fix module import statement Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 02/15] install: add support for network interface name pinning Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 03/15] run env: network: add kernel driver name to network interface info Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 04/15] common: utils: fix clippy warnings Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 05/15] common: setup: simplify network address list serialization Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 06/15] common: implement support for `network_interface_pin_map` config Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 07/15] auto: add support for pinning network interface names Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 08/15] assistant: verify network settings in `validate-answer` subcommand Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 09/15] post-hook: avoid redundant Option<bool> for (de-)serialization Christoph Heiss
2025-10-30 11:06 ` Christoph Heiss [this message]
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 11/15] tui: views: move network options view to own module Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 12/15] tui: views: form: allow attaching user-defined data to children Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 13/15] tui: add support for pinning network interface names Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 14/15] ui: gtk3: allow passing of dialog parent window Christoph Heiss
2025-10-30 11:06 ` [pve-devel] [PATCH installer v2 15/15] gui: add support for pinning network interface names Christoph Heiss

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20251030110627.812398-11-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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