]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Validate when DVR enabled, l2_pop is also enabled
authorGal Sagie <gal.sagie@huawei.com>
Wed, 18 Mar 2015 06:36:29 +0000 (08:36 +0200)
committerRomil Gupta <romilg@hp.com>
Fri, 20 Mar 2015 10:01:12 +0000 (03:01 -0700)
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 <romilg@hp.com>
neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py

index eccfb59d8ce4ae3289cf15964b44b9837a11a436..532aa17807b5529299e78fd3b631cd4bf1f32ea4 100644 (file)
@@ -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))
index b371d275b9b17624cbf3c8a79d6461fed040932f..e2893a27e3fa50b8638a350e45def91fa10f48f9 100644 (file)
@@ -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)