public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH common] network: get_local_ip_from_cidr: return unique IPs
@ 2021-02-22 13:24 Fabian Ebner
  2021-02-25 12:49 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2021-02-22 13:24 UTC (permalink / raw)
  To: pve-devel

to avoid erroring out when "multiple" addresses are configured on live
migration, when in fact it's the same IP multiple times.

Seems like the same problem for a caller in pve-cluster was fixed by checking
the uniqueness afterwards, see commit 266041169beb36c8892ca54265e2d91335307ffb
in pve-cluster. But there doesn't seem to be any caller relying on the current
behavior, and no additional information other than the addresses are returned,
so fix it here.

Reported here:
https://forum.proxmox.com/threads/live-migration-of-vms-via-full-mesh-network-could-not-get-ip-multiple-addresses-configured-on-local-node-for-network.84585/

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/PVE/Network.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index 12536c7..3b1afdd 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -599,14 +599,14 @@ sub is_ip_in_cidr {
 sub get_local_ip_from_cidr {
     my ($cidr) = @_;
 
-    my $IPs = [];
+    my $IPs = {};
     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+)!) {
-	    push @$IPs, $1;
+	    $IPs->{$1} = 1;
 	}
     });
 
-    return $IPs;
+    return [ keys %{$IPs} ];
 }
 
 sub addr_to_ip {
-- 
2.20.1





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

* [pve-devel] applied: [PATCH common] network: get_local_ip_from_cidr: return unique IPs
  2021-02-22 13:24 [pve-devel] [PATCH common] network: get_local_ip_from_cidr: return unique IPs Fabian Ebner
@ 2021-02-25 12:49 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-02-25 12:49 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Ebner

On 22.02.21 14:24, Fabian Ebner wrote:
> to avoid erroring out when "multiple" addresses are configured on live
> migration, when in fact it's the same IP multiple times.
> 
> Seems like the same problem for a caller in pve-cluster was fixed by checking
> the uniqueness afterwards, see commit 266041169beb36c8892ca54265e2d91335307ffb
> in pve-cluster. But there doesn't seem to be any caller relying on the current
> behavior, and no additional information other than the addresses are returned,
> so fix it here.
> 
> Reported here:
> https://forum.proxmox.com/threads/live-migration-of-vms-via-full-mesh-network-could-not-get-ip-multiple-addresses-configured-on-local-node-for-network.84585/
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  src/PVE/Network.pm | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
>

applied, thanks!

Follow'd up with ensuring the returned array is always sorted in a stable manner,
perl hash key pseudo random ordering is just a pain..




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

end of thread, other threads:[~2021-02-25 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 13:24 [pve-devel] [PATCH common] network: get_local_ip_from_cidr: return unique IPs Fabian Ebner
2021-02-25 12:49 ` [pve-devel] applied: " Thomas Lamprecht

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