Merge ~bjornt/maas:reverse-dns-3.0-backport into maas:3.0

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: dad809bbc9e36f92f45cb12ac78b8f3b411e6975
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~bjornt/maas:reverse-dns-3.0-backport
Merge into: maas:3.0
Diff against target: 98 lines (+32/-19)
3 files modified
src/maasserver/dns/tests/test_zonegenerator.py (+3/-0)
src/maasserver/dns/zonegenerator.py (+6/-2)
src/provisioningserver/dns/zoneconfig.py (+23/-17)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Björn Tillenius Approve
Review via email: mp+404108@code.launchpad.net

Commit message

LP #1931838: Reverse DNS lookup fails for subnets smaller than /24

pull the skip exclusions logic into its own function

correct the rfc2317 glue exclusions

(cherry picked from commit fdd0c41bba6b758416f460829b83d03e86200f36)

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Self-approve backport

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b reverse-dns-3.0-backport lp:~bjornt/maas/+git/maas into -b 3.0 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: dad809bbc9e36f92f45cb12ac78b8f3b411e6975

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/dns/tests/test_zonegenerator.py b/src/maasserver/dns/tests/test_zonegenerator.py
index 0d96159..c012e9c 100644
--- a/src/maasserver/dns/tests/test_zonegenerator.py
+++ b/src/maasserver/dns/tests/test_zonegenerator.py
@@ -384,6 +384,9 @@ class TestZoneGenerator(MAASServerTestCase):
384 "0-25.33.168.192.in-addr.arpa",384 "0-25.33.168.192.in-addr.arpa",
385 "0-26.35.168.192.in-addr.arpa",385 "0-26.35.168.192.in-addr.arpa",
386 "0-26.36.168.192.in-addr.arpa",386 "0-26.36.168.192.in-addr.arpa",
387 "33.168.192.in-addr.arpa",
388 "35.168.192.in-addr.arpa",
389 "36.168.192.in-addr.arpa",
387 "overlap",390 "overlap",
388 ]391 ]
389 zone_names = [392 zone_names = [
diff --git a/src/maasserver/dns/zonegenerator.py b/src/maasserver/dns/zonegenerator.py
index bd6401a..40af246 100644
--- a/src/maasserver/dns/zonegenerator.py
+++ b/src/maasserver/dns/zonegenerator.py
@@ -429,7 +429,7 @@ class ZoneGenerator:
429 dynamic_ranges=dynamic_ranges,429 dynamic_ranges=dynamic_ranges,
430 rfc2317_ranges=glue,430 rfc2317_ranges=glue,
431 exclude=set(431 exclude=set(
432 [IPNetwork(s.cidr) for s in subnets if s is not subnet]432 IPNetwork(s.cidr) for s in subnets if s is not subnet
433 ),433 ),
434 )434 )
435 # Now provide any remaining rfc2317 glue networks.435 # Now provide any remaining rfc2317 glue networks.
@@ -441,7 +441,11 @@ class ZoneGenerator:
441 network=network,441 network=network,
442 ns_host_name=ns_host_name,442 ns_host_name=ns_host_name,
443 rfc2317_ranges=ranges,443 rfc2317_ranges=ranges,
444 exclude=set([IPNetwork(s.cidr) for s in subnets]),444 exclude=set(
445 IPNetwork(s.cidr)
446 for s in subnets
447 if network in IPNetwork(s.cidr)
448 ),
445 )449 )
446450
447 def __iter__(self):451 def __iter__(self):
diff --git a/src/provisioningserver/dns/zoneconfig.py b/src/provisioningserver/dns/zoneconfig.py
index c88a9ba..24d5547 100644
--- a/src/provisioningserver/dns/zoneconfig.py
+++ b/src/provisioningserver/dns/zoneconfig.py
@@ -346,6 +346,22 @@ class DNSReverseZoneConfig(DomainConfigBase):
346 super().__init__(domain, zone_info=zone_info, **kwargs)346 super().__init__(domain, zone_info=zone_info, **kwargs)
347347
348 @classmethod348 @classmethod
349 def _skip_if_overlaps(cls, first, base, step, network, exclude):
350 for other_network in exclude:
351 if (
352 first in other_network
353 and network.prefixlen < other_network.prefixlen
354 ): # allow the more specific overlapping subnet to create the zone config
355 try:
356 base += 1
357 first += step
358 except IndexError:
359 # IndexError occurs when we go from 255.255.255.255 to
360 # 0.0.0.0. If we hit that, we're all fine and done.
361 break
362 return (first, base)
363
364 @classmethod
349 def compose_zone_info(cls, network, exclude=()):365 def compose_zone_info(cls, network, exclude=()):
350 """Return the names of the reverse zones."""366 """Return the names of the reverse zones."""
351 # Generate the name of the reverse zone file:367 # Generate the name of the reverse zone file:
@@ -400,23 +416,13 @@ class DNSReverseZoneConfig(DomainConfigBase):
400 base = int(split_zone[rest_limit - 1])416 base = int(split_zone[rest_limit - 1])
401 while first <= last:417 while first <= last:
402418
403 for other_network in exclude:419 (first, base) = cls._skip_if_overlaps(
404 if (420 first, base, step, network, exclude
405 first in other_network421 )
406 and network.prefixlen < other_network.prefixlen422 if first > last:
407 ): # allow the more specific overlapping subnet to create the zone config423 # if the excluding subnet pushes the base IP beyond the bounds of the generating subnet, we've reached the end and return early
408 try:424 return info
409 base += 1425
410 first += step
411 if (
412 first > last
413 ): # if the excluding subnet pushes the base IP beyond the bounds of the generating subnet, we've reached the end and return early
414 return info
415 continue
416 except IndexError:
417 # IndexError occurs when we go from 255.255.255.255 to
418 # 0.0.0.0. If we hit that, we're all fine and done.
419 break
420 # Rest_limit has bounds of 1..labelcount+1 (5 or 33).426 # Rest_limit has bounds of 1..labelcount+1 (5 or 33).
421 # If we're stripping any elements, then we just want base.name.427 # If we're stripping any elements, then we just want base.name.
422 if rest_limit > 1:428 if rest_limit > 1:

Subscribers

People subscribed via source and target branches