From: Matthieu Pignolet Date: Thu, 27 Feb 2025 09:02:27 +0000 (+0400) Subject: dns: powerdns: correctly handle different records types (A / AAAA) X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=2fd0ad83d3cc043092d54d104cc5df40ad062b3a;p=mirror%2Fpve-network.git dns: powerdns: correctly handle different records types (A / AAAA) This fixes an issue with dual stacking, when using a zone with both a IPv4 and IPv6 subnet and the same DNS suffix, pve-network will try to set both DNS records (type A and AAAA) in the same powerdns rrset, causing an API error, and effectively causing no forward DNS records being created. This change edits the `get_zone_rrset` function so that it takes the DNS record type into account. Signed-off-by: Matthieu Pignolet Tested-by: Stefan Hanreich [TL: wrap commit message] Signed-off-by: Thomas Lamprecht --- diff --git a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm index 15afb4a..aad8b6f 100644 --- a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm +++ b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm @@ -66,7 +66,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 = []; for my $record (@{$existing_rrset->{records}}) { @@ -136,7 +136,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 = [ grep { $_->{content} ne $ip } $existing_rrset->{records}->@* ]; my $final_records_size = scalar($final_records->@*); @@ -262,10 +262,10 @@ sub get_zone_content { } sub get_zone_rrset { - my ($zonecontent, $name) = @_; + my ($zonecontent, $name, $type) = @_; for my $rrset (@{$zonecontent->{rrsets}}) { - return $rrset if $rrset->{name} eq $name; + return $rrset if $rrset->{name} eq $name and ($rrset->{type} eq $type); } return; # not found }