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 276557C54E for ; Fri, 5 Nov 2021 09:06:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 00ECA27C8B for ; Fri, 5 Nov 2021 09:06:50 +0100 (CET) Received: from bastionodiso.odiso.net (bastionodiso.odiso.net [IPv6:2a0a:1580:2000::2d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 7D8B327C01 for ; Fri, 5 Nov 2021 09:06:43 +0100 (CET) Received: from kvmformation3.odiso.net (formationkvm3.odiso.net [10.3.94.12]) by bastionodiso.odiso.net (Postfix) with ESMTP id 17B829E6E; Fri, 5 Nov 2021 09:06:37 +0100 (CET) Received: by kvmformation3.odiso.net (Postfix, from userid 0) id 972EA14DF1D; Fri, 5 Nov 2021 09:06:46 +0100 (CET) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Fri, 5 Nov 2021 09:06:41 +0100 Message-Id: <20211105080645.3145996-2-aderumier@odiso.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211105080645.3145996-1-aderumier@odiso.com> References: <20211105080645.3145996-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% HEADER_FROM_DIFFERENT_DOMAINS 0.249 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 NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records SPF_NONE 0.001 SPF: sender does not publish an SPF Record T_SPF_HELO_TEMPERROR 0.01 SPF: test of HELO record failed (temperror) Subject: [pve-devel] [PATCH pve-network 1/5] 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: Fri, 05 Nov 2021 08:06:50 -0000 allow to register ip to ipam without dns registration. can be used for temp/pending ip for example --- 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