From: Stefan Hanreich <s.hanreich@proxmox.com>
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 [thread overview]
Message-ID: <20261124175718.512428-3-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20261124175718.512428-1-s.hanreich@proxmox.com>
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 <s.hanreich@proxmox.com>
---
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::<NetworkDevice>()
.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::<NetworkDevice>()
@@ -533,6 +553,10 @@ mod tests {
.parse::<NetworkDevice>()
.expect_err("invalid network configuration");
+ "hwaddr=AA:AA:AA:E2:3E:24,bridge=public"
+ .parse::<NetworkDevice>()
+ .expect_err("invalid network configuration");
+
"name=eth0,bridge=public,firewall=0,hwaddr=AA:AA:AG:E2:3E:24,ip=dhcp,type=veth"
.parse::<NetworkDevice>()
.expect_err("invalid network configuration");
--
2.47.3
next prev parent reply other threads:[~2026-11-24 17:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 17:57 [PATCH firewall/proxmox{-ve-rs,-firewall} 0/7] firewall: handle guest network devices without a MAC address Stefan Hanreich
2026-11-24 17:57 ` [PATCH proxmox-ve-rs 1/7] ve-config: guest: require the name of container network devices Stefan Hanreich
2026-11-24 17:57 ` Stefan Hanreich [this message]
2026-11-24 17:57 ` [PATCH proxmox-ve-rs 3/7] ve-config: guest: accept network devices without a MAC address Stefan Hanreich
2026-11-24 17:57 ` [PATCH proxmox-firewall 4/7] firewall: guest: handle " Stefan Hanreich
2026-11-25 7:28 ` Arthur Bied-Charreton
2026-11-24 17:57 ` [PATCH proxmox-firewall 5/7] tests: add network devices without " Stefan Hanreich
2026-11-24 17:57 ` [PATCH pve-firewall 6/7] firewall: drop the traffic of guest " Stefan Hanreich
2026-11-24 17:57 ` [PATCH pve-firewall 7/7] firewall: do not generate MAC addresses for guest network devices Stefan Hanreich
2026-11-25 7:14 ` [PATCH firewall/proxmox{-ve-rs,-firewall} 0/7] firewall: handle guest network devices without a MAC address Arthur Bied-Charreton
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=20261124175718.512428-3-s.hanreich@proxmox.com \
--to=s.hanreich@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox