[pve-devel] [PATCH v3 pve-network 03/12] sdn: dhcp: only consider subnets that have dhcp-range configured

Stefan Lendl s.lendl at proxmox.com
Fri Apr 5 15:17:56 CEST 2024


From: Stefan Hanreich <s.hanreich at proxmox.com>

If DHCP is enabled on a zone with subnets, but no subnet has a
dhcp-range configured, then starting a VM will fail because no IP can
be allocated. This patch fixes this by only considering subnets that
have a dhcp-range configured and only failing if there is at least one
subnet with a dhcp-range configured.

Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
Reviewed-by: Stefan Lendl <s.lendl at proxmox.com>
Tested-by: Stefan Lendl <s.lendl at proxmox.com>
Signed-off-by: Stefan Lendl <s.lendl at proxmox.com>
---
 src/PVE/Network/SDN/Vnets.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/PVE/Network/SDN/Vnets.pm b/src/PVE/Network/SDN/Vnets.pm
index 4542b70..cbf0a07 100644
--- a/src/PVE/Network/SDN/Vnets.pm
+++ b/src/PVE/Network/SDN/Vnets.pm
@@ -118,6 +118,7 @@ sub add_next_free_cidr {
 	    my $network = $subnet->{network};
 
 	    next if Net::IP::ip_get_version($network) != $ipversion || $ips->{$ipversion};
+	    next if !$subnet->{'dhcp-range'};
 	    $subnetcount++;
 
 	    eval {
-- 
2.44.0





More information about the pve-devel mailing list