mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-21 18:02:18 +00:00
fix(xcat-core): makedns drops IPv6 PTRs and named.conf settings
makedns stops with "the mask should be a factor of 4" when a node is
in an IPv6 network with a /62 or other non-nibble prefix.
get_reverse_zones_for_entity rejected the prefix that getzonesfornet
already accepts. It now takes the zone of the next nibble that holds
the node address, which is one of the zones getzonesfornet creates.
A node whose hosts.ip is IPv4 got an AAAA for its IPv6 address but no
PTR, because add_or_delete_records walked hosts.ip only. It now also
walks the other addresses the makehosts content gives the node.
find_nameserver_for_dns asked the resolver for the NS of ip6.arpa. and
arpa.: its stop list matched IN-ADDR.ARPA and upper-case ARPA only.
update_namedconf matched "listen-on {" and "listen-on-v6 {". The EL
named.conf writes "listen-on-v6 port 53 { ::1; };", so
site.dnsinterfaces was ignored and named stayed on ::1. The match now
allows options before the brace and a block on one line.
A new zone closed allow-update before the site.dnsupdaters entries,
and named rejects the entries as unknown options.
ddns_ipv6_records.t holds each case down.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -252,10 +252,10 @@ sub get_reverse_zones_for_entity {
|
||||
} elsif ($net =~ /:/) { #v6/ip6.arpa case
|
||||
$net =~ /\/(.*)/;
|
||||
my $maskbits = $1;
|
||||
unless (defined($maskbits) && (($maskbits % 4) == 0)) {
|
||||
die "Never expected this, $net should have had CIDR / notation... and the mask should be a factor of 4, if not, need work..."
|
||||
unless (defined($maskbits)) {
|
||||
die "Never expected this, $net should have had CIDR / notation"
|
||||
}
|
||||
push @revs, xCAT::NetworkUtils->getIPv6ReverseZone($net);
|
||||
push @revs, _ipv6_reverse_zone_of_number($tvar, $maskbits);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,6 +263,31 @@ sub get_reverse_zones_for_entity {
|
||||
return @revs;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 _ipv6_reverse_zone_of_number
|
||||
|
||||
Descriptions: The ip6.arpa zone that holds one IPv6 address of a network.
|
||||
A reverse zone is delegated on a nibble, so for a prefix that is not a
|
||||
multiple of 4 the zone is the one of the next nibble. getzonesfornet
|
||||
creates the same zones for that network.
|
||||
Arguments: the address as a number (getipaddr GetNumber), the prefix length
|
||||
Returns: the zone name
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub _ipv6_reverse_zone_of_number {
|
||||
my ($number, $prefix) = @_;
|
||||
|
||||
my $nibbles = int(($prefix + 3) / 4);
|
||||
return 'ip6.arpa.' unless $nibbles;
|
||||
my $hex = Math::BigInt->new($number)->as_hex;
|
||||
$hex =~ s/^0x//;
|
||||
$hex = substr(('0' x 32) . $hex, -32, $nibbles);
|
||||
return join('.', reverse(split(//, $hex))) . '.ip6.arpa.';
|
||||
}
|
||||
|
||||
sub process_request {
|
||||
my $request = shift;
|
||||
$callback = shift;
|
||||
@@ -1296,16 +1321,17 @@ sub update_namedconf {
|
||||
push @newnamed, "\t\t" . $_ . ";\n";
|
||||
}
|
||||
push @newnamed, "\t};\n";
|
||||
} elsif (defined($ctx->{dnslistenonifs}) and defined($ctx->{dnslistenonifs}->{ipv4}) and $line =~ /listen-on \{/) {
|
||||
} elsif (defined($ctx->{dnslistenonifs}) and defined($ctx->{dnslistenonifs}->{ipv4}) and $line =~ /listen-on\s[^{]*\{/) {
|
||||
# The distribution file writes "listen-on port 53 { ... };" on one line.
|
||||
push @newnamed, "\tlisten-on \{\n";
|
||||
$skip = 1;
|
||||
$skip = ($line !~ /\};/);
|
||||
foreach (@{ $ctx->{dnslistenonifs}->{ipv4} }) {
|
||||
push @newnamed, "\t\t" . $_ . ";\n";
|
||||
}
|
||||
push @newnamed, "\t};\n";
|
||||
} elsif (defined($ctx->{dnslistenonifs}) and defined($ctx->{dnslistenonifs}->{ipv6}) and $line =~ /listen-on-v6 \{/) {
|
||||
} elsif (defined($ctx->{dnslistenonifs}) and defined($ctx->{dnslistenonifs}->{ipv6}) and $line =~ /listen-on-v6\s[^{]*\{/) {
|
||||
push @newnamed, "\tlisten-on-v6 \{\n";
|
||||
$skip = 1;
|
||||
$skip = ($line !~ /\};/);
|
||||
foreach (@{ $ctx->{dnslistenonifs}->{ipv6} }) {
|
||||
push @newnamed, "\t\t" . $_ . ";\n";
|
||||
}
|
||||
@@ -1536,10 +1562,11 @@ sub update_namedconf {
|
||||
push @newnamed, "\ttype slave;\n";
|
||||
push @newnamed, "\tmasters { $output[0]; };\n";
|
||||
} else {
|
||||
push @newnamed, "\ttype master;\n", "\tallow-update {\n", "\t\tkey $omapi_key_name;\n", "\t};\n";
|
||||
push @newnamed, "\ttype master;\n", "\tallow-update {\n", "\t\tkey $omapi_key_name;\n";
|
||||
foreach (@{ $ctx->{dnsupdaters} }) {
|
||||
push @newnamed, "\t\t$_;\n";
|
||||
}
|
||||
push @newnamed, "\t};\n";
|
||||
}
|
||||
if ($zone =~ /IN-ADDR\.ARPA/) {
|
||||
my $net = $zone;
|
||||
@@ -1709,7 +1736,11 @@ sub add_or_delete_records {
|
||||
unless ($name =~ /\.$domain\z/) { $name .= "." . $domain } # $name needs to represent fqdn, but must preserve $node as a nodename for cfg lookup
|
||||
|
||||
if ($ctx->{hoststab} and $ctx->{hoststab}->{$node} and $ctx->{hoststab}->{$node}->[0]->{ip}) {
|
||||
@ips = ($ctx->{hoststab}->{$node}->[0]->{ip});
|
||||
my $hostip = $ctx->{hoststab}->{$node}->[0]->{ip};
|
||||
|
||||
# hosts.ip holds one address. The other family of a dual-stack node comes from the
|
||||
# makehosts content, and it needs its PTR too.
|
||||
@ips = ($hostip, grep { $_ ne $hostip } sort keys %{ $ctx->{nodeips}->{$node} || {} });
|
||||
} else {
|
||||
@ips = getipaddr($node, GetAllAddresses => 1);
|
||||
if (not @ips and keys %{ $ctx->{nodeips}->{$node} }) {
|
||||
@@ -1819,7 +1850,7 @@ sub find_nameserver_for_dns {
|
||||
}
|
||||
while ($zone) {
|
||||
unless (defined $ctx->{nsmap}->{$zone}) { #ok, we already thought about this zone and made a decision
|
||||
if ($zone =~ /^\.*192.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*172.IN-ADDR.ARPA\.*/ or $zone =~ /127.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*IN-ADDR.ARPA\.*/ or $zone =~ /^\.*ARPA\.*/) {
|
||||
if ($zone =~ /^\.*(?:ip6\.)?arpa\.*$/i or $zone =~ /^\.*192.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*172.IN-ADDR.ARPA\.*/ or $zone =~ /127.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*IN-ADDR.ARPA\.*/ or $zone =~ /^\.*ARPA\.*/) {
|
||||
$ctx->{nsmap}->{$zone} = 0; #ignore zones that are likely to appear, but probably not ours
|
||||
} elsif ($::XCATSITEVALS{ddnsserver}) {
|
||||
$ctx->{nsmap}->{$zone} = $::XCATSITEVALS{ddnsserver};
|
||||
|
||||
Reference in New Issue
Block a user