diff --git a/vmware_nsx/plugins/common/plugin.py b/vmware_nsx/plugins/common/plugin.py index d8f0ad97c5..01b2dc3bfb 100644 --- a/vmware_nsx/plugins/common/plugin.py +++ b/vmware_nsx/plugins/common/plugin.py @@ -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) diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index eb5c037b85..62ee1208fb 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -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):