From: Kim Soo <popododo0720@naver.com>
To: pve-devel@lists.proxmox.com
Cc: Kim Soo <popododo0720@naver.com>
Subject: [RFC PATCH network] fix #7815: sdn: vnets: add optional MTU override for VLAN zones
Date: Mon, 23 Nov 2026 05:24:49 +0000 [thread overview]
Message-ID: <20261123052449.187370-1-popododo0720@naver.com> (raw)
Currently all VNets of a zone get the MTU of the zone. Using a smaller
MTU for some VLANs, for example 1500 next to 9000 on the same bridge,
requires a second zone on the same bridge or setting the MTU on every
guest NIC.
Add an optional 'mtu' property to VNets. In VLAN zones it overrides the
zone MTU for the interfaces generated for the VNet: the VNet bridge and,
on non VLAN-aware bridges, the veth pair and the vmbrXvY bridge. Guest
NICs on the VNet already inherit the MTU of the VNet bridge.
A VNet MTU must not be bigger than the zone MTU (1500 if unset), since
the zone MTU describes what the uplink can carry. Check this when a VNet
is created or updated, and when the MTU of a zone is changed.
Signed-off-by: Kim Soo <popododo0720@naver.com>
---
RFC because I am not sure about a few points:
* Only the VLAN zone uses the VNet MTU for now. The 'mtu' property is
generic, so a VNet in another zone accepts it but ignores it. Should
the other zones reject it for now, or should I extend this to the
other zones?
* The check when the zone MTU changes is in the zone update API
handler, next to the ipam check, because the zone plugin's
on_update_hook() does not get the VNet config, and reading it from
the plugin would add a module cycle. Is that the right place?
* The checks read the zone MTU from the zone config instead of using
PVE::Network::SDN::Zones::get_mtu(), because the VLAN and QinQ plugins
do not implement get_mtu() and calling it dies with "please implement
inside plugin". Its only caller is the dnsmasq DHCP backend. I can
send a separate patch that adds get_mtu() to these plugins.
Tested on PVE 9.2.2 (libpve-network-perl 1.6.5 with this patch applied),
VLAN zone on a non VLAN-aware bridge, zone MTU unset:
* VNet mtu 1400: the VNet bridge, the veth pair and vmbr1v100 get MTU
1400, a guest NIC on the VNet gets host_mtu=1400.
* VNet mtu 1600 is rejected (bigger than the zone MTU 1500).
* With a VNet at 1400, setting the zone MTU to 1300 is rejected; 1400
and 9000 are accepted.
* make test passes.
UI and docs will follow once the approach is fine.
src/PVE/API2/Network/SDN/Zones.pm | 11 ++++++++
src/PVE/Network/SDN/VnetPlugin.pm | 8 ++++++
src/PVE/Network/SDN/Zones/VlanPlugin.pm | 8 +++++-
.../bridge_vnet_mtu/expected_sdn_interfaces | 27 +++++++++++++++++++
.../zones/vlan/bridge_vnet_mtu/interfaces | 5 ++++
.../zones/vlan/bridge_vnet_mtu/sdn_config | 11 ++++++++
6 files changed, 69 insertions(+), 1 deletion(-)
create mode 100644 src/test/zones/vlan/bridge_vnet_mtu/expected_sdn_interfaces
create mode 100644 src/test/zones/vlan/bridge_vnet_mtu/interfaces
create mode 100644 src/test/zones/vlan/bridge_vnet_mtu/sdn_config
diff --git a/src/PVE/API2/Network/SDN/Zones.pm b/src/PVE/API2/Network/SDN/Zones.pm
index 74b10f0..26a9e1b 100644
--- a/src/PVE/API2/Network/SDN/Zones.pm
+++ b/src/PVE/API2/Network/SDN/Zones.pm
@@ -492,6 +492,17 @@ __PACKAGE__->register_method({
my $dnszone = $opts->{dnszone};
raise_param_exc({ dnszone => "missing dns server" }) if $dnszone && !$dnsserver;
+ my $zone_mtu = $scfg->{mtu} // 1500;
+ my $vnet_cfg = PVE::Network::SDN::Vnets::config();
+ for my $vnetid (sort keys $vnet_cfg->{ids}->%*) {
+ my $vnet = $vnet_cfg->{ids}->{$vnetid};
+ next if ($vnet->{zone} // '') ne $id;
+ raise_param_exc({
+ mtu =>
+ "MTU $zone_mtu is smaller than the MTU $vnet->{mtu} of vnet $vnetid",
+ })
+ if defined($vnet->{mtu}) && $vnet->{mtu} > $zone_mtu;
+ }
$plugin->on_update_hook($id, $zone_cfg, $controller_cfg);
PVE::Network::SDN::Zones::write_config($zone_cfg);
diff --git a/src/PVE/Network/SDN/VnetPlugin.pm b/src/PVE/Network/SDN/VnetPlugin.pm
index 7a38457..a8e4bd1 100644
--- a/src/PVE/Network/SDN/VnetPlugin.pm
+++ b/src/PVE/Network/SDN/VnetPlugin.pm
@@ -83,6 +83,13 @@ sub properties {
"If true, sets the isolated property for all interfaces on the bridge of this VNet.",
optional => 1,
},
+ mtu => {
+ type => 'integer',
+ description => "MTU of the VNet, overrides the MTU of the zone.",
+ optional => 1,
+ minimum => 68,
+ maximum => 65535,
+ },
};
}
@@ -93,6 +100,7 @@ sub options {
alias => { optional => 1 },
vlanaware => { optional => 1 },
'isolate-ports' => { optional => 1 },
+ mtu => { optional => 1 },
};
}
diff --git a/src/PVE/Network/SDN/Zones/VlanPlugin.pm b/src/PVE/Network/SDN/Zones/VlanPlugin.pm
index de19755..f73e82c 100644
--- a/src/PVE/Network/SDN/Zones/VlanPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/VlanPlugin.pm
@@ -76,7 +76,7 @@ sub generate_sdn_config {
my $tag = $vnet->{tag};
my $alias = $vnet->{alias};
- my $mtu = $plugin_config->{mtu};
+ my $mtu = $vnet->{mtu} // $plugin_config->{mtu};
my $vnet_uplink = "ln_" . $vnetid;
my $vnet_uplinkpeer = "pr_" . $vnetid;
@@ -197,6 +197,12 @@ sub vnet_update_hook {
raise_param_exc({ tag => "missing vlan tag" }) if !defined($vnet->{tag});
raise_param_exc({ tag => "vlan tag max value is 4096" }) if $vnet->{tag} > 4096;
+ if (defined(my $mtu = $vnet->{mtu})) {
+ my $zone_mtu = $zone_cfg->{ids}->{ $vnet->{zone} }->{mtu} // 1500;
+ raise_param_exc({ mtu => "MTU $mtu is bigger than the zone MTU $zone_mtu" })
+ if $mtu > $zone_mtu;
+ }
+
# verify that tag is not already defined in another vnet on same zone
foreach my $id (keys %{ $vnet_cfg->{ids} }) {
next if $id eq $vnetid;
diff --git a/src/test/zones/vlan/bridge_vnet_mtu/expected_sdn_interfaces b/src/test/zones/vlan/bridge_vnet_mtu/expected_sdn_interfaces
new file mode 100644
index 0000000..ab88c69
--- /dev/null
+++ b/src/test/zones/vlan/bridge_vnet_mtu/expected_sdn_interfaces
@@ -0,0 +1,27 @@
+#version:1
+
+auto ln_myvnet
+iface ln_myvnet
+ link-type veth
+ veth-peer-name pr_myvnet
+ mtu 1500
+
+auto myvnet
+iface myvnet
+ bridge_ports ln_myvnet
+ bridge_stp off
+ bridge_fd 0
+ mtu 1500
+
+auto pr_myvnet
+iface pr_myvnet
+ link-type veth
+ veth-peer-name ln_myvnet
+ mtu 1500
+
+auto vmbr0v100
+iface vmbr0v100
+ bridge_ports eth0.100 pr_myvnet
+ bridge_stp off
+ bridge_fd 0
+ mtu 1500
diff --git a/src/test/zones/vlan/bridge_vnet_mtu/interfaces b/src/test/zones/vlan/bridge_vnet_mtu/interfaces
new file mode 100644
index 0000000..68b6a88
--- /dev/null
+++ b/src/test/zones/vlan/bridge_vnet_mtu/interfaces
@@ -0,0 +1,5 @@
+auto vmbr0
+iface vmbr0 inet manual
+ bridge-ports eth0
+ bridge-stp off
+ bridge-fd 0
diff --git a/src/test/zones/vlan/bridge_vnet_mtu/sdn_config b/src/test/zones/vlan/bridge_vnet_mtu/sdn_config
new file mode 100644
index 0000000..ee7a7d1
--- /dev/null
+++ b/src/test/zones/vlan/bridge_vnet_mtu/sdn_config
@@ -0,0 +1,11 @@
+{
+ version => 1,
+ vnets => {
+ ids => {
+ myvnet => { tag => 100, type => "vnet", zone => "myzone", mtu => 1500 },
+ },
+ },
+ zones => {
+ ids => { myzone => { bridge => "vmbr0", ipam => "pve", type => "vlan", mtu => "9200" } },
+ },
+}
--
2.55.0
reply other threads:[~2026-11-23 5:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261123052449.187370-1-popododo0720@naver.com \
--to=popododo0720@naver.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