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
1diff --git a/src/maasserver/dns/tests/test_zonegenerator.py b/src/maasserver/dns/tests/test_zonegenerator.py
2index 0d96159..c012e9c 100644
3--- a/src/maasserver/dns/tests/test_zonegenerator.py
4+++ b/src/maasserver/dns/tests/test_zonegenerator.py
5@@ -384,6 +384,9 @@ class TestZoneGenerator(MAASServerTestCase):
6 "0-25.33.168.192.in-addr.arpa",
7 "0-26.35.168.192.in-addr.arpa",
8 "0-26.36.168.192.in-addr.arpa",
9+ "33.168.192.in-addr.arpa",
10+ "35.168.192.in-addr.arpa",
11+ "36.168.192.in-addr.arpa",
12 "overlap",
13 ]
14 zone_names = [
15diff --git a/src/maasserver/dns/zonegenerator.py b/src/maasserver/dns/zonegenerator.py
16index bd6401a..40af246 100644
17--- a/src/maasserver/dns/zonegenerator.py
18+++ b/src/maasserver/dns/zonegenerator.py
19@@ -429,7 +429,7 @@ class ZoneGenerator:
20 dynamic_ranges=dynamic_ranges,
21 rfc2317_ranges=glue,
22 exclude=set(
23- [IPNetwork(s.cidr) for s in subnets if s is not subnet]
24+ IPNetwork(s.cidr) for s in subnets if s is not subnet
25 ),
26 )
27 # Now provide any remaining rfc2317 glue networks.
28@@ -441,7 +441,11 @@ class ZoneGenerator:
29 network=network,
30 ns_host_name=ns_host_name,
31 rfc2317_ranges=ranges,
32- exclude=set([IPNetwork(s.cidr) for s in subnets]),
33+ exclude=set(
34+ IPNetwork(s.cidr)
35+ for s in subnets
36+ if network in IPNetwork(s.cidr)
37+ ),
38 )
39
40 def __iter__(self):
41diff --git a/src/provisioningserver/dns/zoneconfig.py b/src/provisioningserver/dns/zoneconfig.py
42index c88a9ba..24d5547 100644
43--- a/src/provisioningserver/dns/zoneconfig.py
44+++ b/src/provisioningserver/dns/zoneconfig.py
45@@ -346,6 +346,22 @@ class DNSReverseZoneConfig(DomainConfigBase):
46 super().__init__(domain, zone_info=zone_info, **kwargs)
47
48 @classmethod
49+ def _skip_if_overlaps(cls, first, base, step, network, exclude):
50+ for other_network in exclude:
51+ if (
52+ first in other_network
53+ and network.prefixlen < other_network.prefixlen
54+ ): # allow the more specific overlapping subnet to create the zone config
55+ try:
56+ base += 1
57+ first += step
58+ except IndexError:
59+ # IndexError occurs when we go from 255.255.255.255 to
60+ # 0.0.0.0. If we hit that, we're all fine and done.
61+ break
62+ return (first, base)
63+
64+ @classmethod
65 def compose_zone_info(cls, network, exclude=()):
66 """Return the names of the reverse zones."""
67 # Generate the name of the reverse zone file:
68@@ -400,23 +416,13 @@ class DNSReverseZoneConfig(DomainConfigBase):
69 base = int(split_zone[rest_limit - 1])
70 while first <= last:
71
72- for other_network in exclude:
73- if (
74- first in other_network
75- and network.prefixlen < other_network.prefixlen
76- ): # allow the more specific overlapping subnet to create the zone config
77- try:
78- base += 1
79- first += step
80- if (
81- first > last
82- ): # if the excluding subnet pushes the base IP beyond the bounds of the generating subnet, we've reached the end and return early
83- return info
84- continue
85- except IndexError:
86- # IndexError occurs when we go from 255.255.255.255 to
87- # 0.0.0.0. If we hit that, we're all fine and done.
88- break
89+ (first, base) = cls._skip_if_overlaps(
90+ first, base, step, network, exclude
91+ )
92+ if first > last:
93+ # if the excluding subnet pushes the base IP beyond the bounds of the generating subnet, we've reached the end and return early
94+ return info
95+
96 # Rest_limit has bounds of 1..labelcount+1 (5 or 33).
97 # If we're stripping any elements, then we just want base.name.
98 if rest_limit > 1:

Subscribers

People subscribed via source and target branches