Merge "NSX|v+v3: Prevent adding 0.0.0.0 route to router"
This commit is contained in:
commit
17186e8daf
@ -327,7 +327,7 @@ class NsxPluginBase(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
context, router_id, routes)
|
||||
# do not allow adding a default route. NSX-v/v3 don't support it
|
||||
for route in routes:
|
||||
if route.get('destination') == '0.0.0.0/0':
|
||||
if route.get('destination', '').startswith('0.0.0.0/'):
|
||||
msg = _("Cannot set a default route using static routes")
|
||||
raise n_exc.BadRequest(resource='router', msg=msg)
|
||||
|
||||
|
@ -1762,6 +1762,22 @@ class TestL3NatTestCase(L3NatTest,
|
||||
az_hints = rtr['router']['availability_zone_hints']
|
||||
self.assertListEqual(zone, az_hints)
|
||||
|
||||
def _test_route_update_illegal(self, destination):
|
||||
routes = [{'destination': destination, 'nexthop': '10.0.1.3'}]
|
||||
with self.router() as r:
|
||||
with self.subnet(cidr='10.0.1.0/24') as s:
|
||||
fixed_ip_data = [{'ip_address': '10.0.1.2'}]
|
||||
with self.port(subnet=s, fixed_ips=fixed_ip_data) as p:
|
||||
self._router_interface_action(
|
||||
'add', r['router']['id'], None, p['port']['id'])
|
||||
self._update('routers', r['router']['id'],
|
||||
{'router': {'routes': routes}},
|
||||
expected_code=400)
|
||||
|
||||
def test_route_update_illegal(self):
|
||||
self._test_route_update_illegal('0.0.0.0/0')
|
||||
self._test_route_update_illegal('0.0.0.0/16')
|
||||
|
||||
|
||||
class ExtGwModeTestCase(test_ext_gw_mode.ExtGwModeIntTestCase,
|
||||
L3NatTest):
|
||||
|
Loading…
Reference in New Issue
Block a user