From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1C592752A7 for ; Mon, 12 Jul 2021 00:49:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 128F5EFED for ; Mon, 12 Jul 2021 00:48:35 +0200 (CEST) Received: from kvmformation3.odiso.net (globalOdiso.M6Lille.odiso.net [89.248.211.242]) by firstgate.proxmox.com (Proxmox) with ESMTP id 47216EFE4 for ; Mon, 12 Jul 2021 00:48:34 +0200 (CEST) Received: by kvmformation3.odiso.net (Postfix, from userid 0) id 3849CADB; Mon, 12 Jul 2021 00:48:34 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Mon, 12 Jul 2021 00:48:33 +0200 Message-Id: <20210711224833.66035-1-aderumier@odiso.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.047 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% HEADER_FROM_DIFFERENT_DOMAINS 0.001 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods KHOP_HELO_FCRDNS 0.399 Relay HELO differs from its IP's reverse DNS NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH pve-network] vnet/subnet : add skipdns option X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jul 2021 22:49:05 -0000 allow to register ip to ipam without dns registration. can be used for temp/pending ip for example Signed-off-by: Alexandre Derumier --- PVE/Network/SDN/Subnets.pm | 70 ++++++++++++++++++++++---------------- PVE/Network/SDN/Vnets.pm | 16 ++++----- 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/PVE/Network/SDN/Subnets.pm b/PVE/Network/SDN/Subnets.pm index 0231822..6bb42e5 100644 --- a/PVE/Network/SDN/Subnets.pm +++ b/PVE/Network/SDN/Subnets.pm @@ -184,7 +184,7 @@ sub del_subnet { } sub next_free_ip { - my ($zone, $subnetid, $subnet, $hostname, $mac, $description) = @_; + my ($zone, $subnetid, $subnet, $hostname, $mac, $description, $skipdns) = @_; my $cidr = undef; my $ip = undef; @@ -199,7 +199,7 @@ sub next_free_ip { $hostname .= ".$dnszoneprefix" if $dnszoneprefix; #verify dns zones before ipam - verify_dns_zone($dnszone, $dns); + verify_dns_zone($dnszone, $dns) if !$skipdns; if($ipamid) { my $ipam_cfg = PVE::Network::SDN::Ipams::config(); @@ -215,10 +215,12 @@ sub next_free_ip { eval { my $reversednszone = get_reversedns_zone($subnetid, $subnet, $reversedns, $ip); - #add dns - add_dns_record($dnszone, $dns, $hostname, $ip); - #add reverse dns - add_dns_ptr_record($reversednszone, $dnszone, $reversedns, $hostname, $ip); + if(!$skipdns) { + #add dns + add_dns_record($dnszone, $dns, $hostname, $ip); + #add reverse dns + add_dns_ptr_record($reversednszone, $dnszone, $reversedns, $hostname, $ip); + } }; if ($@) { #rollback @@ -232,7 +234,7 @@ sub next_free_ip { } sub add_ip { - my ($zone, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway) = @_; + my ($zone, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway, $skipdns) = @_; return if !$subnet || !$ip; @@ -249,8 +251,10 @@ sub add_ip { $hostname .= ".$dnszoneprefix" if $dnszoneprefix; #verify dns zones before ipam - verify_dns_zone($dnszone, $dns); - verify_dns_zone($reversednszone, $reversedns); + if(!$skipdns) { + verify_dns_zone($dnszone, $dns); + verify_dns_zone($reversednszone, $reversedns); + } if ($ipamid) { @@ -265,10 +269,12 @@ sub add_ip { } eval { - #add dns - add_dns_record($dnszone, $dns, $hostname, $ip); - #add reverse dns - add_dns_ptr_record($reversednszone, $dnszone, $reversedns, $hostname, $ip); + if(!$skipdns) { + #add dns + add_dns_record($dnszone, $dns, $hostname, $ip); + #add reverse dns + add_dns_ptr_record($reversednszone, $dnszone, $reversedns, $hostname, $ip); + } }; if ($@) { #rollback @@ -281,7 +287,7 @@ sub add_ip { } sub update_ip { - my ($zone, $subnetid, $subnet, $ip, $hostname, $oldhostname, $mac, $description) = @_; + my ($zone, $subnetid, $subnet, $ip, $hostname, $oldhostname, $mac, $description, $skipdns) = @_; return if !$subnet || !$ip; @@ -298,8 +304,10 @@ sub update_ip { $hostname .= ".$dnszoneprefix" if $dnszoneprefix; #verify dns zones before ipam - verify_dns_zone($dnszone, $dns); - verify_dns_zone($reversednszone, $reversedns); + if(!$skipdns) { + verify_dns_zone($dnszone, $dns); + verify_dns_zone($reversednszone, $reversedns); + } if ($ipamid) { my $ipam_cfg = PVE::Network::SDN::Ipams::config(); @@ -314,18 +322,19 @@ sub update_ip { return if $hostname eq $oldhostname; eval { - #add dns - - del_dns_record($dnszone, $dns, $oldhostname, $ip); - add_dns_record($dnszone, $dns, $hostname, $ip); - #add reverse dns - del_dns_ptr_record($reversednszone, $reversedns, $ip); - add_dns_ptr_record($reversednszone, $dnszone, $reversedns, $hostname, $ip); + if(!$skipdns) { + #add dns + del_dns_record($dnszone, $dns, $oldhostname, $ip); + add_dns_record($dnszone, $dns, $hostname, $ip); + #add reverse dns + del_dns_ptr_record($reversednszone, $reversedns, $ip); + add_dns_ptr_record($reversednszone, $dnszone, $reversedns, $hostname, $ip); + } }; } sub del_ip { - my ($zone, $subnetid, $subnet, $ip, $hostname) = @_; + my ($zone, $subnetid, $subnet, $ip, $hostname, $skipdns) = @_; return if !$subnet || !$ip; @@ -340,9 +349,10 @@ sub del_ip { my $dnszoneprefix = $subnet->{dnszoneprefix}; $hostname .= ".$dnszoneprefix" if $dnszoneprefix; - - verify_dns_zone($dnszone, $dns); - verify_dns_zone($reversednszone, $reversedns); + if(!$skipdns) { + verify_dns_zone($dnszone, $dns); + verify_dns_zone($reversednszone, $reversedns); + } if ($ipamid) { my $ipam_cfg = PVE::Network::SDN::Ipams::config(); @@ -352,8 +362,10 @@ sub del_ip { } eval { - del_dns_record($dnszone, $dns, $hostname, $ip); - del_dns_ptr_record($reversednszone, $reversedns, $ip); + if(!$skipdns) { + del_dns_record($dnszone, $dns, $hostname, $ip); + del_dns_ptr_record($reversednszone, $reversedns, $ip); + } }; if ($@) { warn $@; diff --git a/PVE/Network/SDN/Vnets.pm b/PVE/Network/SDN/Vnets.pm index 86967a3..caa6bfc 100644 --- a/PVE/Network/SDN/Vnets.pm +++ b/PVE/Network/SDN/Vnets.pm @@ -100,7 +100,7 @@ sub get_subnet_from_vnet_cidr { } sub get_next_free_cidr { - my ($vnetid, $hostname, $mac, $description, $ipversion) = @_; + my ($vnetid, $hostname, $mac, $description, $ipversion, $skipdns) = @_; my $vnet = PVE::Network::SDN::Vnets::get_vnet($vnetid); my $zoneid = $vnet->{zone}; @@ -121,7 +121,7 @@ sub get_next_free_cidr { $subnetcount++; eval { - $ip = PVE::Network::SDN::Subnets::next_free_ip($zone, $subnetid, $subnet, $hostname, $mac, $description); + $ip = PVE::Network::SDN::Subnets::next_free_ip($zone, $subnetid, $subnet, $hostname, $mac, $description, $skipdns); }; warn $@ if $@; last if $ip; @@ -132,30 +132,30 @@ sub get_next_free_cidr { } sub add_cidr { - my ($vnetid, $cidr, $hostname, $mac, $description) = @_; + my ($vnetid, $cidr, $hostname, $mac, $description, $skipdns) = @_; return if !$vnetid; my ($zone, $subnetid, $subnet, $ip) = PVE::Network::SDN::Vnets::get_subnet_from_vnet_cidr($vnetid, $cidr); - PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac, $description); + PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $ip, $hostname, $mac, $description, undef, $skipdns); } sub update_cidr { - my ($vnetid, $cidr, $hostname, $oldhostname, $mac, $description) = @_; + my ($vnetid, $cidr, $hostname, $oldhostname, $mac, $description, $skipdns) = @_; return if !$vnetid; my ($zone, $subnetid, $subnet, $ip) = PVE::Network::SDN::Vnets::get_subnet_from_vnet_cidr($vnetid, $cidr); - PVE::Network::SDN::Subnets::update_ip($zone, $subnetid, $subnet, $ip, $hostname, $oldhostname, $mac, $description); + PVE::Network::SDN::Subnets::update_ip($zone, $subnetid, $subnet, $ip, $hostname, $oldhostname, $mac, $description, $skipdns); } sub del_cidr { - my ($vnetid, $cidr, $hostname) = @_; + my ($vnetid, $cidr, $hostname, $skipdns) = @_; return if !$vnetid; my ($zone, $subnetid, $subnet, $ip) = PVE::Network::SDN::Vnets::get_subnet_from_vnet_cidr($vnetid, $cidr); - PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname); + PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $subnet, $ip, $hostname, $skipdns); } -- 2.30.2