From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id D1CCA1FF066 for ; Tue, 24 Nov 2026 18:57:32 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 763CD21663; Tue, 24 Nov 2026 18:57:30 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs 2/7] ve-config: guest: default the type of container network devices to veth Date: Tue, 24 Nov 2026 18:57:12 +0100 Message-ID: <20261124175718.512428-3-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261124175718.512428-1-s.hanreich@proxmox.com> References: <20261124175718.512428-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: 1795543046680 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.180 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: 6ABIGMBF4NTLORQCYFIO2ESSCVNTLK2P X-Message-ID-Hash: 6ABIGMBF4NTLORQCYFIO2ESSCVNTLK2P 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: The type of a container network device is optional for pve-container, which only supports veth and sets it when parsing the device. A config with a network device without a type thus works for the container, but proxmox-firewall failed to parse it. Signed-off-by: Stefan Hanreich --- proxmox-ve-config/src/guest/vm.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/proxmox-ve-config/src/guest/vm.rs b/proxmox-ve-config/src/guest/vm.rs index 08927218..e809c2e0 100644 --- a/proxmox-ve-config/src/guest/vm.rs +++ b/proxmox-ve-config/src/guest/vm.rs @@ -193,6 +193,10 @@ impl FromStr for LxcIpv6Addr { } } +fn default_lxc_network_device_model() -> NetworkDeviceModel { + NetworkDeviceModel::Veth +} + /// Representation of the network device property string of a LXC guest. /// /// It currently only cotains properties that are required for the firewall to function, there are @@ -200,7 +204,7 @@ impl FromStr for LxcIpv6Addr { #[derive(Debug, Deserialize)] #[cfg_attr(test, derive(Eq, PartialEq))] pub struct LxcNetworkDevice { - #[serde(rename = "type")] + #[serde(rename = "type", default = "default_lxc_network_device_model")] ty: NetworkDeviceModel, #[serde(rename = "hwaddr")] mac_address: MacAddress, @@ -244,7 +248,7 @@ impl ApiType for LxcNetworkDevice { ), ( "type", - false, + true, &StringSchema::new("type of the network device").schema(), ), ]), @@ -521,6 +525,22 @@ mod tests { .parse::() .expect_err("invalid network configuration"); + network_device = "name=eth0,bridge=public,firewall=1,hwaddr=AA:AA:AA:E2:3E:25" + .parse() + .expect("valid network configuration"); + + assert_eq!( + network_device, + NetworkDevice::Lxc(LxcNetworkDevice { + ty: NetworkDeviceModel::Veth, + _name: "eth0".to_string(), + mac_address: MacAddress::new([0xAA, 0xAA, 0xAA, 0xE2, 0x3E, 0x25]), + firewall: Some(true), + ip: None, + ip6: None, + }) + ); + // neither a QEMU device without a model nor an LXC device without a name "bridge=public,firewall=0" .parse::() @@ -533,6 +553,10 @@ mod tests { .parse::() .expect_err("invalid network configuration"); + "hwaddr=AA:AA:AA:E2:3E:24,bridge=public" + .parse::() + .expect_err("invalid network configuration"); + "name=eth0,bridge=public,firewall=0,hwaddr=AA:AA:AG:E2:3E:24,ip=dhcp,type=veth" .parse::() .expect_err("invalid network configuration"); -- 2.47.3