Merge "Do not run "ovs-ofctl add-flow" with an invalid in_port"
This commit is contained in:
commit
bc18247313
@ -862,7 +862,13 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
||||
self.local_ip,
|
||||
tunnel_type,
|
||||
self.vxlan_udp_port)
|
||||
if ofport < 0:
|
||||
ofport_int = -1
|
||||
try:
|
||||
ofport_int = int(ofport)
|
||||
except (TypeError, ValueError):
|
||||
LOG.exception(_("ofport should have a value that can be "
|
||||
"interpreted as an integer"))
|
||||
if ofport_int < 0:
|
||||
LOG.error(_("Failed to set-up %(type)s tunnel port to %(ip)s"),
|
||||
{'type': tunnel_type, 'ip': remote_ip})
|
||||
return 0
|
||||
|
@ -591,6 +591,42 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
||||
mock_get_pm.assert_called_with(False, 'sudo')
|
||||
mock_loop.called_once()
|
||||
|
||||
def test_setup_tunnel_port_error_negative(self):
|
||||
with contextlib.nested(
|
||||
mock.patch.object(self.agent.tun_br, 'add_tunnel_port',
|
||||
return_value='-1'),
|
||||
mock.patch.object(ovs_neutron_agent.LOG, 'error')
|
||||
) as (add_tunnel_port_fn, log_error_fn):
|
||||
ofport = self.agent.setup_tunnel_port(
|
||||
'gre-1', 'remote_ip', constants.TYPE_GRE)
|
||||
add_tunnel_port_fn.assert_called_once_with(
|
||||
'gre-1', 'remote_ip', self.agent.local_ip, constants.TYPE_GRE,
|
||||
self.agent.vxlan_udp_port)
|
||||
log_error_fn.assert_called_once_with(
|
||||
_("Failed to set-up %(type)s tunnel port to %(ip)s"),
|
||||
{'type': constants.TYPE_GRE, 'ip': 'remote_ip'})
|
||||
self.assertEqual(ofport, 0)
|
||||
|
||||
def test_setup_tunnel_port_error_not_int(self):
|
||||
with contextlib.nested(
|
||||
mock.patch.object(self.agent.tun_br, 'add_tunnel_port',
|
||||
return_value=None),
|
||||
mock.patch.object(ovs_neutron_agent.LOG, 'exception'),
|
||||
mock.patch.object(ovs_neutron_agent.LOG, 'error')
|
||||
) as (add_tunnel_port_fn, log_exc_fn, log_error_fn):
|
||||
ofport = self.agent.setup_tunnel_port(
|
||||
'gre-1', 'remote_ip', constants.TYPE_GRE)
|
||||
add_tunnel_port_fn.assert_called_once_with(
|
||||
'gre-1', 'remote_ip', self.agent.local_ip, constants.TYPE_GRE,
|
||||
self.agent.vxlan_udp_port)
|
||||
log_exc_fn.assert_called_once_with(
|
||||
_("ofport should have a value that can be "
|
||||
"interpreted as an integer"))
|
||||
log_error_fn.assert_called_once_with(
|
||||
_("Failed to set-up %(type)s tunnel port to %(ip)s"),
|
||||
{'type': constants.TYPE_GRE, 'ip': 'remote_ip'})
|
||||
self.assertEqual(ofport, 0)
|
||||
|
||||
|
||||
class AncillaryBridgesTest(base.BaseTestCase):
|
||||
|
||||
|
@ -401,7 +401,9 @@ class TunnelTest(base.BaseTestCase):
|
||||
|
||||
def test_tunnel_update(self):
|
||||
self.mock_tun_bridge.add_tunnel_port('gre-1', '10.0.10.1', '10.0.0.1',
|
||||
'gre', 4789)
|
||||
'gre', 4789).AndReturn('9999')
|
||||
self.mock_tun_bridge.add_flow(actions='resubmit(,2)', in_port='9999',
|
||||
priority=1)
|
||||
self.mox.ReplayAll()
|
||||
a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
|
||||
self.TUN_BRIDGE,
|
||||
|
Loading…
Reference in New Issue
Block a user