Default route missing for IPv6 subnets in HA Router

In an HA setup, keepalived would configure the default gateway (in the master
HA router) by parsing the "virtual_routes" section of keepalived.conf file.
The "virtual_routes" section is properly constructed for an IPv4 subnet, but
requires a minor change for IPv6 subnets.

Closes-Bug: #1414937
Change-Id: I54070e048577292d98d86fcc9ca8b9d3e72b4ebe
This commit is contained in:
sridhargaddam 2015-01-28 14:18:00 +00:00
parent 36bfd6b889
commit a1318ae187
3 changed files with 35 additions and 17 deletions

View File

@ -174,8 +174,9 @@ class HaRouter(router.RouterInfo):
instance = self._get_keepalived_instance()
# Filter out all of the old routes while keeping only the default route
default_gw = ('::/0', '0.0.0.0/0')
instance.virtual_routes = [route for route in instance.virtual_routes
if route.destination == '0.0.0.0/0']
if route.destination in default_gw]
for route in new_routes:
instance.virtual_routes.append(keepalived.KeepalivedVirtualRoute(
route['destination'],
@ -187,13 +188,15 @@ class HaRouter(router.RouterInfo):
gw_ip = ex_gw_port['subnet']['gateway_ip']
if gw_ip:
# TODO(Carl) This is repeated everywhere. A method would be nice.
default_gw = ('0.0.0.0/0' if netaddr.IPAddress(gw_ip).version == 4
else '::/0')
instance = self._get_keepalived_instance()
instance.virtual_routes = (
[route for route in instance.virtual_routes
if route.destination != '0.0.0.0/0'])
if route.destination != default_gw])
instance.virtual_routes.append(
keepalived.KeepalivedVirtualRoute(
'0.0.0.0/0', gw_ip, interface_name))
default_gw, gw_ip, interface_name))
def _get_ipv6_lladdr(self, mac_addr):
return '%s/64' % netaddr.EUI(mac_addr).ipv6_link_local()

View File

@ -99,11 +99,18 @@ class L3AgentTestFramework(base.BaseOVSLinuxTestCase):
return agent
def generate_router_info(self, enable_ha):
return test_l3_agent.prepare_router_data(enable_snat=True,
enable_floating_ip=True,
def generate_router_info(self, enable_ha, ip_version=4, extra_routes=True,
enable_fip=True, enable_snat=True):
if ip_version == 6:
enable_snat = False
enable_fip = False
extra_routes = False
return test_l3_agent.prepare_router_data(ip_version=ip_version,
enable_snat=enable_snat,
enable_floating_ip=enable_fip,
enable_ha=enable_ha,
extra_routes=True)
extra_routes=extra_routes)
def manage_router(self, agent, router):
self.addCleanup(self._delete_router, agent, router['id'])
@ -341,6 +348,9 @@ class L3AgentTestCase(L3AgentTestFramework):
with testtools.ExpectedException(RuntimeError):
netcat.test_connectivity()
def test_ipv6_ha_router_lifecycle(self):
self._router_lifecycle(enable_ha=True, ip_version=6)
def test_keepalived_configuration(self):
router_info = self.generate_router_info(enable_ha=True)
router = self.manage_router(self.agent, router_info)
@ -380,8 +390,8 @@ class L3AgentTestCase(L3AgentTestFramework):
(new_external_device_ip, external_device_name),
new_config)
def _router_lifecycle(self, enable_ha):
router_info = self.generate_router_info(enable_ha)
def _router_lifecycle(self, enable_ha, ip_version=4):
router_info = self.generate_router_info(enable_ha, ip_version)
router = self.manage_router(self.agent, router_info)
if enable_ha:
@ -406,12 +416,17 @@ class L3AgentTestCase(L3AgentTestFramework):
self.assertTrue(self._metadata_proxy_exists(self.agent.conf, router))
self._assert_internal_devices(router)
self._assert_external_device(router)
self._assert_gateway(router)
self.assertTrue(self._floating_ips_configured(router))
self._assert_snat_chains(router)
self._assert_floating_ip_chains(router)
if ip_version == 4:
# Note(SridharG): enable the assert_gateway for IPv6 once
# keepalived on Ubuntu14.04 (i.e., check-neutron-dsvm-functional
# platform) is updated to 1.2.10 (or above).
# For more details: https://review.openstack.org/#/c/151284/
self._assert_gateway(router)
self.assertTrue(self._floating_ips_configured(router))
self._assert_snat_chains(router)
self._assert_floating_ip_chains(router)
self._assert_extra_routes(router)
self._assert_metadata_chains(router)
self._assert_extra_routes(router)
if enable_ha:
self._assert_ha_device(router)

View File

@ -64,9 +64,9 @@ def router_append_interface(router, count=1, ip_version=4, ra_mode=None,
cidr_pool = '35.4.%i.0/24'
gw_pool = '35.4.%i.1'
elif ip_version == 6:
ip_pool = 'fd01:%x::6'
cidr_pool = 'fd01:%x::/64'
gw_pool = 'fd01:%x::1'
ip_pool = 'fd01:%x:1::6'
cidr_pool = 'fd01:%x:1::/64'
gw_pool = 'fd01:%x:1::1'
else:
raise ValueError("Invalid ip_version: %s" % ip_version)