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


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to