]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Check that router info is set before calling _update_arp_entry
authorCarl Baldwin <carl.baldwin@hp.com>
Tue, 29 Jul 2014 20:34:01 +0000 (20:34 +0000)
committerCarl Baldwin <carl.baldwin@hp.com>
Tue, 29 Jul 2014 20:34:01 +0000 (20:34 +0000)
Change-Id: Ieec6fb01a7d48bed1042114c27527fe6ec2555e0
Closes-bug: #1350028

neutron/agent/l3_agent.py
neutron/tests/unit/test_l3_agent.py

index 9d7ec1219515fc501840afcf76db30ca24689b0a..cf66df7b1b7e401493d1c0b35a8b7930652c30c5 100644 (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."""
index 4e229bb2d5fe5d0391fd24552ad5f75a3df83a32..832da25905a4c3625fba674216588ffeece8bd41 100644 (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)