From 79ad8492d76dd1534ea08419143f2ee2e05f13ed Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Tue, 8 Nov 2016 11:24:59 -0500 Subject: [PATCH] Don't pass config object to send_ip_addr_adv_notif() Previously, the function consumed a config object and picked only a single option send_arp_for_ha from that object. This patch replaces the config object with count itself in order to be able to send gratuitous ARPs not relying on a single config option. As per http://codesearch.openstack.org, this function is not called in any other stadium project. The send_arp_for_ha option is deprecated as for Ocata. Related-bug: 1639315 Change-Id: I6efc539a969bebb4fd969e1648a787bf7dc9cd0b --- neutron/agent/l3/dvr_fip_ns.py | 2 +- neutron/agent/l3/dvr_local_router.py | 2 +- neutron/agent/l3/legacy_router.py | 2 +- neutron/agent/l3/router_info.py | 4 ++-- neutron/agent/linux/ip_lib.py | 9 ++++++--- neutron/tests/unit/agent/l3/test_legacy_router.py | 2 +- neutron/tests/unit/agent/linux/test_ip_lib.py | 8 ++------ 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/neutron/agent/l3/dvr_fip_ns.py b/neutron/agent/l3/dvr_fip_ns.py index baff7a21ca1..51aaa97ebcf 100644 --- a/neutron/agent/l3/dvr_fip_ns.py +++ b/neutron/agent/l3/dvr_fip_ns.py @@ -226,7 +226,7 @@ class FipNamespace(namespaces.Namespace): ip_lib.send_ip_addr_adv_notif(ns_name, interface_name, fixed_ip['ip_address'], - self.agent_conf) + self.agent_conf.send_arp_for_ha) ipd = ip_lib.IPDevice(interface_name, namespace=ns_name) for subnet in agent_gateway_port['subnets']: diff --git a/neutron/agent/l3/dvr_local_router.py b/neutron/agent/l3/dvr_local_router.py index 08afb8b6d92..f1b5eac2f32 100644 --- a/neutron/agent/l3/dvr_local_router.py +++ b/neutron/agent/l3/dvr_local_router.py @@ -103,7 +103,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase): ip_lib.send_ip_addr_adv_notif(fip_ns_name, interface_name, floating_ip, - self.agent_conf) + self.agent_conf.send_arp_for_ha) # update internal structures self.dist_fip_count = self.dist_fip_count + 1 diff --git a/neutron/agent/l3/legacy_router.py b/neutron/agent/l3/legacy_router.py index 6c24f345f3a..a6c7d3a48a3 100644 --- a/neutron/agent/l3/legacy_router.py +++ b/neutron/agent/l3/legacy_router.py @@ -28,5 +28,5 @@ class LegacyRouter(router.RouterInfo): ip_lib.send_ip_addr_adv_notif(self.ns_name, interface_name, fip['floating_ip_address'], - self.agent_conf) + self.agent_conf.send_arp_for_ha) return lib_constants.FLOATINGIP_STATUS_ACTIVE diff --git a/neutron/agent/l3/router_info.py b/neutron/agent/l3/router_info.py index 6f65061db16..f432d5c2f45 100644 --- a/neutron/agent/l3/router_info.py +++ b/neutron/agent/l3/router_info.py @@ -410,7 +410,7 @@ class RouterInfo(object): ip_lib.send_ip_addr_adv_notif(ns_name, interface_name, fixed_ip['ip_address'], - self.agent_conf) + self.agent_conf.send_arp_for_ha) def internal_network_added(self, port): network_id = port['network_id'] @@ -663,7 +663,7 @@ class RouterInfo(object): ip_lib.send_ip_addr_adv_notif(ns_name, interface_name, fixed_ip['ip_address'], - self.agent_conf) + self.agent_conf.send_arp_for_ha) def is_v6_gateway_set(self, gateway_ips): """Check to see if list of gateway_ips has an IPv6 gateway. diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index e3cbe6b94c5..dc61448fcb5 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -1022,7 +1022,7 @@ def _arping(ns_name, iface_name, address, count): 'ns': ns_name}) -def send_ip_addr_adv_notif(ns_name, iface_name, address, config): +def send_ip_addr_adv_notif(ns_name, iface_name, address, count=3): """Send advance notification of an IP address assignment. If the address is in the IPv4 family, send gratuitous ARP. @@ -1032,9 +1032,12 @@ def send_ip_addr_adv_notif(ns_name, iface_name, address, config): Address Discovery (DAD), and (for stateless addresses) router advertisements (RAs) are sufficient for address resolution and duplicate address detection. - """ - count = config.send_arp_for_ha + :param ns_name: Namespace name which GARPs are gonna be sent from. + :param iface_name: Name of interface which GARPs are gonna be sent from. + :param address: Advertised IP address. + :param count: (Optional) How many GARPs are gonna be sent. Default is 3. + """ def arping(): _arping(ns_name, iface_name, address, count) diff --git a/neutron/tests/unit/agent/l3/test_legacy_router.py b/neutron/tests/unit/agent/l3/test_legacy_router.py index 52df74ddd0f..77f41df4cbd 100644 --- a/neutron/tests/unit/agent/l3/test_legacy_router.py +++ b/neutron/tests/unit/agent/l3/test_legacy_router.py @@ -100,7 +100,7 @@ class TestAddFloatingIpWithMockGarp(BasicRouterTestCaseFramework): ri.ns_name, mock.sentinel.interface_name, ip, - self.agent_conf) + self.agent_conf.send_arp_for_ha) self.assertEqual(lib_constants.FLOATINGIP_STATUS_ACTIVE, result) def test_add_floating_ip_error(self, send_ip_addr_adv_notif): diff --git a/neutron/tests/unit/agent/linux/test_ip_lib.py b/neutron/tests/unit/agent/linux/test_ip_lib.py index 20f1cce70ca..ac96964351e 100644 --- a/neutron/tests/unit/agent/linux/test_ip_lib.py +++ b/neutron/tests/unit/agent/linux/test_ip_lib.py @@ -1340,12 +1340,10 @@ class TestArpPing(TestIPCmdBase): spawn_n.side_effect = lambda f: f() ARPING_COUNT = 3 address = '20.0.0.1' - config = mock.Mock() - config.send_arp_for_ha = ARPING_COUNT ip_lib.send_ip_addr_adv_notif(mock.sentinel.ns_name, mock.sentinel.iface_name, address, - config) + ARPING_COUNT) self.assertTrue(spawn_n.called) mIPWrapper.assert_called_once_with(namespace=mock.sentinel.ns_name) @@ -1364,12 +1362,10 @@ class TestArpPing(TestIPCmdBase): @mock.patch('eventlet.spawn_n') def test_no_ipv6_addr_notif(self, spawn_n): ipv6_addr = 'fd00::1' - config = mock.Mock() - config.send_arp_for_ha = 3 ip_lib.send_ip_addr_adv_notif(mock.sentinel.ns_name, mock.sentinel.iface_name, ipv6_addr, - config) + 3) self.assertFalse(spawn_n.called)