Merge "[OVN] Set send_periodic to False on provider networks"
This commit is contained in:
commit
b9a717f48c
@ -469,7 +469,7 @@ def is_gateway_chassis_invalid(chassis_name, gw_chassis,
|
||||
|
||||
|
||||
def is_provider_network(network):
|
||||
return external_net.EXTERNAL in network
|
||||
return network.get(external_net.EXTERNAL, False)
|
||||
|
||||
|
||||
def is_neutron_dhcp_agent_port(port):
|
||||
|
@ -1000,12 +1000,14 @@ class OVNClient(object):
|
||||
utils.ovn_lrouter_port_name(gw_port_id),
|
||||
gw_lrouter_name))
|
||||
|
||||
def _get_nets_and_ipv6_ra_confs_for_router_port(
|
||||
self, context, port_fixed_ips):
|
||||
def _get_nets_and_ipv6_ra_confs_for_router_port(self, context, port):
|
||||
port_fixed_ips = port['fixed_ips']
|
||||
networks = set()
|
||||
ipv6_ra_configs = {}
|
||||
ipv6_ra_configs_supported = self._nb_idl.is_col_present(
|
||||
'Logical_Router_Port', 'ipv6_ra_configs')
|
||||
is_gw_port = const.DEVICE_OWNER_ROUTER_GW == port.get(
|
||||
'device_owner')
|
||||
|
||||
for fixed_ip in port_fixed_ips:
|
||||
subnet_id = fixed_ip['subnet_id']
|
||||
@ -1019,8 +1021,14 @@ class OVNClient(object):
|
||||
ipv6_ra_configs['address_mode'] = (
|
||||
utils.get_ovn_ipv6_address_mode(
|
||||
subnet['ipv6_address_mode']))
|
||||
ipv6_ra_configs['send_periodic'] = 'true'
|
||||
net = self._plugin.get_network(context, subnet['network_id'])
|
||||
# If it's a gateway port and connected to a provider
|
||||
# network set send_periodic to False, that way we do not
|
||||
# leak the RAs generated for the tenant networks via the
|
||||
# provider network
|
||||
ipv6_ra_configs['send_periodic'] = 'true'
|
||||
if is_gw_port and utils.is_provider_network(net):
|
||||
ipv6_ra_configs['send_periodic'] = 'false'
|
||||
ipv6_ra_configs['mtu'] = str(net['mtu'])
|
||||
|
||||
return list(networks), ipv6_ra_configs
|
||||
@ -1343,8 +1351,7 @@ class OVNClient(object):
|
||||
"""Create a logical router port."""
|
||||
lrouter = utils.ovn_name(router['id'])
|
||||
networks, ipv6_ra_configs = (
|
||||
self._get_nets_and_ipv6_ra_confs_for_router_port(
|
||||
context, port['fixed_ips']))
|
||||
self._get_nets_and_ipv6_ra_confs_for_router_port(context, port))
|
||||
lrouter_port_name = utils.ovn_lrouter_port_name(port['id'])
|
||||
is_gw_port = const.DEVICE_OWNER_ROUTER_GW == port.get(
|
||||
'device_owner')
|
||||
@ -1418,8 +1425,7 @@ class OVNClient(object):
|
||||
def _update_lrouter_port(self, context, port, if_exists=False, txn=None):
|
||||
"""Update a logical router port."""
|
||||
networks, ipv6_ra_configs = (
|
||||
self._get_nets_and_ipv6_ra_confs_for_router_port(
|
||||
context, port['fixed_ips']))
|
||||
self._get_nets_and_ipv6_ra_confs_for_router_port(context, port))
|
||||
|
||||
lsp_address = ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER
|
||||
lrp_name = utils.ovn_lrouter_port_name(port['id'])
|
||||
|
@ -1240,18 +1240,18 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
||||
AssertionError, self.assertItemsEqual, db_router_ids,
|
||||
monitor_lrouter_ids)
|
||||
|
||||
def _get_networks_for_router_port(port_fixed_ips):
|
||||
def _get_networks_for_router_port(port):
|
||||
_ovn_client = self.l3_plugin._ovn_client
|
||||
networks, _ = (
|
||||
_ovn_client._get_nets_and_ipv6_ra_confs_for_router_port(
|
||||
self.ctx, port_fixed_ips))
|
||||
self.ctx, port))
|
||||
return networks
|
||||
|
||||
def _get_ipv6_ra_configs_for_router_port(port_fixed_ips):
|
||||
def _get_ipv6_ra_configs_for_router_port(port):
|
||||
_ovn_client = self.l3_plugin._ovn_client
|
||||
networks, ipv6_ra_configs = (
|
||||
_ovn_client._get_nets_and_ipv6_ra_confs_for_router_port(
|
||||
self.ctx, port_fixed_ips))
|
||||
self.ctx, port))
|
||||
return ipv6_ra_configs
|
||||
|
||||
for router_id in db_router_ids:
|
||||
@ -1260,10 +1260,10 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
||||
r_port_ids = [p['id'] for p in r_ports['ports']]
|
||||
r_port_networks = {
|
||||
p['id']:
|
||||
_get_networks_for_router_port(p['fixed_ips'])
|
||||
_get_networks_for_router_port(p)
|
||||
for p in r_ports['ports']}
|
||||
r_port_ipv6_ra_configs = {
|
||||
p['id']: _get_ipv6_ra_configs_for_router_port(p['fixed_ips'])
|
||||
p['id']: _get_ipv6_ra_configs_for_router_port(p)
|
||||
for p in r_ports['ports']}
|
||||
r_routes = db_routes[router_id]
|
||||
r_nats = db_nats[router_id]
|
||||
|
@ -437,7 +437,7 @@ class TestOvnNbSyncML2(test_mech_driver.OVNMechanismDriverTestCase):
|
||||
ovn_nb_synchronizer._ovn_client = mock.Mock()
|
||||
ovn_nb_synchronizer._ovn_client.\
|
||||
_get_nets_and_ipv6_ra_confs_for_router_port.return_value = (
|
||||
self.lrport_networks, {})
|
||||
self.lrport_networks, {'fixed_ips': {}})
|
||||
ovn_nb_synchronizer._ovn_client._get_v4_network_of_all_router_ports. \
|
||||
side_effect = self._fake_get_v4_network_of_all_router_ports
|
||||
ovn_nb_synchronizer._ovn_client._get_gw_info = mock.Mock()
|
||||
|
Loading…
Reference in New Issue
Block a user