Merge lp:~lamont/maas/bug-1603590-1.9 into lp:maas/1.9

Proposed by LaMont Jones
Status: Merged
Approved by: LaMont Jones
Approved revision: no longer in the source branch.
Merged at revision: 4594
Proposed branch: lp:~lamont/maas/bug-1603590-1.9
Merge into: lp:maas/1.9
Diff against target: 66 lines (+33/-1)
3 files modified
docs/changelog.rst (+5/-0)
src/maasserver/models/subnet.py (+11/-1)
src/maasserver/models/tests/test_subnet.py (+17/-0)
To merge this branch: bzr merge lp:~lamont/maas/bug-1603590-1.9
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+300259@code.launchpad.net

Commit message

Allow link-local addresses (fe80::/64) for the default gateway for a subnet.

Description of the change

Allow link-local addresses (fe80::/64) for the default gateway for a subnet.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/changelog.rst'
--- docs/changelog.rst 2016-07-13 01:23:13 +0000
+++ docs/changelog.rst 2016-07-18 17:26:29 +0000
@@ -2,6 +2,11 @@
2Changelog2Changelog
3=========3=========
44
51.9.5
6=====
7
8LP: #1603590 [1.9] MAAS does not allow link-local address for default gateway on ipv6 subnet.
9
51.9.4101.9.4
6=====11=====
712
813
=== modified file 'src/maasserver/models/subnet.py'
--- src/maasserver/models/subnet.py 2015-12-03 10:41:08 +0000
+++ src/maasserver/models/subnet.py 2016-07-18 17:26:29 +0000
@@ -383,7 +383,17 @@
383 if self.gateway_ip is None or self.gateway_ip == '':383 if self.gateway_ip is None or self.gateway_ip == '':
384 return384 return
385 gateway_addr = IPAddress(self.gateway_ip)385 gateway_addr = IPAddress(self.gateway_ip)
386 if gateway_addr not in self.get_ipnetwork():386 network = self.get_ipnetwork()
387 if gateway_addr in network:
388 # If the gateway is in the network, it is fine.
389 return
390 elif network.version == 6 and gateway_addr.is_link_local():
391 # If this is an IPv6 network and the gateway is in the link-local
392 # network (fe80::/64 -- required to be configured by the spec),
393 # then it is also valid.
394 return
395 else:
396 # The gateway is not valid for the network.
387 message = "Gateway IP must be within CIDR range."397 message = "Gateway IP must be within CIDR range."
388 raise ValidationError({'gateway_ip': [message]})398 raise ValidationError({'gateway_ip': [message]})
389399
390400
=== modified file 'src/maasserver/models/tests/test_subnet.py'
--- src/maasserver/models/tests/test_subnet.py 2015-11-06 01:55:30 +0000
+++ src/maasserver/models/tests/test_subnet.py 2016-07-18 17:26:29 +0000
@@ -445,6 +445,23 @@
445 {'gateway_ip': ["Gateway IP must be within CIDR range."]},445 {'gateway_ip': ["Gateway IP must be within CIDR range."]},
446 error.message_dict)446 error.message_dict)
447447
448 def test_allows_fe80_gateway(self):
449 network = factory.make_ipv6_network(slash=64)
450 gateway_ip = factory.pick_ip_in_network(IPNetwork('fe80::/64'))
451 subnet = factory.make_Subnet(
452 cidr=unicode(network), gateway_ip=gateway_ip)
453 self.assertEqual(subnet.gateway_ip, gateway_ip)
454
455 def test_denies_fe80_gateway_for_ipv4(self):
456 network = factory.make_ipv4_network(slash=22)
457 gateway_ip = factory.pick_ip_in_network(IPNetwork('fe80::/64'))
458 error = self.assertRaises(
459 ValidationError, factory.make_Subnet,
460 cidr=unicode(network), gateway_ip=gateway_ip)
461 self.assertEqual(
462 {'gateway_ip': ["Gateway IP must be within CIDR range."]},
463 error.message_dict)
464
448 def test_create_from_cidr_creates_subnet(self):465 def test_create_from_cidr_creates_subnet(self):
449 vlan = factory.make_VLAN()466 vlan = factory.make_VLAN()
450 cidr = unicode(factory.make_ip4_or_6_network().cidr)467 cidr = unicode(factory.make_ip4_or_6_network().cidr)

Subscribers

People subscribed via source and target branches