dhcp: fix allocating IP for every defined dhcp-range

Due to the wrong check an IP was allocated for every DHCP range,
instead of only allocating an IP in the first free DHCP range.

Suggested-By: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
Stefan Hanreich 2023-11-21 13:40:12 +01:00 committed by Wolfgang Bumiller
parent 5ab15238af
commit 04e1c8ed73

View file

@ -238,7 +238,7 @@ sub add_next_free_ip {
foreach my $range (@$dhcp_ranges) { foreach my $range (@$dhcp_ranges) {
$ip = $plugin->add_range_next_freeip($plugin_config, $subnet, $range, $data); $ip = $plugin->add_range_next_freeip($plugin_config, $subnet, $range, $data);
next if !$ip; last if $ip;
} }
} else { } else {
$ip = $plugin->add_next_freeip($plugin_config, $subnetid, $subnet, $hostname, $mac, $vmid); $ip = $plugin->add_next_freeip($plugin_config, $subnetid, $subnet, $hostname, $mac, $vmid);