Signed-off-by: Alexandre Derumier <aderum...@odiso.com>
---
 PVE/API2/Network.pm | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
index 84bd3c3a..82ae9037 100644
--- a/PVE/API2/Network.pm
+++ b/PVE/API2/Network.pm
@@ -153,7 +153,7 @@ my $confdesc = {
     },
     cidr => {
        description => 'IPv4 CIDR.',
-       type => 'string', format => 'CIDRv4',
+       type => 'string', format => 'CIDRv4-list',
        optional => 1,
     },
     mtu => {
@@ -182,7 +182,7 @@ my $confdesc = {
     },
     cidr6 => {
        description => 'IPv6 CIDR.',
-       type => 'string', format => 'CIDRv6',
+       type => 'string', format => 'CIDRv6-list',
        optional => 1,
     },
 };
@@ -351,11 +351,14 @@ my $map_cidr_to_address_netmask = sub {
            if $param->{address};
        raise_param_exc({ netmask => "netmask conflicts with cidr" })
            if $param->{netmask};
+       my @cidrs = split /,/, $param->{cidr};
+       foreach my $cidr (@cidrs) {
+           push @{$param->{address}}, $cidr;
+       }
 
-       my ($address, $netmask) = $param->{cidr} =~ m!^(.*)/(\d+)$!;
-       $param->{address} = $address;
-       $param->{netmask} = $netmask;
        delete $param->{cidr};
+    } elsif ($param->{address} && $param->{netmask}) {
+       $param->{address} = ["$param->{address}/$param->{netmask}"];
     }
 
     if ($param->{cidr6}) {
@@ -364,10 +367,14 @@ my $map_cidr_to_address_netmask = sub {
        raise_param_exc({ netmask6 => "netmask6 conflicts with cidr6" })
            if $param->{netmask6};
 
-       my ($address, $netmask) = $param->{cidr6} =~ m!^(.*)/(\d+)$!;
-       $param->{address6} = $address;
-       $param->{netmask6} = $netmask;
+       my @cidrs = split /,/, $param->{cidr6};
+       foreach my $cidr (@cidrs) {
+           push @{$param->{address6}}, $cidr;
+       }
        delete $param->{cidr6};
+
+    } elsif ($param->{address6} && $param->{netmask6}) {
+        $param->{address} = ["$param->{address6}/$param->{netmask6}"];
     }
 };
 
-- 
2.20.1

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

Reply via email to