def create(self):
# TODO(Carl) Get this functionality from mlavelle's namespace baseclass
ip_wrapper_root = ip_lib.IPWrapper()
+ ip_wrapper_root.netns.execute(['sysctl',
+ '-w',
+ 'net.ipv4.ip_nonlocal_bind=1'],
+ run_as_root=True)
ip_wrapper = ip_wrapper_root.ensure_namespace(self.get_name())
ip_wrapper.netns.execute(['sysctl', '-w', 'net.ipv4.ip_forward=1'])
if self.use_ipv6:
interface_name = (
self.fip_ns.get_ext_device_name(
self.fip_ns.agent_gateway_port['id']))
- ip_lib.send_garp_for_proxyarp(fip_ns_name,
- interface_name,
- floating_ip,
- self.agent_conf.send_arp_for_ha)
+ ip_lib.send_gratuitous_arp(fip_ns_name,
+ interface_name,
+ floating_ip,
+ self.agent_conf.send_arp_for_ha)
# update internal structures
self.dist_fip_count = self.dist_fip_count + 1
eventlet.spawn_n(arping)
-def send_garp_for_proxyarp(ns_name, iface_name, address, count):
- """
- Send a gratuitous arp using given namespace, interface, and address
-
- This version should be used when proxy arp is in use since the interface
- won't actually have the address configured. We actually need to configure
- the address on the interface and then remove it when the proxy arp has been
- sent.
- """
- def arping_with_temporary_address():
- # Configure the address on the interface
- device = IPDevice(iface_name, namespace=ns_name)
- net = netaddr.IPNetwork(str(address))
- device.addr.add(str(net))
-
- _arping(ns_name, iface_name, address, count)
-
- # Delete the address from the interface
- device.addr.delete(str(net))
-
- if count > 0:
- eventlet.spawn_n(arping_with_temporary_address)
-
-
def add_namespace_to_cmd(cmd, namespace=None):
"""Add an optional namespace to the command."""
'neutron.agent.linux.ip_lib.send_gratuitous_arp')
self.send_arp = self.send_arp_p.start()
- self.send_arp_proxyarp_p = mock.patch(
- 'neutron.agent.linux.ip_lib.send_garp_for_proxyarp')
- self.send_arp_proxyarp = self.send_arp_proxyarp_p.start()
-
self.dvr_cls_p = mock.patch('neutron.agent.linux.interface.NullDriver')
driver_cls = self.dvr_cls_p.start()
self.mock_driver = mock.MagicMock()
self.assertEqual([{'host': mock.sentinel.myhost}], fips)
- @mock.patch.object(ip_lib, 'send_garp_for_proxyarp')
+ @mock.patch.object(ip_lib, 'send_gratuitous_arp')
@mock.patch.object(ip_lib, 'IPDevice')
@mock.patch.object(ip_lib, 'IPRule')
def test_floating_ip_added_dist(self, mIPRule, mIPDevice, mock_arp):
self._test_arping(
ip_lib.send_gratuitous_arp, '20.0.0.1', spawn_n, mIPWrapper)
- @mock.patch.object(ip_lib, 'IPDevice')
- @mock.patch.object(ip_lib, 'IPWrapper')
- @mock.patch('eventlet.spawn_n')
- def test_send_garp_for_proxy_arp(self, spawn_n, mIPWrapper, mIPDevice):
- addr = '20.0.0.1'
- ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name)
- mIPWrapper.reset_mock()
- device = mIPDevice(mock.sentinel.iface_name,
- namespace=mock.sentinel.ns_name)
- mIPDevice.reset_mock()
-
- # Check that the address was added to the interface before arping
- def check_added_address(*args, **kwargs):
- mIPDevice.assert_called_once_with(mock.sentinel.iface_name,
- namespace=mock.sentinel.ns_name)
- device.addr.add.assert_called_once_with(addr + '/32')
- self.assertFalse(device.addr.delete.called)
- device.addr.reset_mock()
-
- ip_wrapper.netns.execute.side_effect = check_added_address
-
- self._test_arping(
- ip_lib.send_garp_for_proxyarp, addr, spawn_n, mIPWrapper)
-
- # Test that the address was removed after arping
- device = mIPDevice(mock.sentinel.iface_name,
- namespace=mock.sentinel.ns_name)
- device.addr.delete.assert_called_once_with(addr + '/32')
-
- # If this was called then check_added_address probably had a assert
- self.assertFalse(device.addr.add.called)
-
class TestAddNamespaceToCmd(base.BaseTestCase):
def test_add_namespace_to_cmd_with_namespace(self):