Don't disconnect br-int from phys br if connected

When starting up, we don't want to delete the patch port between br-int
and the physical bridges. In liberty the br-int bridge was changed to
not tear down flows on startup, and  change
I9801b76829021c9a0e6358982e1136637634a521 will change the physical
bridges to not tear down flows also.

Without this patch the patch port is torn down and not reinstalled until
after the initial flows are set back up.

Partial-Bug: #1514056
Change-Id: I05bf5105a6f3acf6a313ce6799648a095cf8ec96
(cherry picked from commit a549f30fad)
This commit is contained in:
Clayton O'Neill 2016-03-24 15:28:21 +00:00 committed by Clayton O'Neill
parent 8ad932750b
commit a46e00817a
4 changed files with 43 additions and 8 deletions

View File

@ -1147,12 +1147,19 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
if int_type == 'veth':
self.int_br.delete_port(int_if_name)
br.delete_port(phys_if_name)
# Create patch ports without associating them in order to block
# untranslated traffic before association
int_ofport = self.int_br.add_patch_port(
int_if_name, constants.NONEXISTENT_PEER)
phys_ofport = br.add_patch_port(
phys_if_name, constants.NONEXISTENT_PEER)
# Setup int_br to physical bridge patches. If they already
# exist we leave them alone, otherwise we create them but don't
# connect them until after the drop rules are in place.
int_ofport = self.int_br.get_port_ofport(int_if_name)
if int_ofport == ovs_lib.INVALID_OFPORT:
int_ofport = self.int_br.add_patch_port(
int_if_name, constants.NONEXISTENT_PEER)
phys_ofport = br.get_port_ofport(phys_if_name)
if phys_ofport == ovs_lib.INVALID_OFPORT:
phys_ofport = br.add_patch_port(
phys_if_name, constants.NONEXISTENT_PEER)
self.int_ofports[physical_network] = int_ofport
self.phys_ofports[physical_network] = phys_ofport

View File

@ -106,7 +106,7 @@ class TestOVSAgent(base.OVSAgentTestFramework):
self.agent.setup_integration_br()
time.sleep(0.25)
def test_assert_patch_port_ofports_dont_change(self):
def test_assert_br_int_patch_port_ofports_dont_change(self):
# When the integration bridge is setup, it should reuse the existing
# patch ports between br-int and br-tun.
self.setup_agent_and_ports(port_dicts=[], create_tunnels=True)
@ -117,6 +117,19 @@ class TestOVSAgent(base.OVSAgentTestFramework):
self.assertEqual(patch_int_ofport_before, self.agent.patch_int_ofport)
self.assertEqual(patch_tun_ofport_before, self.agent.patch_tun_ofport)
def test_assert_br_phys_patch_port_ofports_dont_change(self):
# When the integration bridge is setup, it should reuse the existing
# patch ports between br-int and br-phys.
self.setup_agent_and_ports(port_dicts=[])
patch_int_ofport_before = self.agent.int_ofports['physnet']
patch_phys_ofport_before = self.agent.phys_ofports['physnet']
self.setup_agent_and_ports(port_dicts=[])
self.assertEqual(patch_int_ofport_before,
self.agent.int_ofports['physnet'])
self.assertEqual(patch_phys_ofport_before,
self.agent.phys_ofports['physnet'])
def test_noresync_after_port_gone(self):
'''This will test the scenario where a port is removed after listing
it but before getting vif info about it.

View File

@ -841,6 +841,8 @@ class TestOvsNeutronAgent(object):
parent.attach_mock(int_br, 'int_br')
phys_br.add_patch_port.return_value = "phy_ofport"
int_br.add_patch_port.return_value = "int_ofport"
phys_br.get_port_ofport.return_value = ovs_lib.INVALID_OFPORT
int_br.get_port_ofport.return_value = ovs_lib.INVALID_OFPORT
self.agent.setup_physical_bridges({"physnet1": "br-eth"})
expected_calls = [
mock.call.phys_br_cls('br-eth'),
@ -851,8 +853,10 @@ class TestOvsNeutronAgent(object):
# Have to use __getattr__ here to avoid mock._Call.__eq__
# method being called
mock.call.int_br.db_get_val().__getattr__('__eq__')('veth'),
mock.call.int_br.get_port_ofport('int-br-eth'),
mock.call.int_br.add_patch_port('int-br-eth',
constants.NONEXISTENT_PEER),
mock.call.phys_br.get_port_ofport('phy-br-eth'),
mock.call.phys_br.add_patch_port('phy-br-eth',
constants.NONEXISTENT_PEER),
mock.call.int_br.drop_port(in_port='int_ofport'),
@ -921,6 +925,8 @@ class TestOvsNeutronAgent(object):
parent.attach_mock(int_br, 'int_br')
phys_br.add_patch_port.return_value = "phy_ofport"
int_br.add_patch_port.return_value = "int_ofport"
phys_br.get_port_ofport.return_value = ovs_lib.INVALID_OFPORT
int_br.get_port_ofport.return_value = ovs_lib.INVALID_OFPORT
self.agent.setup_physical_bridges({"physnet1": "br-eth"})
expected_calls = [
mock.call.phys_br_cls('br-eth'),
@ -928,8 +934,10 @@ class TestOvsNeutronAgent(object):
mock.call.phys_br.setup_default_table(),
mock.call.int_br.delete_port('int-br-eth'),
mock.call.phys_br.delete_port('phy-br-eth'),
mock.call.int_br.get_port_ofport('int-br-eth'),
mock.call.int_br.add_patch_port('int-br-eth',
constants.NONEXISTENT_PEER),
mock.call.phys_br.get_port_ofport('phy-br-eth'),
mock.call.phys_br.add_patch_port('phy-br-eth',
constants.NONEXISTENT_PEER),
mock.call.int_br.drop_port(in_port='int_ofport'),

View File

@ -127,6 +127,8 @@ class TunnelTest(object):
self.mock_int_bridge.add_port.return_value = self.MAP_TUN_INT_OFPORT
self.mock_int_bridge.add_patch_port.side_effect = (
lambda tap, peer: self.ovs_int_ofports[tap])
self.mock_int_bridge.get_port_ofport.return_value = (
ovs_lib.INVALID_OFPORT)
self.mock_int_bridge.get_vif_ports.return_value = []
self.mock_int_bridge.get_ports_attributes.return_value = []
self.mock_int_bridge.db_get_val.return_value = {}
@ -137,6 +139,8 @@ class TunnelTest(object):
self.MAP_TUN_PHY_OFPORT)
self.mock_map_tun_bridge.add_patch_port.return_value = (
self.MAP_TUN_PHY_OFPORT)
self.mock_map_tun_bridge.get_port_ofport.return_value = (
ovs_lib.INVALID_OFPORT)
self.mock_tun_bridge = self.ovs_bridges[self.TUN_BRIDGE]
self.mock_tun_bridge.add_port.return_value = self.INT_OFPORT
@ -187,11 +191,14 @@ class TunnelTest(object):
self.mock_map_tun_bridge_expected = [
mock.call.setup_controllers(mock.ANY),
mock.call.setup_default_table(),
mock.call.get_port_ofport('phy-%s' % self.MAP_TUN_BRIDGE),
mock.call.add_patch_port('phy-%s' % self.MAP_TUN_BRIDGE,
constants.NONEXISTENT_PEER), ]
constants.NONEXISTENT_PEER),
]
self.mock_int_bridge_expected += [
mock.call.db_get_val('Interface', 'int-%s' % self.MAP_TUN_BRIDGE,
'type'),
mock.call.get_port_ofport('int-%s' % self.MAP_TUN_BRIDGE),
mock.call.add_patch_port('int-%s' % self.MAP_TUN_BRIDGE,
constants.NONEXISTENT_PEER),
]