Permalink
Browse files

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 a549f30)
  • Loading branch information...
Clayton O'Neill authored and claytono committed Mar 24, 2016
1 parent 8ad9327 commit a46e00817a65ac7a55e47f4e4b0b89596d776f8d
@@ -1147,12 +1147,19 @@ def setup_physical_bridges(self, bridge_mappings):
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
@@ -106,7 +106,7 @@ def test_assert_pings_during_br_int_setup_not_lost(self):
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 @@ def test_assert_patch_port_ofports_dont_change(self):
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.
@@ -841,6 +841,8 @@ def test_setup_physical_bridges(self):
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 @@ def test_setup_physical_bridges(self):
# 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,15 +925,19 @@ def test_setup_physical_bridges_change_from_veth_to_patch_conf(self):
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'),
mock.call.phys_br.setup_controllers(mock.ANY),
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'),
@@ -127,6 +127,8 @@ def lookup_br(br_name, *args, **kwargs):
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 @@ def lookup_br(br_name, *args, **kwargs):
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 @@ def _define_expected_calls(self, arp_responder=False):
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),
]

0 comments on commit a46e008

Please sign in to comment.