public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-network] dns: only update rrsets which matches the rrset type
@ 2023-12-04 16:40 Matthieu Pignolet
  0 siblings, 0 replies; only message in thread
From: Matthieu Pignolet @ 2023-12-04 16:40 UTC (permalink / raw)
  To: pve-devel; +Cc: Matthieu Pignolet

PowerDNS does not allow multiple dns types in the same rrset, this patch
enables the use of multiple rrset for each types of records.

This fixes an issue when using dual stack ips (Both IPv4 and IPv6) with the
same dns suffix.
---
 src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
index 096d131..c7f79c1 100644
--- a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
+++ b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
@@ -53,7 +53,7 @@ sub add_a_record {
     my $fqdn = $hostname.".".$zone.".";
 
     my $zonecontent = get_zone_content($plugin_config, $zone);
-    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn);
+    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn, $type);
 
     my $final_records = [];
     my $foundrecord = undef;
@@ -62,13 +62,14 @@ sub add_a_record {
 	    $foundrecord = 1;
 	    next;
 	}
+
 	push @$final_records, $record;
     }
     return if $foundrecord;
 
     my $record = { content => $ip, 
                    disabled => JSON::false, 
-		   name => $fqdn, 
+                   name => $fqdn,
                    type => $type, 
                    priority => 0 };
 
@@ -139,7 +140,7 @@ sub del_a_record {
     my $type = Net::IP::ip_is_ipv6($ip) ? "AAAA" : "A";
 
     my $zonecontent = get_zone_content($plugin_config, $zone);
-    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn);
+    my $existing_rrset = get_zone_rrset($zonecontent, $fqdn, $type);
 
     my $final_records = [];
     my $foundrecord = undef;
@@ -313,13 +314,13 @@ sub get_zone_content {
 }
 
 sub get_zone_rrset {
-    my ($zonecontent, $name) = @_;
+    my ($zonecontent, $name, $type) = @_;
 
     my $rrsetresult = undef;
     foreach my $rrset (@{$zonecontent->{rrsets}}) {
-	next if $rrset->{name} ne $name;
+	next if ($rrset->{name} ne $name) or ($rrset->{type} ne $type);
         $rrsetresult = $rrset;
-	last; 
+	last;
     }
     return $rrsetresult;
 }
-- 
2.39.2




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-04 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04 16:40 [pve-devel] [PATCH pve-network] dns: only update rrsets which matches the rrset type Matthieu Pignolet

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