From 45cbe9fd9ad3ee872a75e78d6af0618baac0f89d Mon Sep 17 00:00:00 2001 From: Gal Sagie Date: Wed, 18 Mar 2015 08:36:29 +0200 Subject: [PATCH] Validate when DVR enabled, l2_pop is also enabled The agent should fail to start when enable_distributed_routing = True and l2_population = False otherwise the router won't behave as expected. All the cross subnet traffic (between VMs of the same tenant) in DVR is now handled locally on the compute node using the router namespace. A Linux namespace is created for every virtual router, on each compute node that hosts VMs that are connected to that router. The local DVR performs the routing and replaces the source MAC address and the destination MAC address for every packet leaving the compute node. In order to do that correctly, the router must be populated with all the L2 addresses of the attached networks Change-Id: Id2b56d852eff4773a347f490b19ad9eefc86af9c Closes-Bug: #1417633 Co-Authored-By: Romil Gupta --- .../plugins/openvswitch/agent/ovs_neutron_agent.py | 8 ++++++++ .../tests/unit/openvswitch/test_ovs_neutron_agent.py | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index eccfb59d8..532aa1780 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -183,6 +183,9 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, 'agent_type': q_const.AGENT_TYPE_OVS, 'start_flag': True} + # Validate agent configurations + self._check_agent_configurations() + # Keep track of int_br's device count for use by _report_state() self.int_br_device_count = 0 @@ -1555,6 +1558,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, self.dvr_plugin_rpc, self.state_rpc): rpc_api.client.timeout = timeout + def _check_agent_configurations(self): + if self.enable_distributed_routing and not self.l2_pop: + raise ValueError(_("DVR cannot be enabled without " + "L2 population.")) + def _ofport_set_to_str(ofport_set): return ",".join(map(str, ofport_set)) diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index b371d275b..e2893a27e 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -167,6 +167,17 @@ class TestOvsNeutronAgent(base.BaseTestCase): self.assertFalse(set_ovs_db_func.called) self.assertFalse(delete_flows_func.called) + def test_check_agent_configurations_raises(self): + self.agent.enable_distributed_routing = True + self.agent.l2_pop = False + self.assertRaises(ValueError, + self.agent._check_agent_configurations) + + def test_check_agent_configurations(self): + self.agent.enable_distributed_routing = True + self.agent.l2_pop = True + self.assertIsNone(self.agent._check_agent_configurations()) + def test_port_bound_deletes_flows_for_valid_ofport(self): self._mock_port_bound(ofport=1, new_local_vlan=1) -- 2.45.2