]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
ip_lib: Add flush() command to IpNeigh to clean arp cache
authorJakub Libosvar <libosvar@redhat.com>
Tue, 16 Jun 2015 15:29:17 +0000 (15:29 +0000)
committerJakub Libosvar <libosvar@redhat.com>
Sat, 27 Jun 2015 16:28:18 +0000 (16:28 +0000)
Change-Id: I938974e3d67373cd18d8a9c6538f1f8b2d09e965

neutron/agent/linux/ip_lib.py
neutron/tests/unit/agent/linux/test_ip_lib.py

index e6d20c78348d843c5bb8bf4cf7d54be4e6dd212e..890444a01f9d154480582c33536b530197d3ea0d 100644 (file)
@@ -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'
index 4ed06426119604c326318c8e4a0c766b223b93a3..42c3befa3c9ae684275d48f059a380887f7951a2 100644 (file)
@@ -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')