]> git.puffer.fish Git - mirror/pve-network.git/commitdiff
sdn: dhcp: get next free ip for a specific IP version
authorStefan Lendl <s.lendl@proxmox.com>
Fri, 5 Apr 2024 13:17:54 +0000 (15:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 8 Apr 2024 15:57:18 +0000 (17:57 +0200)
Specify the IP version (4|6) for which an IP shall be requested from the IPAM.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
src/PVE/Network/SDN/Subnets.pm
src/PVE/Network/SDN/Vnets.pm

index 3b08dcd50c70e6d37b050e2a939cd0b173700a5d..e2c8c9c7ab72489b44eea345c6fc235402a1f92c 100644 (file)
@@ -206,7 +206,7 @@ sub del_subnet {
 }
 
 sub add_next_free_ip {
-    my ($zone, $subnetid, $subnet, $hostname, $mac, $vmid, $skipdns, $dhcprange) = @_;
+    my ($zone, $subnetid, $subnet, $hostname, $mac, $vmid, $skipdns, $dhcprange, $ipversion) = @_;
 
     my $cidr = undef;
     my $ip = undef;
index 0dfdfd74819a2816ba150dd580fc6a84396887c9..03609b7275a068bce1f7d644e2904593bd1001f0 100644 (file)
@@ -95,7 +95,7 @@ sub get_subnet_from_vnet_ip {
 }
 
 sub add_next_free_cidr {
-    my ($vnetid, $hostname, $mac, $vmid, $skipdns, $dhcprange) = @_;
+    my ($vnetid, $hostname, $mac, $vmid, $skipdns, $dhcprange, $ipversion) = @_;
 
     my $vnet = PVE::Network::SDN::Vnets::get_vnet($vnetid);
     return if !$vnet;
@@ -109,7 +109,7 @@ sub add_next_free_cidr {
 
     my $ips = {};
 
-    my @ipversions = qw/ 4 6 /;
+    my @ipversions = defined($ipversion) ? ($ipversion) : qw/ 4 6 /;
     for my $ipversion (@ipversions) {
        my $ip = undef;
        my $subnetcount = 0;
@@ -125,7 +125,7 @@ sub add_next_free_cidr {
            };
            die $@ if $@;
 
-            if ($ip) {
+           if ($ip) {
                $ips->{$ipversion} = $ip;
                last;
            }