From: Jakub Libosvar Date: Tue, 16 Jun 2015 15:29:17 +0000 (+0000) Subject: ip_lib: Add flush() command to IpNeigh to clean arp cache X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=b622e6538ae5a606c1bc9830a2afe816a92a2ca5;p=openstack-build%2Fneutron-build.git ip_lib: Add flush() command to IpNeigh to clean arp cache Change-Id: I938974e3d67373cd18d8a9c6538f1f8b2d09e965 --- diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index e6d20c783..890444a01 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -634,6 +634,17 @@ class IpNeighCommand(IpDeviceCommandBase): ('show', 'dev', self.name)) + def flush(self, ip_version, ip_address): + """Flush neighbour entries + + Given address entry is removed from neighbour cache (ARP or NDP). To + flush all entries pass string 'all' as an address. + + :param ip_version: Either 4 or 6 for IPv4 or IPv6 respectively + :param ip_address: The prefix selecting the neighbours to flush + """ + self._as_root([ip_version], ('flush', 'to', ip_address)) + class IpNetnsCommand(IpCommandBase): COMMAND = 'netns' diff --git a/neutron/tests/unit/agent/linux/test_ip_lib.py b/neutron/tests/unit/agent/linux/test_ip_lib.py index 4ed064261..42c3befa3 100644 --- a/neutron/tests/unit/agent/linux/test_ip_lib.py +++ b/neutron/tests/unit/agent/linux/test_ip_lib.py @@ -1031,6 +1031,10 @@ class TestIpNeighCommand(TestIPCmdBase): 'lladdr', 'cc:dd:ee:ff:ab:cd', 'dev', 'tap0')) + def test_flush(self): + self.neigh_cmd.flush(4, '192.168.0.1') + self._assert_sudo([4], ('flush', 'to', '192.168.0.1')) + class TestArpPing(TestIPCmdBase): @mock.patch.object(ip_lib, 'IPWrapper')