public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Matthieu Pignolet <matthieu@matthieu-dev.xyz>
To: pve-devel@lists.proxmox.com
Cc: Matthieu Pignolet <matthieu@matthieu-dev.xyz>
Subject: [pve-devel] [PATCH pve-network] dns: only update rrsets which matches the rrset type
Date: Mon,  4 Dec 2023 20:40:54 +0400	[thread overview]
Message-ID: <20231204164054.861599-1-matthieu@matthieu-dev.xyz> (raw)

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




                 reply	other threads:[~2023-12-04 17:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20231204164054.861599-1-matthieu@matthieu-dev.xyz \
    --to=matthieu@matthieu-dev.xyz \
    --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