diff --git a/kuryr_libnetwork/controllers.py b/kuryr_libnetwork/controllers.py index c831741c..17a12d93 100644 --- a/kuryr_libnetwork/controllers.py +++ b/kuryr_libnetwork/controllers.py @@ -1370,7 +1370,8 @@ def network_driver_join(): "SrcName": iface_name, "DstPrefix": config.CONF.binding.veth_dst_prefix }, - "StaticRoutes": [] + "StaticRoutes": [], + "DisableGatewayService": True, } for subnet in all_subnets: @@ -1699,7 +1700,12 @@ def ipam_request_address(): if is_gateway: # check if request gateway ip same with existed gateway ip existed_gateway_ip = subnet.get('gateway_ip', '') - if req_address == existed_gateway_ip: + if not req_address: + if subnet['ip_version'] == 4: + allocated_address = "0.0.0.0/0" + else: + allocated_address = "::/0" + elif req_address == existed_gateway_ip: allocated_address = '{}/{}'.format(req_address, subnet_cidr.prefixlen) else: diff --git a/kuryr_libnetwork/tests/unit/test_kuryr.py b/kuryr_libnetwork/tests/unit/test_kuryr.py index 8872faa1..7a10d1e1 100644 --- a/kuryr_libnetwork/tests/unit/test_kuryr.py +++ b/kuryr_libnetwork/tests/unit/test_kuryr.py @@ -2158,7 +2158,8 @@ class TestKuryr(base.TestKuryrBase): 'DstPrefix': config.CONF.binding.veth_dst_prefix, 'SrcName': fake_iface_name, }, - 'StaticRoutes': [] + 'StaticRoutes': [], + 'DisableGatewayService': True } self.assertEqual(200, response.status_code) @@ -2276,7 +2277,8 @@ class TestKuryr(base.TestKuryrBase): 'DstPrefix': config.CONF.binding.veth_dst_prefix, 'SrcName': fake_iface_name, }, - 'StaticRoutes': [] + 'StaticRoutes': [], + 'DisableGatewayService': True } self.assertEqual(200, response.status_code) @@ -2385,7 +2387,8 @@ class TestKuryr(base.TestKuryrBase): fake_v4_subnet['subnet']['host_routes'][0]['nexthop'], 'Destination': fake_v4_subnet['subnet']['host_routes'][0]['destination'], - 'RouteType': constants.ROUTE_TYPE['NEXTHOP']}] + 'RouteType': constants.ROUTE_TYPE['NEXTHOP']}], + 'DisableGatewayService': True } self.assertEqual(200, response.status_code)