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 D998C1FF09B for ; Mon, 23 Nov 2026 06:35:26 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C8411201E9; Mon, 23 Nov 2026 06:35:25 +0100 (CET) X-Originating-IP: 110.15.161.254 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=naver.com; s=s20171208; t=1795411503; bh=v9mgYwlzTusz08C3aYHdLQBHKWb4IUxvsSLqM6l42XM=; h=From:To:Subject:Date:Message-ID:From:Subject:Feedback-ID: X-Works-Security; b=wftfM8YTmTn2uRiQLIPEOuOox82wsSGkSNEB0NYoa9gD9re4sGplzxOxQ7yu9DICh j955R1PXg4ywKwclPET3J7g5f8+ueyC4OADob6Aw4lemKs0dLGQVtgRv5aDtspGL/e 6v25cOPqEZSN/1tJomYt9W0typTi0skjZYEZ+GN20agmG97CiK15SCHu50H0BJ3S7J IgTU9cDMsUJrCtaYWLRK/8RCFAuigzuf/sSD7cnXxsfa/pk/k1bJ4G3lpcxjqPFG/8 ogSKFYnoa+CFjoyeEuDsBW9cOUG0Wmt6HUA3QH1L6VpmAkI3CI6zA19t8oL5eI022F tsxdbCSdZSseQ== X-Session-ID: m39X5p0GRDCL7Nf6im+AEw X-Originating-IP: 110.15.161.254 X-Works-Send-Opt: rPeTbzemjHmZFqITpzevKHmwjAJYKxtdFo2ZFqgmKNwkx0eFjAJYKg== X-Works-Smtp-Source: gZKXKqElFqJZ+HmZKAul+6E= From: Kim Soo To: pve-devel@lists.proxmox.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 Message-ID: <20261123052449.187370-1-popododo0720@naver.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: 3 Message-ID-Hash: 2R66EKYGZKUJZJAP53JX2IN73PMG7SMR X-Message-ID-Hash: 2R66EKYGZKUJZJAP53JX2IN73PMG7SMR X-MailFrom: popododo0720@naver.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 CC: Kim Soo X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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