public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH V2 pve-network 0/7] various cleanups
@ 2020-12-03  9:19 Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 1/7] evpn: frr: use datacenter default profile (lower timeouts) Alexandre Derumier
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

changelog v2:

- add more bugfix

Alexandre Derumier (7):
  evpn: frr: use datacenter default profile (lower timeouts)
  get_local_vnets: display vnet alias in comments
  use canonical ipv6 address (RFC 5952) everywhere
  ipam : pve: don't register hostname/description
  zones: evpn: fix exitnodes for snat
  zones: plugin : readd encode/decode value
  subnets: api : add missing param in on_update_hook for update

 PVE/API2/Network/SDN/Subnets.pm           |  2 +-
 PVE/Network/SDN.pm                        | 25 +++-----------------
 PVE/Network/SDN/Controllers/EvpnPlugin.pm |  5 ++--
 PVE/Network/SDN/Dns/PowerdnsPlugin.pm     |  3 +--
 PVE/Network/SDN/Ipams/PVEPlugin.pm        | 15 ++++--------
 PVE/Network/SDN/Subnets.pm                |  9 +++++++-
 PVE/Network/SDN/Zones/EvpnPlugin.pm       |  9 ++++----
 PVE/Network/SDN/Zones/Plugin.pm           | 28 +++++++++++++++++++++++
 8 files changed, 53 insertions(+), 43 deletions(-)

-- 
2.20.1




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

* [pve-devel] [PATCH V2 pve-network 1/7] evpn: frr: use datacenter default profile (lower timeouts)
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
@ 2020-12-03  9:19 ` Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 2/7] get_local_vnets: display vnet alias in comments Alexandre Derumier
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN/Controllers/EvpnPlugin.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index e59c142..b997cca 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -288,7 +288,7 @@ sub write_controller_config {
     push @{$final_config}, "log syslog informational";
     push @{$final_config}, "ip forwarding";
     push @{$final_config}, "ipv6 forwarding";
-    push @{$final_config}, "frr defaults traditional";
+    push @{$final_config}, "frr defaults datacenter";
     push @{$final_config}, "service integrated-vtysh-config";
     push @{$final_config}, "hostname $nodename";
     push @{$final_config}, "!";
-- 
2.20.1




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

* [pve-devel] [PATCH V2 pve-network 2/7] get_local_vnets: display vnet alias in comments
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 1/7] evpn: frr: use datacenter default profile (lower timeouts) Alexandre Derumier
@ 2020-12-03  9:19 ` Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere Alexandre Derumier
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index c0c5672..ed891de 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -188,6 +188,8 @@ sub get_local_vnets {
 
 	my $vnet = PVE::Network::SDN::Vnets::sdn_vnets_config($vnets_cfg, $vnetid);
 	my $zoneid = $vnet->{zone};
+	my $comments = $vnet->{alias};
+
 	my $privs = [ 'SDN.Audit', 'SDN.Allocate' ];
 
 	next if !$zoneid;
@@ -196,7 +198,7 @@ sub get_local_vnets {
 	my $zone_config = PVE::Network::SDN::Zones::sdn_zones_config($zones_cfg, $zoneid);
 
 	next if defined($zone_config->{nodes}) && !$zone_config->{nodes}->{$nodename};
-	$vnets->{$vnetid} = { type => 'vnet', active => '1' };
+	$vnets->{$vnetid} = { type => 'vnet', active => '1', comments => $comments };
     }
 
     return $vnets;
-- 
2.20.1




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

* [pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 1/7] evpn: frr: use datacenter default profile (lower timeouts) Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 2/7] get_local_vnets: display vnet alias in comments Alexandre Derumier
@ 2020-12-03  9:19 ` Alexandre Derumier
  2020-12-18 17:02   ` Thomas Lamprecht
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 4/7] ipam : pve: don't register hostname/description Alexandre Derumier
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

we want only 1 format for ipam database

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN/Dns/PowerdnsPlugin.pm | 3 +--
 PVE/Network/SDN/Ipams/PVEPlugin.pm    | 5 +++--
 PVE/Network/SDN/Subnets.pm            | 9 ++++++++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/PVE/Network/SDN/Dns/PowerdnsPlugin.pm b/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
index b00432e..3fbd595 100644
--- a/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
+++ b/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
@@ -7,8 +7,7 @@ use PVE::Cluster;
 use PVE::Tools;
 use JSON;
 use Net::IP;
-use NetAddr::IP;
-
+use NetAddr::IP qw(:lower);
 use base('PVE::Network::SDN::Dns::Plugin');
 
 sub type {
diff --git a/PVE/Network/SDN/Ipams/PVEPlugin.pm b/PVE/Network/SDN/Ipams/PVEPlugin.pm
index e4c9ef7..a2e7d86 100644
--- a/PVE/Network/SDN/Ipams/PVEPlugin.pm
+++ b/PVE/Network/SDN/Ipams/PVEPlugin.pm
@@ -6,7 +6,8 @@ use PVE::INotify;
 use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_register_file cfs_lock_file);
 use PVE::Tools;
 use JSON;
-use NetAddr::IP;
+use NetAddr::IP qw(:lower);
+
 use Net::IP;
 use Digest::SHA;
 
@@ -134,7 +135,7 @@ sub add_next_freeip {
 	    while(1) {
 		$iplist++;
 		last if $iplist eq $broadcast;
-		my $ip = $iplist->addr();
+		my $ip = $iplist->canon();
 		next if defined($dbsubnet->{ips}->{$ip});
 		$freeip = $ip;
 		last;
diff --git a/PVE/Network/SDN/Subnets.pm b/PVE/Network/SDN/Subnets.pm
index 74a538c..81970a1 100644
--- a/PVE/Network/SDN/Subnets.pm
+++ b/PVE/Network/SDN/Subnets.pm
@@ -5,6 +5,7 @@ use warnings;
 
 use Net::Subnet qw(subnet_matcher);
 use Net::IP;
+use NetAddr::IP qw(:lower);
 
 use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file);
 use PVE::Network::SDN::Dns;
@@ -213,6 +214,9 @@ sub add_ip {
 
     return if !$subnet || !$ip; 
 
+    my $ipaddr = new NetAddr::IP($ip);
+    $ip = $ipaddr->canon();
+
     my $ipamid = $zone->{ipam};
     my $dns = $zone->{dns};
     my $dnszone = $zone->{dnszone};
@@ -255,7 +259,10 @@ sub add_ip {
 sub del_ip {
     my ($zone, $subnetid, $subnet, $ip, $hostname) = @_;
 
-    return if !$subnet;
+    return if !$subnet || !$ip;
+
+    my $ipaddr = new NetAddr::IP($ip);
+    $ip = $ipaddr->canon();
 
     my $ipamid = $zone->{ipam};
     my $dns = $zone->{dns};
-- 
2.20.1




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

* [pve-devel] [PATCH V2 pve-network 4/7] ipam : pve: don't register hostname/description
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
                   ` (2 preceding siblings ...)
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere Alexandre Derumier
@ 2020-12-03  9:19 ` Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 5/7] zones: evpn: fix exitnodes for snat Alexandre Derumier
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

we already have this informations in vm/ct config,
and we are limited in space in pmxcfs

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN/Ipams/PVEPlugin.pm | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/PVE/Network/SDN/Ipams/PVEPlugin.pm b/PVE/Network/SDN/Ipams/PVEPlugin.pm
index a2e7d86..4925274 100644
--- a/PVE/Network/SDN/Ipams/PVEPlugin.pm
+++ b/PVE/Network/SDN/Ipams/PVEPlugin.pm
@@ -98,10 +98,7 @@ sub add_ip {
 
 	die "IP '$ip' already exist\n" if defined($dbsubnet->{ips}->{$ip});
 
-	$dbsubnet->{ips}->{$ip} = {
-	    hostname => $hostname,
-	    description => $description,
-	};
+	$dbsubnet->{ips}->{$ip} = {};
 
 	write_db($db);
     });
@@ -144,10 +141,7 @@ sub add_next_freeip {
 
 	die "can't find free ip in subnet '$cidr'\n" if !$freeip;
 
-	$dbsubnet->{ips}->{$freeip} = {
-	    hostname => $hostname,
-	    description => $description,
-	};
+	$dbsubnet->{ips}->{$freeip} = {};
 
 	write_db($db);
     });
-- 
2.20.1




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

* [pve-devel] [PATCH V2 pve-network 5/7] zones: evpn: fix exitnodes for snat
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
                   ` (3 preceding siblings ...)
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 4/7] ipam : pve: don't register hostname/description Alexandre Derumier
@ 2020-12-03  9:19 ` Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 6/7] zones: plugin : readd encode/decode value Alexandre Derumier
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN/Controllers/EvpnPlugin.pm | 3 ++-
 PVE/Network/SDN/Zones/EvpnPlugin.pm       | 9 ++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index b997cca..6927921 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -144,7 +144,8 @@ sub generate_controller_zone_config {
 	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"l2vpn evpn"}}, "route-target export $autortas:$vrfvxlan");
     }
 
-    my $is_gateway = grep { $_ eq $local_node } PVE::Tools::split_list($exitnodes);
+    my $is_gateway = $exitnodes->{$local_node};
+
     if ($is_gateway) {
 
 	@controller_config = ();
diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm b/PVE/Network/SDN/Zones/EvpnPlugin.pm
index d833641..e6ee839 100644
--- a/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -100,12 +100,11 @@ sub generate_sdn_config {
 	    push @iface_config, "address $gateway/$mask" if !defined($address->{$gateway});
 	    $address->{$gateway} = 1;
 	}
+
 	if ($subnet->{snat}) {
-	    my $gatewaynodes = $controller->{'gateway-nodes'};
-	    my $is_evpn_gateway = "";
-	    foreach my $evpn_gatewaynode (PVE::Tools::split_list($gatewaynodes)) {
-		$is_evpn_gateway = 1 if $evpn_gatewaynode eq $local_node;
-	    }
+
+	    my $is_evpn_gateway = $plugin_config->{'exitnodes'}->{$local_node};
+
             #find outgoing interface
             my ($outip, $outiface) = PVE::Network::SDN::Zones::Plugin::get_local_route_ip('8.8.8.8');
             if ($outip && $outiface && $is_evpn_gateway) {
-- 
2.20.1




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

* [pve-devel] [PATCH V2 pve-network 6/7] zones: plugin : readd encode/decode value
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
                   ` (4 preceding siblings ...)
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 5/7] zones: evpn: fix exitnodes for snat Alexandre Derumier
@ 2020-12-03  9:19 ` Alexandre Derumier
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 7/7] subnets: api : add missing param in on_update_hook for update Alexandre Derumier
  2020-12-18 16:59 ` [pve-devel] applied-series: Re: [PATCH V2 pve-network 0/7] various cleanups Thomas Lamprecht
  7 siblings, 0 replies; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN.pm              | 21 ---------------------
 PVE/Network/SDN/Zones/Plugin.pm | 28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index ed891de..256a7c8 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -6,8 +6,6 @@ use warnings;
 use Data::Dumper;
 use JSON;
 
-use PVE::JSONSchema;
-
 use PVE::Network::SDN::Vnets;
 use PVE::Network::SDN::Zones;
 use PVE::Network::SDN::Controllers;
@@ -218,25 +216,6 @@ sub generate_controller_config {
     PVE::Network::SDN::Controllers::reload_controller() if $reload;
 }
 
-
-sub decode_value {
-    my ($type, $key, $value) = @_;
-
-    if ($key eq 'nodes') {
-        my $res = {};
-
-        foreach my $node (PVE::Tools::split_list($value)) {
-            if (PVE::JSONSchema::pve_verify_node_name($node)) {
-                $res->{$node} = 1;
-            }
-        }
-
-        return $res;
-    }
-
-   return $value;
-}
-
 sub encode_value {
     my ($type, $key, $value) = @_;
 
diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plugin.pm
index ebb5c7e..9db2791 100644
--- a/PVE/Network/SDN/Zones/Plugin.pm
+++ b/PVE/Network/SDN/Zones/Plugin.pm
@@ -69,6 +69,34 @@ sub parse_section_header {
     return undef;
 }
 
+sub decode_value {
+    my ($class, $type, $key, $value) = @_;
+
+    if ($key eq 'nodes' || $key eq 'exitnodes') {
+	my $res = {};
+
+	foreach my $node (PVE::Tools::split_list($value)) {
+	    if (PVE::JSONSchema::pve_verify_node_name($node)) {
+		$res->{$node} = 1;
+	    }
+	}
+
+	return $res;
+    }
+
+    return $value;
+}
+
+sub encode_value {
+    my ($class, $type, $key, $value) = @_;
+
+    if ($key eq 'nodes' || $key eq 'exitnodes') {
+	return join(',', keys(%$value));
+    }
+
+    return $value;
+}
+
 sub generate_sdn_config {
     my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $controller_cfg, $subnet_cfg, $interfaces_config, $config) = @_;
 
-- 
2.20.1




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

* [pve-devel] [PATCH V2 pve-network 7/7] subnets: api : add missing param in on_update_hook for update
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
                   ` (5 preceding siblings ...)
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 6/7] zones: plugin : readd encode/decode value Alexandre Derumier
@ 2020-12-03  9:19 ` Alexandre Derumier
  2020-12-18 16:59 ` [pve-devel] applied-series: Re: [PATCH V2 pve-network 0/7] various cleanups Thomas Lamprecht
  7 siblings, 0 replies; 10+ messages in thread
From: Alexandre Derumier @ 2020-12-03  9:19 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/API2/Network/SDN/Subnets.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/API2/Network/SDN/Subnets.pm b/PVE/API2/Network/SDN/Subnets.pm
index a3bc10b..07ef2e1 100644
--- a/PVE/API2/Network/SDN/Subnets.pm
+++ b/PVE/API2/Network/SDN/Subnets.pm
@@ -240,7 +240,7 @@ __PACKAGE__->register_method ({
 	    raise_param_exc({ ipam => "you can't change ipam"}) if $opts->{ipam} && $scfg->{ipam} && $opts->{ipam} ne $scfg->{ipam};
 
 	    my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($cfg, $id);
-	    PVE::Network::SDN::SubnetPlugin->on_update_hook($zone, $id, $subnet);
+	    PVE::Network::SDN::SubnetPlugin->on_update_hook($zone, $id, $subnet, $scfg);
 
 	    PVE::Network::SDN::Subnets::write_config($cfg);
 
-- 
2.20.1




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

* [pve-devel] applied-series: Re: [PATCH V2 pve-network 0/7] various cleanups
  2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
                   ` (6 preceding siblings ...)
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 7/7] subnets: api : add missing param in on_update_hook for update Alexandre Derumier
@ 2020-12-18 16:59 ` Thomas Lamprecht
  7 siblings, 0 replies; 10+ messages in thread
From: Thomas Lamprecht @ 2020-12-18 16:59 UTC (permalink / raw)
  To: Proxmox VE development discussion, Alexandre Derumier

On 03/12/2020 10:19, Alexandre Derumier wrote:
> changelog v2:
> 
> - add more bugfix
> 
> Alexandre Derumier (7):
>   evpn: frr: use datacenter default profile (lower timeouts)
>   get_local_vnets: display vnet alias in comments
>   use canonical ipv6 address (RFC 5952) everywhere
>   ipam : pve: don't register hostname/description
>   zones: evpn: fix exitnodes for snat
>   zones: plugin : readd encode/decode value
>   subnets: api : add missing param in on_update_hook for update
> 
>  PVE/API2/Network/SDN/Subnets.pm           |  2 +-
>  PVE/Network/SDN.pm                        | 25 +++-----------------
>  PVE/Network/SDN/Controllers/EvpnPlugin.pm |  5 ++--
>  PVE/Network/SDN/Dns/PowerdnsPlugin.pm     |  3 +--
>  PVE/Network/SDN/Ipams/PVEPlugin.pm        | 15 ++++--------
>  PVE/Network/SDN/Subnets.pm                |  9 +++++++-
>  PVE/Network/SDN/Zones/EvpnPlugin.pm       |  9 ++++----
>  PVE/Network/SDN/Zones/Plugin.pm           | 28 +++++++++++++++++++++++
>  8 files changed, 53 insertions(+), 43 deletions(-)
> 



applied, thanks!




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

* Re: [pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere
  2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere Alexandre Derumier
@ 2020-12-18 17:02   ` Thomas Lamprecht
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Lamprecht @ 2020-12-18 17:02 UTC (permalink / raw)
  To: Proxmox VE development discussion, Alexandre Derumier

On 03/12/2020 10:19, Alexandre Derumier wrote:
> we want only 1 format for ipam database
> 
> Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
> ---
>  PVE/Network/SDN/Dns/PowerdnsPlugin.pm | 3 +--
>  PVE/Network/SDN/Ipams/PVEPlugin.pm    | 5 +++--
>  PVE/Network/SDN/Subnets.pm            | 9 ++++++++-
>  3 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/PVE/Network/SDN/Dns/PowerdnsPlugin.pm b/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
> index b00432e..3fbd595 100644
> --- a/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
> +++ b/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
> @@ -7,8 +7,7 @@ use PVE::Cluster;
>  use PVE::Tools;
>  use JSON;
>  use Net::IP;
> -use NetAddr::IP;
> -
> +use NetAddr::IP qw(:lower);
>  use base('PVE::Network::SDN::Dns::Plugin');
>  
>  sub type {
> diff --git a/PVE/Network/SDN/Ipams/PVEPlugin.pm b/PVE/Network/SDN/Ipams/PVEPlugin.pm
> index e4c9ef7..a2e7d86 100644
> --- a/PVE/Network/SDN/Ipams/PVEPlugin.pm
> +++ b/PVE/Network/SDN/Ipams/PVEPlugin.pm
> @@ -6,7 +6,8 @@ use PVE::INotify;
>  use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_register_file cfs_lock_file);
>  use PVE::Tools;
>  use JSON;
> -use NetAddr::IP;
> +use NetAddr::IP qw(:lower);
> +
>  use Net::IP;
>  use Digest::SHA;
>  
> @@ -134,7 +135,7 @@ sub add_next_freeip {
>  	    while(1) {
>  		$iplist++;
>  		last if $iplist eq $broadcast;
> -		my $ip = $iplist->addr();
> +		my $ip = $iplist->canon();
>  		next if defined($dbsubnet->{ips}->{$ip});
>  		$freeip = $ip;
>  		last;
> diff --git a/PVE/Network/SDN/Subnets.pm b/PVE/Network/SDN/Subnets.pm
> index 74a538c..81970a1 100644
> --- a/PVE/Network/SDN/Subnets.pm
> +++ b/PVE/Network/SDN/Subnets.pm
> @@ -5,6 +5,7 @@ use warnings;
>  
>  use Net::Subnet qw(subnet_matcher);
>  use Net::IP;
> +use NetAddr::IP qw(:lower);
>  
>  use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file);
>  use PVE::Network::SDN::Dns;
> @@ -213,6 +214,9 @@ sub add_ip {
>  
>      return if !$subnet || !$ip; 
>  
> +    my $ipaddr = new NetAddr::IP($ip);

nit, please do not use old style new, do:

my $ipaddr = NetAddr::IP->new($ip);

> +    $ip = $ipaddr->canon();
> +
>      my $ipamid = $zone->{ipam};
>      my $dns = $zone->{dns};
>      my $dnszone = $zone->{dnszone};
> @@ -255,7 +259,10 @@ sub add_ip {
>  sub del_ip {
>      my ($zone, $subnetid, $subnet, $ip, $hostname) = @_;
>  
> -    return if !$subnet;
> +    return if !$subnet || !$ip;
> +
> +    my $ipaddr = new NetAddr::IP($ip);

same as above, prefer

my $ipaddr = NetAddr::IP->new($ip);

> +    $ip = $ipaddr->canon();
>  
>      my $ipamid = $zone->{ipam};
>      my $dns = $zone->{dns};
> 





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

end of thread, other threads:[~2020-12-18 17:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03  9:19 [pve-devel] [PATCH V2 pve-network 0/7] various cleanups Alexandre Derumier
2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 1/7] evpn: frr: use datacenter default profile (lower timeouts) Alexandre Derumier
2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 2/7] get_local_vnets: display vnet alias in comments Alexandre Derumier
2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere Alexandre Derumier
2020-12-18 17:02   ` Thomas Lamprecht
2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 4/7] ipam : pve: don't register hostname/description Alexandre Derumier
2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 5/7] zones: evpn: fix exitnodes for snat Alexandre Derumier
2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 6/7] zones: plugin : readd encode/decode value Alexandre Derumier
2020-12-03  9:19 ` [pve-devel] [PATCH V2 pve-network 7/7] subnets: api : add missing param in on_update_hook for update Alexandre Derumier
2020-12-18 16:59 ` [pve-devel] applied-series: Re: [PATCH V2 pve-network 0/7] various cleanups 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