Merge "[DVR] Fix update of the MTU in the DVR HA routers"

This commit is contained in:
Zuul 2021-11-04 14:20:22 +00:00 committed by Gerrit Code Review
commit 77e05822a8
4 changed files with 35 additions and 9 deletions

View File

@ -14,10 +14,14 @@
# under the License.
from neutron_lib import constants
from oslo_log import log as logging
from neutron.agent.l3 import dvr_edge_router
from neutron.agent.l3 import ha_router
from neutron.agent.l3 import router_info
from neutron.common import utils as common_utils
LOG = logging.getLogger(__name__)
class DvrEdgeHaRouter(dvr_edge_router.DvrEdgeRouter,
@ -57,6 +61,22 @@ class DvrEdgeHaRouter(dvr_edge_router.DvrEdgeRouter,
self._get_snat_int_device_name,
constants.SNAT_INT_DEV_PREFIX)
def internal_network_updated(self, port):
interface_name = self.get_internal_device_name(port['id'])
ip_cidrs = common_utils.fixed_ip_cidrs(port['fixed_ips'])
mtu = port['mtu']
self.driver.set_mtu(interface_name, mtu, namespace=self.ns_name,
prefix=router_info.INTERNAL_DEV_PREFIX)
self._clear_vips(interface_name)
# NOTE(slaweq): qr- interface is not in ha_namespace but in qrouter
# namespace in case of dvr ha ruter
self._disable_ipv6_addressing_on_interface(
interface_name, namespace=self.ns_name)
for ip_cidr in ip_cidrs:
self._add_vip(ip_cidr, interface_name)
self._set_snat_interfce_mtu(port)
def add_centralized_floatingip(self, fip, fip_cidr):
interface_name = self.get_snat_external_device_interface_name(
self.get_ex_gw_port())

View File

@ -129,11 +129,7 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
lib_constants.SNAT_INT_DEV_PREFIX,
mtu=sn_port.get('mtu'))
def internal_network_updated(self, port):
super(DvrEdgeRouter, self).internal_network_updated(port)
if not port:
return
def _set_snat_interfce_mtu(self, port):
if not self._is_this_snat_host():
return
@ -146,6 +142,11 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
self.driver.set_mtu(interface_name, port['mtu'], namespace=ns_name,
prefix=lib_constants.SNAT_INT_DEV_PREFIX)
def internal_network_updated(self, port):
super(DvrEdgeRouter, self).internal_network_updated(port)
if port:
self._set_snat_interfce_mtu(port)
def _dvr_internal_network_removed(self, port):
super(DvrEdgeRouter, self)._dvr_internal_network_removed(port)

View File

@ -325,21 +325,23 @@ class HaRouter(router.RouterInfo):
return False
return True
def _disable_ipv6_addressing_on_interface(self, interface_name):
def _disable_ipv6_addressing_on_interface(self, interface_name,
namespace=None):
"""Disable IPv6 link local addressing on the device and add it as
a VIP to keepalived. This means that the IPv6 link local address
will only be present on the primary.
"""
device = ip_lib.IPDevice(interface_name, namespace=self.ha_namespace)
namespace = namespace or self.ha_namespace
device = ip_lib.IPDevice(interface_name, namespace=namespace)
ipv6_lladdr = ip_lib.get_ipv6_lladdr(device.link.address)
if self._should_delete_ipv6_lladdr(ipv6_lladdr):
self.driver.configure_ipv6_ra(self.ha_namespace, interface_name,
self.driver.configure_ipv6_ra(namespace, interface_name,
n_consts.ACCEPT_RA_DISABLED)
device.addr.flush(n_consts.IP_VERSION_6)
else:
self.driver.configure_ipv6_ra(
self.ha_namespace, interface_name,
namespace, interface_name,
n_consts.ACCEPT_RA_WITHOUT_FORWARDING)
self._remove_vip(ipv6_lladdr)

View File

@ -2385,3 +2385,6 @@ class TestDvrRouter(DvrRouterTestFramework, framework.L3AgentTestFramework):
def test_dvr_router_interface_mtu_update(self):
self._test_router_interface_mtu_update(ha=False)
def test_dvr_ha_router_interface_mtu_update(self):
self._test_router_interface_mtu_update(ha=True)