]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Adds support to provide the csum option for the OVS tunnels
authorroot <mamtaprabhu@in.ibm.com>
Sat, 5 Sep 2015 17:47:41 +0000 (10:47 -0700)
committerroot <mamtaprabhu@in.ibm.com>
Sun, 6 Sep 2015 17:49:32 +0000 (10:49 -0700)
The new option for the ovs agent will enable to set/unset the
csum option for the vxlan/gre tunnels. The default is maintained as False.

Change-Id: I18dcd8946b585e70f8890a5c222ea37059c4a0c5
Implements: bp ovs-tunnel-csum-option
Closes-bug: #1492111

etc/neutron/plugins/ml2/openvswitch_agent.ini
neutron/agent/common/ovs_lib.py
neutron/plugins/ml2/drivers/openvswitch/agent/common/config.py
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/agent/common/test_ovs_lib.py
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py

index 323ed3d740a5605e324aeb46e96597acdf864758..664aa0a1f31db59f0d71cab52a4cad4f738947e8 100644 (file)
 #
 # extensions =
 
+# (BoolOpt) Set or un-set the checksum on outgoing IP packet
+# carrying GRE/VXLAN tunnel. The default value is False.
+#
+# tunnel_csum = False
+
+
 [securitygroup]
 # Firewall driver for realizing neutron security group function.
 # firewall_driver = neutron.agent.firewall.NoopFirewallDriver
index 76f0b4478d9e98cdd66cee98b44d7c669d5afbac..a7d6609763517c5e057e028a4404403ef2ecdcdd 100644 (file)
@@ -299,7 +299,8 @@ class OVSBridge(BaseOVS):
     def add_tunnel_port(self, port_name, remote_ip, local_ip,
                         tunnel_type=p_const.TYPE_GRE,
                         vxlan_udp_port=p_const.VXLAN_UDP_PORT,
-                        dont_fragment=True):
+                        dont_fragment=True,
+                        tunnel_csum=False):
         attrs = [('type', tunnel_type)]
         # TODO(twilson) This is an OrderedDict solely to make a test happy
         options = collections.OrderedDict()
@@ -314,6 +315,8 @@ class OVSBridge(BaseOVS):
         options['local_ip'] = local_ip
         options['in_key'] = 'flow'
         options['out_key'] = 'flow'
+        if tunnel_csum:
+            options['csum'] = str(tunnel_csum).lower()
         attrs.append(('options', options))
 
         return self.add_port(port_name, *attrs)
index 34685c53a2e8f2ed0172e6c7b6b975532831c03b..300c1a8369579564292ce2b5b0b20e6acf870cee 100644 (file)
@@ -119,7 +119,11 @@ agent_opts = [
                       "timeout won't be changed")),
     cfg.BoolOpt('drop_flows_on_start', default=False,
                 help=_("Reset flow table on start. Setting this to True will "
-                       "cause brief traffic interruption."))
+                       "cause brief traffic interruption.")),
+    cfg.BoolOpt('tunnel_csum', default=False,
+                help=_("Set or un-set the tunnel header checksum  on "
+                       "outgoing IP packet carrying GRE/VXLAN tunnel."))
+
 ]
 
 
index 26771f449bda470ba366eb4cd80947ef18125778..8d37423f797d1460eb90dd5fdf7e53a8eab9605c 100644 (file)
@@ -254,6 +254,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         self.tunnel_count = 0
         self.vxlan_udp_port = self.conf.AGENT.vxlan_udp_port
         self.dont_fragment = self.conf.AGENT.dont_fragment
+        self.tunnel_csum = cfg.CONF.AGENT.tunnel_csum
         self.tun_br = None
         self.patch_int_ofport = constants.OFPORT_INVALID
         self.patch_tun_ofport = constants.OFPORT_INVALID
@@ -1243,7 +1244,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
                                     self.local_ip,
                                     tunnel_type,
                                     self.vxlan_udp_port,
-                                    self.dont_fragment)
+                                    self.dont_fragment,
+                                    self.tunnel_csum)
         if ofport == ovs_lib.INVALID_OFPORT:
             LOG.error(_LE("Failed to set-up %(type)s tunnel port to %(ip)s"),
                       {'type': tunnel_type, 'ip': remote_ip})
index a599dc6bb2d7de385781e42e1c92d2dc9af6a549..8741dff79d29610f4d83e3576117f5493fbf2404 100644 (file)
@@ -400,6 +400,40 @@ class OVS_Lib_Test(base.BaseTestCase):
 
         tools.verify_mock_calls(self.execute, expected_calls_and_values)
 
+    def test_add_vxlan_csum_tunnel_port(self):
+        pname = "tap99"
+        local_ip = "1.1.1.1"
+        remote_ip = "9.9.9.9"
+        ofport = 6
+        vxlan_udp_port = "9999"
+        dont_fragment = True
+        tunnel_csum = True
+        command = ["--may-exist", "add-port", self.BR_NAME, pname]
+        command.extend(["--", "set", "Interface", pname])
+        command.extend(["type=" + constants.TYPE_VXLAN,
+                        "options:dst_port=" + vxlan_udp_port,
+                        "options:df_default=true",
+                        "options:remote_ip=" + remote_ip,
+                        "options:local_ip=" + local_ip,
+                        "options:in_key=flow",
+                        "options:out_key=flow",
+                        "options:csum=true"])
+        # Each element is a tuple of (expected mock call, return_value)
+        expected_calls_and_values = [
+            (self._vsctl_mock(*command), None),
+            (self._vsctl_mock("--columns=ofport", "list", "Interface", pname),
+             self._encode_ovs_json(['ofport'], [[ofport]])),
+        ]
+        tools.setup_mock_calls(self.execute, expected_calls_and_values)
+
+        self.assertEqual(
+            self.br.add_tunnel_port(pname, remote_ip, local_ip,
+                                    constants.TYPE_VXLAN, vxlan_udp_port,
+                                    dont_fragment, tunnel_csum),
+            ofport)
+
+        tools.verify_mock_calls(self.execute, expected_calls_and_values)
+
     def _test_get_vif_ports(self, is_xen=False):
         pname = "tap99"
         ofport = 6
index df6c8780df7307c511b33c6c95344acbc4683b92..c566001d2e600502d3822e37124571371606169b 100644 (file)
@@ -1169,7 +1169,8 @@ class TestOvsNeutronAgent(object):
                 self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE)
             add_tunnel_port_fn.assert_called_once_with(
                 'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE,
-                self.agent.vxlan_udp_port, self.agent.dont_fragment)
+                self.agent.vxlan_udp_port, self.agent.dont_fragment,
+                self.agent.tunnel_csum)
             log_error_fn.assert_called_once_with(
                 _("Failed to set-up %(type)s tunnel port to %(ip)s"),
                 {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'})
@@ -1182,11 +1183,32 @@ class TestOvsNeutronAgent(object):
             return_value=ovs_lib.INVALID_OFPORT) as add_tunnel_port_fn,\
                 mock.patch.object(self.mod_agent.LOG, 'error') as log_error_fn:
             self.agent.dont_fragment = False
+            self.agent.tunnel_csum = False
             ofport = self.agent._setup_tunnel_port(
                 self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE)
             add_tunnel_port_fn.assert_called_once_with(
                 'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE,
-                self.agent.vxlan_udp_port, self.agent.dont_fragment)
+                self.agent.vxlan_udp_port, self.agent.dont_fragment,
+                self.agent.tunnel_csum)
+            log_error_fn.assert_called_once_with(
+                _("Failed to set-up %(type)s tunnel port to %(ip)s"),
+                {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'})
+            self.assertEqual(ofport, 0)
+
+    def test_setup_tunnel_port_error_negative_tunnel_csum(self):
+        with mock.patch.object(
+            self.agent.tun_br,
+            'add_tunnel_port',
+            return_value=ovs_lib.INVALID_OFPORT) as add_tunnel_port_fn,\
+                mock.patch.object(self.mod_agent.LOG, 'error') as log_error_fn:
+            self.agent.dont_fragment = True
+            self.agent.tunnel_csum = True
+            ofport = self.agent._setup_tunnel_port(
+                self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE)
+            add_tunnel_port_fn.assert_called_once_with(
+                'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE,
+                self.agent.vxlan_udp_port, self.agent.dont_fragment,
+                self.agent.tunnel_csum)
             log_error_fn.assert_called_once_with(
                 _("Failed to set-up %(type)s tunnel port to %(ip)s"),
                 {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'})
index d2d1920a216db0d763a7930a3db76e2e56cc6366..3fef3f17de3b0347d86c2e03d954eb15fd76cf66 100644 (file)
@@ -484,7 +484,7 @@ class TunnelTest(object):
         self.mock_tun_bridge.add_tunnel_port.return_value = tunnel_port
         self.mock_tun_bridge_expected += [
             mock.call.add_tunnel_port('gre-0a000a01', '10.0.10.1', '10.0.0.1',
-                                      'gre', 4789, True),
+                                      'gre', 4789, True, False),
             mock.call.setup_tunnel_port('gre', tunnel_port),
         ]