public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-network] dhcp: fix allocating IP for every defined dhcp-range
@ 2023-11-21 12:40 Stefan Hanreich
  2023-11-21 13:51 ` [pve-devel] applied: " Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hanreich @ 2023-11-21 12:40 UTC (permalink / raw)
  To: pve-devel

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>
---
The fix I talked about off-list was actually unrelated to this. It
prevented allocating IP addresses in multiple IPv4/6 subnets, not
allocating multiple IP addresses for multiple DHCP ranges. So I did
not remove anything in this patch.

 src/PVE/Network/SDN/Subnets.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/Network/SDN/Subnets.pm b/src/PVE/Network/SDN/Subnets.pm
index b05b3d9..8e2a6aa 100644
--- a/src/PVE/Network/SDN/Subnets.pm
+++ b/src/PVE/Network/SDN/Subnets.pm
@@ -238,7 +238,7 @@ sub add_next_free_ip {
 
 		foreach my $range (@$dhcp_ranges) {
 		    $ip = $plugin->add_range_next_freeip($plugin_config, $subnet, $range, $data);
-	            next if !$ip;
+		    last if $ip;
 		}
 	    } else {
 		$ip = $plugin->add_next_freeip($plugin_config, $subnetid, $subnet, $hostname, $mac, $vmid);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-21 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21 12:40 [pve-devel] [PATCH pve-network] dhcp: fix allocating IP for every defined dhcp-range Stefan Hanreich
2023-11-21 13:51 ` [pve-devel] applied: " Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal