From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id AF14B1FF14F for ; Wed, 17 Jun 2026 13:11:57 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D520E315EC; Wed, 17 Jun 2026 13:11:05 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-network-interface-pinning 08/13] network-interface-pinning: switch to proxmox-iproute2 crate Date: Wed, 17 Jun 2026 13:10:05 +0200 Message-ID: <20260617111012.312710-9-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260617111012.312710-1-s.hanreich@proxmox.com> References: <20260617111012.312710-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1781694568826 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.597 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XMNKG44NSJJS4NY7L3XVVYDBVPCEIO3Y X-Message-ID-Hash: XMNKG44NSJJS4NY7L3XVVYDBVPCEIO3Y X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Hanreich --- Cargo.toml | 1 + src/main.rs | 19 ++++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6e6f982..eddcba4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ walkdir = "2.5.0" proxmox-async = "0.5.0" proxmox-log = "1.0.0" +proxmox-iproute2 = "0.1.0" proxmox-network-api = { version = "1.0.3", features = [ "impl" ] } proxmox-network-types = "1" proxmox-product-config = "1" diff --git a/src/main.rs b/src/main.rs index 3129432..004db8c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,10 +51,7 @@ impl InterfaceMapping { /// /// It uses [`ip_links`] to determine the MAC address of the interfaces that should be pinned, /// since we pin based on MAC addresses. - pub fn write( - &self, - ip_links: HashMap, - ) -> Result<(), Error> { + pub fn write(&self, ip_links: HashMap) -> Result<(), Error> { if self.mapping.is_empty() { return Ok(()); } @@ -63,7 +60,7 @@ impl InterfaceMapping { std::fs::create_dir_all(SYSTEMD_LINK_FILE_PATH)?; - let mut sorted_links: Vec<&proxmox_network_api::IpLink> = ip_links.values().collect(); + let mut sorted_links: Vec<&proxmox_iproute2::IpLink> = ip_links.values().collect(); sorted_links.sort_by_key(|a| a.index()); for ip_link in sorted_links { @@ -323,10 +320,10 @@ impl Display for LinkFile { #[derive(Debug, Clone, Eq, PartialEq, Hash)] /// A wrapper struct for [`proxmox_network_api::IpLink`], that implements Ord by comparing /// ifindexes. -struct IpLink(proxmox_network_api::IpLink); +struct IpLink(proxmox_iproute2::IpLink); impl Deref for IpLink { - type Target = proxmox_network_api::IpLink; + type Target = proxmox_iproute2::IpLink; fn deref(&self) -> &Self::Target { &self.0 @@ -345,8 +342,8 @@ impl Ord for IpLink { } } -impl From for IpLink { - fn from(value: proxmox_network_api::IpLink) -> Self { +impl From for IpLink { + fn from(value: proxmox_iproute2::IpLink) -> Self { Self(value) } } @@ -355,7 +352,7 @@ impl From for IpLink { /// /// It holds all information required for generating pub struct PinningTool { - ip_links: HashMap, + ip_links: HashMap, pinned_interfaces: PinnedInterfaces, existing_names: HashSet, } @@ -395,7 +392,7 @@ impl PinningTool { /// Constructs a new instance of the pinning tool. pub fn new() -> Result { - let ip_links = proxmox_network_api::get_network_interfaces()?; + let ip_links = proxmox_iproute2::get_network_interfaces()?; let pinned_interfaces: PinnedInterfaces = Self::read_link_files()?.into_iter().collect(); let mut existing_names = HashSet::new(); -- 2.47.3