DVR: Fix router_update failure when agent restarts

Router update task fails when agent restarts with DVR routers
as it was failing adding an IP rule to the namespace.

The IP rule matching code was not finding a match for
a rule for an interface since we are not specifying an
IP address, but the resulting rule does have the "any" IP
address in its output, for example, 0.0.0.0/0.  Change
to always supply the IP address.

Conflicts:
    neutron/tests/functional/agent/l3/test_dvr_router.py

Change-Id: Ic2e80ebb59ac9e0e0063e5f6e69f3d66abe775a1
Closes-Bug: #1702790
(cherry picked from commit 7da955bf46)
This commit is contained in:
Swaminathan Vasudevan 2017-07-06 16:41:17 -07:00 committed by Brian Haley
parent 30ec219e87
commit fc9c146b13
2 changed files with 17 additions and 2 deletions

View File

@ -468,8 +468,11 @@ class IpRuleCommand(IpCommandBase):
ip_version = get_ip_version(ip)
# In case if we need to add in a rule based on incoming
# interface we don't need to pass in the ip.
if not kwargs.get('iif'):
# interface, pass the "any" IP address, for example, 0.0.0.0/0,
# else pass the given IP.
if kwargs.get('iif'):
kwargs.update({'from': constants.IP_ANY[ip_version]})
else:
kwargs.update({'from': ip})
canonical_kwargs = self._make_canonical(ip_version, kwargs)

View File

@ -724,6 +724,18 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self._assert_dvr_snat_gateway(router1)
self.assertTrue(self._namespace_exists(fip_ns))
def test_dvr_router_update_on_restarted_agent_sets_dist_fip_count(self):
self.agent.conf.agent_mode = 'dvr_snat'
router_info = self.generate_dvr_router_info()
router1 = self.manage_router(self.agent, router_info)
self.assertEqual(1, router1.dist_fip_count)
fip_ns = router1.fip_ns.get_name()
self.assertTrue(self._namespace_exists(fip_ns))
restarted_agent = neutron_l3_agent.L3NATAgentWithStateReport(
self.agent.host, self.agent.conf)
router_updated = self.manage_router(restarted_agent, router1.router)
self.assertEqual(1, router_updated.dist_fip_count)
def test_dvr_router_add_fips_on_restarted_agent(self):
self.agent.conf.agent_mode = 'dvr'
router_info = self.generate_dvr_router_info()