Merge "ofagent: Ignore unknown l2pop entry removals"

This commit is contained in:
Jenkins 2014-10-20 17:17:37 +00:00 committed by Gerrit Code Review
commit b40fb9dafe
2 changed files with 23 additions and 1 deletions

View File

@ -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]

View File

@ -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},