From: YAMAMOTO Takashi Date: Fri, 15 Aug 2014 05:20:00 +0000 (+0900) Subject: ofagent: Ignore unknown l2pop entry removals X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=dd5c73450da908d95724e20eb3be09bc936cb551;p=openstack-build%2Fneutron-build.git ofagent: Ignore unknown l2pop entry removals l2pop can send us entry removal without the corresponding addition. Gracefully ignore it instead of crashing. Closes-Bug: #1357198 Change-Id: I5a0cc44ba62faf15d6fe3730a9532a3826647820 --- diff --git a/neutron/plugins/ofagent/agent/arp_lib.py b/neutron/plugins/ofagent/agent/arp_lib.py index c83e94352..aeae8f358 100644 --- a/neutron/plugins/ofagent/agent/arp_lib.py +++ b/neutron/plugins/ofagent/agent/arp_lib.py @@ -120,7 +120,12 @@ class ArpLib(object): @log.log def del_arp_table_entry(self, network, ip): - del self._arp_tbl[network][ip] + if network not in self._arp_tbl: + LOG.debug("removal of unknown network %s", network) + return + if self._arp_tbl[network].pop(ip, None) is None: + LOG.debug("removal of unknown ip %s", ip) + return if not self._arp_tbl[network]: del self._arp_tbl[network] diff --git a/neutron/tests/unit/ofagent/test_arp_lib.py b/neutron/tests/unit/ofagent/test_arp_lib.py index a0b0dcdaf..45c119362 100644 --- a/neutron/tests/unit/ofagent/test_arp_lib.py +++ b/neutron/tests/unit/ofagent/test_arp_lib.py @@ -16,6 +16,7 @@ import collections import contextlib +import copy import mock @@ -203,6 +204,22 @@ class TestArpLib(OFAAgentTestCase): self.arplib.del_arp_table_entry(self.nets[0].net, self.nets[0].ip) self.assertEqual(self.arplib._arp_tbl, {}) + def test_del_arp_table_entry_unknown_network(self): + self.arplib._arp_tbl = { + 100: {"192.0.2.1": "fa:16:3e:e2:37:37"}, + } + orig = copy.deepcopy(self.arplib._arp_tbl) + self.arplib.del_arp_table_entry(200, "192.0.2.1") + self.assertEqual(orig, self.arplib._arp_tbl) + + def test_del_arp_table_entry_unknown_ip(self): + self.arplib._arp_tbl = { + 100: {"192.0.2.1": "fa:16:3e:e2:37:37"}, + } + orig = copy.deepcopy(self.arplib._arp_tbl) + self.arplib.del_arp_table_entry(100, "192.0.2.9") + self.assertEqual(orig, self.arplib._arp_tbl) + def test_del_arp_table_entry_multiple_net(self): self.arplib._arp_tbl = { self.nets[0].net: {self.nets[0].ip: self.nets[0].mac},