Merge "Adds support to provide the csum option for the OVS tunnels"

This commit is contained in:
Jenkins 2015-09-06 22:14:46 +00:00 committed by Gerrit Code Review
commit fee48aa108
7 changed files with 77 additions and 6 deletions

View File

@ -163,6 +163,12 @@
# #
# extensions = # 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] [securitygroup]
# Firewall driver for realizing neutron security group function. # Firewall driver for realizing neutron security group function.
# firewall_driver = neutron.agent.firewall.NoopFirewallDriver # firewall_driver = neutron.agent.firewall.NoopFirewallDriver

View File

@ -299,7 +299,8 @@ class OVSBridge(BaseOVS):
def add_tunnel_port(self, port_name, remote_ip, local_ip, def add_tunnel_port(self, port_name, remote_ip, local_ip,
tunnel_type=p_const.TYPE_GRE, tunnel_type=p_const.TYPE_GRE,
vxlan_udp_port=p_const.VXLAN_UDP_PORT, vxlan_udp_port=p_const.VXLAN_UDP_PORT,
dont_fragment=True): dont_fragment=True,
tunnel_csum=False):
attrs = [('type', tunnel_type)] attrs = [('type', tunnel_type)]
# TODO(twilson) This is an OrderedDict solely to make a test happy # TODO(twilson) This is an OrderedDict solely to make a test happy
options = collections.OrderedDict() options = collections.OrderedDict()
@ -314,6 +315,8 @@ class OVSBridge(BaseOVS):
options['local_ip'] = local_ip options['local_ip'] = local_ip
options['in_key'] = 'flow' options['in_key'] = 'flow'
options['out_key'] = 'flow' options['out_key'] = 'flow'
if tunnel_csum:
options['csum'] = str(tunnel_csum).lower()
attrs.append(('options', options)) attrs.append(('options', options))
return self.add_port(port_name, *attrs) return self.add_port(port_name, *attrs)

View File

@ -119,7 +119,11 @@ agent_opts = [
"timeout won't be changed")), "timeout won't be changed")),
cfg.BoolOpt('drop_flows_on_start', default=False, cfg.BoolOpt('drop_flows_on_start', default=False,
help=_("Reset flow table on start. Setting this to True will " 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."))
] ]

View File

@ -254,6 +254,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.tunnel_count = 0 self.tunnel_count = 0
self.vxlan_udp_port = self.conf.AGENT.vxlan_udp_port self.vxlan_udp_port = self.conf.AGENT.vxlan_udp_port
self.dont_fragment = self.conf.AGENT.dont_fragment self.dont_fragment = self.conf.AGENT.dont_fragment
self.tunnel_csum = cfg.CONF.AGENT.tunnel_csum
self.tun_br = None self.tun_br = None
self.patch_int_ofport = constants.OFPORT_INVALID self.patch_int_ofport = constants.OFPORT_INVALID
self.patch_tun_ofport = constants.OFPORT_INVALID self.patch_tun_ofport = constants.OFPORT_INVALID
@ -1243,7 +1244,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.local_ip, self.local_ip,
tunnel_type, tunnel_type,
self.vxlan_udp_port, self.vxlan_udp_port,
self.dont_fragment) self.dont_fragment,
self.tunnel_csum)
if ofport == ovs_lib.INVALID_OFPORT: if ofport == ovs_lib.INVALID_OFPORT:
LOG.error(_LE("Failed to set-up %(type)s tunnel port to %(ip)s"), LOG.error(_LE("Failed to set-up %(type)s tunnel port to %(ip)s"),
{'type': tunnel_type, 'ip': remote_ip}) {'type': tunnel_type, 'ip': remote_ip})

View File

@ -400,6 +400,40 @@ class OVS_Lib_Test(base.BaseTestCase):
tools.verify_mock_calls(self.execute, expected_calls_and_values) 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): def _test_get_vif_ports(self, is_xen=False):
pname = "tap99" pname = "tap99"
ofport = 6 ofport = 6

View File

@ -1169,7 +1169,8 @@ class TestOvsNeutronAgent(object):
self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE) self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE)
add_tunnel_port_fn.assert_called_once_with( add_tunnel_port_fn.assert_called_once_with(
'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE, '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( log_error_fn.assert_called_once_with(
_("Failed to set-up %(type)s tunnel port to %(ip)s"), _("Failed to set-up %(type)s tunnel port to %(ip)s"),
{'type': p_const.TYPE_GRE, 'ip': 'remote_ip'}) {'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,\ return_value=ovs_lib.INVALID_OFPORT) as add_tunnel_port_fn,\
mock.patch.object(self.mod_agent.LOG, 'error') as log_error_fn: mock.patch.object(self.mod_agent.LOG, 'error') as log_error_fn:
self.agent.dont_fragment = False self.agent.dont_fragment = False
self.agent.tunnel_csum = False
ofport = self.agent._setup_tunnel_port( ofport = self.agent._setup_tunnel_port(
self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE) self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE)
add_tunnel_port_fn.assert_called_once_with( add_tunnel_port_fn.assert_called_once_with(
'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE, '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( log_error_fn.assert_called_once_with(
_("Failed to set-up %(type)s tunnel port to %(ip)s"), _("Failed to set-up %(type)s tunnel port to %(ip)s"),
{'type': p_const.TYPE_GRE, 'ip': 'remote_ip'}) {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'})

View File

@ -484,7 +484,7 @@ class TunnelTest(object):
self.mock_tun_bridge.add_tunnel_port.return_value = tunnel_port self.mock_tun_bridge.add_tunnel_port.return_value = tunnel_port
self.mock_tun_bridge_expected += [ self.mock_tun_bridge_expected += [
mock.call.add_tunnel_port('gre-0a000a01', '10.0.10.1', '10.0.0.1', 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), mock.call.setup_tunnel_port('gre', tunnel_port),
] ]