Merge "Loopback address routing should be invalid"

This commit is contained in:
Zuul 2019-06-26 22:59:13 +00:00 committed by Gerrit Code Review
commit 34a61eee20
3 changed files with 15 additions and 0 deletions

View File

@ -680,6 +680,8 @@ def validate_route_cidr(data, valid_values=None):
msg = _("'%(data)s' is not a recognized CIDR,"
" '%(cidr)s' is recommended") % {"data": data,
"cidr": net.cidr}
elif net.is_loopback():
msg = _("'%(data)s' is not a routable CIDR") % {"data": data}
else:
return
except Exception:

View File

@ -742,6 +742,12 @@ class TestAttributeValidation(base.BaseTestCase):
"cidr": "192.0.0.0/8"}
self.assertEqual(error, msg)
# Invalid - loopback CIDR
cidr = "127.0.0.0/8"
msg = validators.validate_route_cidr(cidr, None)
error = _("'%(data)s' is not a routable CIDR") % {"data": cidr}
self.assertEqual(error, msg)
# Invalid - CIDR format error
cidr = 'invalid'
msg = validators.validate_route_cidr(cidr, None)

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Static route validator should verify that routed CIDR isn't a loopback.
Loopback addresses should not be routable.
Bug: `1834012 <https://bugs.launchpad.net/neutron/+bug/1834012>`_