]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
GRE tunnels should include local_ip.
authorAdin Scannell <adin@scannell.ca>
Mon, 27 May 2013 17:21:42 +0000 (13:21 -0400)
committerAdin Scannell <adin@scannell.ca>
Thu, 18 Jul 2013 14:38:58 +0000 (10:38 -0400)
This addresses the issue of having one or more multi-homed host.

Because you may only specify one local IP for a quantum agent, and
other hosts could be routed across different subnets (even for small
installations, for various reasons), it's important to also specify
the used local_ip when setting up the GRE tunnels. As long as the
address is routable on both ends, this will work. If the local_ip is
not specified, then traffic will mysteriously be dropped on one end
where the IP does not match the expected IP in the GRE tunnel.

Bug: https://bugs.launchpad.net/quantum/+bug/1184696

Change-Id: I5d612bf9e4f6652af8b155cdd1748d73ac4539ff
Signed-off-by: Adin Scannell <adin@scannell.ca>
neutron/agent/linux/ovs_lib.py
neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/openvswitch/test_ovs_lib.py
neutron/tests/unit/openvswitch/test_ovs_tunnel.py

index 491dd1969ed28eca64808a066be678b75d5fb122..9da39b0149d2d2ad10bccf703b6fa66c0810932f 100644 (file)
@@ -165,7 +165,7 @@ class OVSBridge:
         flow_str = ",".join(flow_expr_arr)
         self.run_ofctl("del-flows", [flow_str])
 
-    def add_tunnel_port(self, port_name, remote_ip,
+    def add_tunnel_port(self, port_name, remote_ip, local_ip,
                         tunnel_type=constants.TYPE_GRE,
                         vxlan_udp_port=constants.VXLAN_UDP_PORT):
         self.run_vsctl(["add-port", self.br_name, port_name])
@@ -178,6 +178,8 @@ class OVSBridge:
                                       vxlan_udp_port)
         self.set_db_attribute("Interface", port_name, "options:remote_ip",
                               remote_ip)
+        self.set_db_attribute("Interface", port_name, "options:local_ip",
+                              local_ip)
         self.set_db_attribute("Interface", port_name, "options:in_key", "flow")
         self.set_db_attribute("Interface", port_name, "options:out_key",
                               "flow")
index acc27e66b4f46483c609644b885667c7d29ada0c..4c2d31da36926563ae2524672099289d6481371b 100644 (file)
@@ -302,8 +302,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
         if tunnel_ip == self.local_ip:
             return
         tun_name = '%s-%s' % (tunnel_type, tunnel_id)
-        self.tun_br.add_tunnel_port(tun_name, tunnel_ip, tunnel_type,
-                                    self.vxlan_udp_port)
+        self.tun_br.add_tunnel_port(tun_name, tunnel_ip, self.local_ip,
+                                    tunnel_type, self.vxlan_udp_port)
 
     def create_rpc_dispatcher(self):
         '''Get the rpc dispatcher for this manager.
@@ -713,6 +713,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                         tun_name = '%s-%s' % (tunnel_type, tunnel_id)
                         self.tun_br.add_tunnel_port(tun_name,
                                                     tunnel['ip_address'],
+                                                    self.local_ip,
                                                     tunnel_type,
                                                     self.vxlan_udp_port)
         except Exception as e:
index 5e5c79cdcd0e9dd150cf6738dd29201428fc96d0..1b9486affe4a5a5bfdc279b3aa4d91d59dae4675 100644 (file)
@@ -185,7 +185,8 @@ class OVS_Lib_Test(base.BaseTestCase):
 
     def test_add_tunnel_port(self):
         pname = "tap99"
-        ip = "9.9.9.9"
+        local_ip = "1.1.1.1"
+        remote_ip = "9.9.9.9"
         ofport = "6"
 
         utils.execute(["ovs-vsctl", self.TO, "add-port",
@@ -193,7 +194,10 @@ class OVS_Lib_Test(base.BaseTestCase):
         utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
                        pname, "type=gre"], root_helper=self.root_helper)
         utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
-                       pname, "options:remote_ip=" + ip],
+                       pname, "options:remote_ip=" + remote_ip],
+                      root_helper=self.root_helper)
+        utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
+                       pname, "options:local_ip=" + local_ip],
                       root_helper=self.root_helper)
         utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
                        pname, "options:in_key=flow"],
@@ -206,7 +210,9 @@ class OVS_Lib_Test(base.BaseTestCase):
                       root_helper=self.root_helper).AndReturn(ofport)
         self.mox.ReplayAll()
 
-        self.assertEqual(self.br.add_tunnel_port(pname, ip), ofport)
+        self.assertEqual(
+            self.br.add_tunnel_port(pname, remote_ip, local_ip),
+            ofport)
         self.mox.VerifyAll()
 
     def test_add_patch_port(self):
index 6e3e9a527daa7c0fbac4937e51ba19596663362d..b1186e3301bb4fd99eb92d4d7c415cd1c41d6428 100644 (file)
@@ -346,7 +346,8 @@ class TunnelTest(base.BaseTestCase):
         self.mox.VerifyAll()
 
     def testTunnelUpdate(self):
-        self.mock_tun_bridge.add_tunnel_port('gre-1', '10.0.10.1', 'gre', 4789)
+        self.mock_tun_bridge.add_tunnel_port('gre-1', '10.0.10.1', '10.0.0.1',
+                                             'gre', 4789)
         self.mox.ReplayAll()
         a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                               self.TUN_BRIDGE,