Merge "Check that router info is set before calling _update_arp_entry"

This commit is contained in:
Jenkins 2014-07-30 00:37:51 +00:00 committed by Gerrit Code Review
commit edcfc40a30
2 changed files with 15 additions and 1 deletions

View File

@ -1478,7 +1478,8 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
mac = arp_table['mac_address']
subnet_id = arp_table['subnet_id']
ri = self.router_info.get(router_id)
self._update_arp_entry(ri, ip, mac, subnet_id, 'add')
if ri:
self._update_arp_entry(ri, ip, mac, subnet_id, 'add')
def del_arp_entry(self, context, payload):
"""Delete arp entry from router namespace. Called from RPC."""

View File

@ -624,6 +624,19 @@ class TestBasicRouterOperations(base.BaseTestCase):
self.mock_ip_dev.neigh.add.assert_called_once_with(
4, '1.7.23.11', '00:11:22:33:44:55')
def test_add_arp_entry_no_routerinfo(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
router = prepare_router_data(num_internal_ports=2)
subnet_id = _get_subnet_id(router[l3_constants.INTERFACE_KEY][0])
arp_table = {'ip_address': '1.7.23.11',
'mac_address': '00:11:22:33:44:55',
'subnet_id': subnet_id}
payload = {'arp_table': arp_table, 'router_id': router['id']}
agent._update_arp_entry = mock.Mock()
agent.add_arp_entry(None, payload)
self.assertFalse(agent._update_arp_entry.called)
def test_del_arp_entry(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
router = prepare_router_data(num_internal_ports=2)