public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Alexandre Derumier <aderumier@odiso.com>
Subject: Re: [pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere
Date: Fri, 18 Dec 2020 18:02:14 +0100	[thread overview]
Message-ID: <f7173c81-2e53-e729-401d-2c3f195a5967@proxmox.com> (raw)
In-Reply-To: <20201203091942.2401958-4-aderumier@odiso.com>

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};
> 





  reply	other threads:[~2020-12-18 17:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7173c81-2e53-e729-401d-2c3f195a5967@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=aderumier@odiso.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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