From 0ac6d5fbaed1859abe0847f3d33594df8807b0aa Mon Sep 17 00:00:00 2001 From: Yang Li Date: Fri, 12 Apr 2019 19:14:29 +0800 Subject: [PATCH] Don't add arp responder for non tunnel network port When the vlan and vxlan both exist in env, and l2population and arp_responder are enabled, if we update a port's ip address from vlan network, there will be arp responder related flows added into br-tun, this will cause too many arp reply for one arp request, and vm connections will be unnormal. Closes-Bug: #1824504 Change-Id: I1b6154b9433a9442d3e0118dedfa01c4a9b4740b (cherry picked from commit 5301ecf41b18e83abdc3c828cd64ce0111f9fcd1) --- .../plugins/ml2/drivers/l2pop/mech_driver.py | 7 +++++ .../ml2/drivers/l2pop/test_mech_driver.py | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py index eccd6f4148d..13ce261c7e8 100644 --- a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py +++ b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py @@ -120,6 +120,13 @@ class L2populationMechanismDriver(api.MechanismDriver): if not agent_host: return + # We should not add arp responder for non tunnel network type + port_context = context._plugin_context + agent = l2pop_db.get_agent_by_host(port_context, agent_host) + segment = context.bottom_bound_segment + if not self._validate_segment(segment, port['id'], agent): + return + agent_ip = l2pop_db.get_agent_ip_by_host(context._plugin_context, agent_host) diff --git a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py index 1e655f4e535..257f874d604 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py @@ -1087,6 +1087,35 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase): self.mock_fanout.assert_called_with( mock.ANY, 'add_fdb_entries', add_expected) + def test_fixed_ips_changed_vlan(self): + self._register_ml2_agents() + + with self.subnet(network=self._network2) as subnet: + host_arg = {portbindings.HOST_ID: HOST} + fixed_ips = [{'subnet_id': subnet['subnet']['id'], + 'ip_address': '10.0.0.2'}] + with self.port(subnet=subnet, cidr='10.0.0.0/24', + device_owner=DEVICE_OWNER_COMPUTE, + arg_list=(portbindings.HOST_ID,), + fixed_ips=fixed_ips, + **host_arg) as port: + p = port['port'] + + device = 'tap' + p['id'] + + self.callbacks.update_device_up(self.adminContext, + agent_id=HOST, + device=device) + + data = {'port': {'fixed_ips': [{'ip_address': '10.0.0.2'}, + {'ip_address': '10.0.0.10'}]}} + self.new_update_request('ports', data, p['id']) + l2pop_mech = l2pop_mech_driver.L2populationMechanismDriver() + l2pop_mech.L2PopulationAgentNotify = mock.Mock() + l2notify = l2pop_mech.L2PopulationAgentNotify + l2notify.update_fdb_entries = mock.Mock() + self.assertFalse(l2notify.update_fdb_entries.called) + def test_fixed_ips_changed(self): self._register_ml2_agents()