Stefan Hanreich <s.hanre...@proxmox.com> writes:

> @@ -230,10 +227,28 @@ sub next_free_ip {
>       my $plugin_config = $ipam_cfg->{ids}->{$ipamid};
>       my $plugin = 
> PVE::Network::SDN::Ipams::Plugin->lookup($plugin_config->{type});
>       eval {
> -         $cidr = $plugin->add_next_freeip($plugin_config, $subnetid, 
> $subnet, $hostname, $mac, $description);
> -         ($ip, undef) = split(/\//, $cidr);
> +         if ($dhcprange) {
> +             my $data = {
> +                 mac => $mac,
> +                 hostname => $hostname,
> +                 vmid => $vmid,
> +             };
> +
> +             my $dhcp_ranges = 
> PVE::Network::SDN::Subnets::get_dhcp_ranges($subnet);
> +
> +             foreach my $range (@$dhcp_ranges) {
> +                 $ip = $plugin->add_range_next_freeip($plugin_config, 
> $subnet, $range, $data);
> +                 next if !$ip;

If an IP was found, the loop will just start again.
This should be (tested):

last if $ip;


> +             }
> +         } else {
> +             $ip = $plugin->add_next_freeip($plugin_config, $subnetid, 
> $subnet, $hostname, $mac, $vmid);
> +         }
>       };
> +
>       die $@ if $@;
> +
> +     eval { PVE::Network::SDN::Ipams::add_cache_mac_ip($mac, $ip); };
> +     warn $@ if $@;
>      }
>  
>      eval {


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to