mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-04 08:33:06 +00:00
net: ip from CIDR: sort result
this should not be a real problem yet, but the perl keys hash pseudo random order was an issue way to often to bet on that.. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
1e55a6cd22
commit
ef737f0b3c
@ -600,13 +600,14 @@ sub get_local_ip_from_cidr {
|
||||
my ($cidr) = @_;
|
||||
|
||||
my $IPs = {};
|
||||
my $i = 1;
|
||||
run_command(['/sbin/ip', 'address', 'show', 'to', $cidr, 'up'], outfunc => sub {
|
||||
if ($_[0] =~ m!^\s*inet(?:6)?\s+($PVE::Tools::IPRE)(?:/\d+|\s+peer\s+)!) {
|
||||
$IPs->{$1} = 1;
|
||||
$IPs->{$1} = $i++ if !exists($IPs->{$1});
|
||||
}
|
||||
});
|
||||
|
||||
return [ keys %{$IPs} ];
|
||||
return [ sort { $IPs->{$a} <=> $IPs->{$b} } keys %{$IPs} ];
|
||||
}
|
||||
|
||||
sub addr_to_ip {
|
||||
|
Loading…
Reference in New Issue
Block a user