diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py index ed29d80a071..c536f8f2c42 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -523,15 +523,25 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase): # inherit from the bridge its plugged into, which will be 1500 # at the time. See bug/1684326 for details. self._set_tap_mtu(tap_device_name, mtu) - # Check if device needs to be added to bridge - if not bridge_lib.BridgeDevice.get_interface_bridge( - tap_device_name): + # Avoid messing with plugging devices into a bridge that the agent + # does not own + if not device_owner.startswith(constants.DEVICE_OWNER_COMPUTE_PREFIX): + # Check if device needs to be added to bridge + if not bridge_lib.BridgeDevice.get_interface_bridge( + tap_device_name): + data = {'tap_device_name': tap_device_name, + 'bridge_name': bridge_name} + LOG.debug("Adding device %(tap_device_name)s to bridge " + "%(bridge_name)s", data) + if bridge_lib.BridgeDevice(bridge_name).addif(tap_device_name): + return False + else: data = {'tap_device_name': tap_device_name, + 'device_owner': device_owner, 'bridge_name': bridge_name} - LOG.debug("Adding device %(tap_device_name)s to bridge " - "%(bridge_name)s", data) - if bridge_lib.BridgeDevice(bridge_name).addif(tap_device_name): - return False + LOG.debug("Skip adding device %(tap_device_name)s to " + "%(bridge_name)s. It is owned by %(device_owner)s and " + "thus added elsewhere.", data) return True def _set_tap_mtu(self, tap_device_name, mtu): @@ -768,8 +778,8 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase): def get_agent_configurations(self): configurations = {'bridge_mappings': self.bridge_mappings, - 'interface_mappings': self.interface_mappings, - 'wires_compute_ports': True} + 'interface_mappings': self.interface_mappings + } if self.vxlan_mode != lconst.VXLAN_NONE: configurations['tunneling_ip'] = self.local_ip configurations['tunnel_types'] = [p_const.TYPE_VXLAN] diff --git a/neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py b/neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py index 49f544bc4d3..d22eca5e6fb 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py @@ -36,7 +36,7 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): sg_enabled = securitygroups_rpc.is_firewall_enabled() super(LinuxbridgeMechanismDriver, self).__init__( constants.AGENT_TYPE_LINUXBRIDGE, - portbindings.VIF_TYPE_TAP, + portbindings.VIF_TYPE_BRIDGE, {portbindings.CAP_PORT_FILTER: sg_enabled}) lb_qos_driver.register() @@ -50,13 +50,6 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): **agent['configurations'].get('bridge_mappings', {})) return mappings - def get_vif_type(self, context, agent, segment): - # TODO(kevinbenton): remove this function after we no longer support - # Ocata agents - if not agent['configurations'].get('wires_compute_ports'): - return portbindings.VIF_TYPE_BRIDGE - return self.vif_type - def check_vlan_transparency(self, context): """Linuxbridge driver vlan transparency support.""" return True diff --git a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py index 08b0fc92392..b44f4862930 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py @@ -527,6 +527,15 @@ class TestLinuxBridgeManager(base.BaseTestCase): p_const.TYPE_VLAN, "physnet1", None, "tap1", "foo", None) + def test_add_tap_interface_owner_compute(self): + with mock.patch.object(ip_lib, "device_exists"): + with mock.patch.object(self.lbm, "ensure_local_bridge"): + self.assertTrue(self.lbm.add_tap_interface("123", + p_const.TYPE_LOCAL, + "physnet1", None, + "tap1", + "compute:1", None)) + def _test_add_tap_interface(self, dev_owner_prefix): with mock.patch.object(ip_lib, "device_exists") as de_fn: de_fn.return_value = False diff --git a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/mech_driver/test_mech_linuxbridge.py b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/mech_driver/test_mech_linuxbridge.py index 466a39e6b72..27746f65117 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/mech_driver/test_mech_linuxbridge.py +++ b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/mech_driver/test_mech_linuxbridge.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import copy - from neutron_lib.api.definitions import portbindings from neutron_lib import constants @@ -24,14 +22,13 @@ from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base class LinuxbridgeMechanismBaseTestCase(base.AgentMechanismBaseTestCase): - VIF_TYPE = portbindings.VIF_TYPE_TAP + VIF_TYPE = portbindings.VIF_TYPE_BRIDGE CAP_PORT_FILTER = True AGENT_TYPE = constants.AGENT_TYPE_LINUXBRIDGE GOOD_MAPPINGS = {'fake_physical_network': 'fake_interface'} GOOD_TUNNEL_TYPES = ['gre', 'vxlan'] - GOOD_CONFIGS = {'wires_compute_ports': True, - 'interface_mappings': GOOD_MAPPINGS, + GOOD_CONFIGS = {'interface_mappings': GOOD_MAPPINGS, 'tunnel_types': GOOD_TUNNEL_TYPES} BAD_MAPPINGS = {'wrong_physical_network': 'wrong_interface'} @@ -81,11 +78,3 @@ class LinuxbridgeMechanismVlanTestCase(LinuxbridgeMechanismBaseTestCase, class LinuxbridgeMechanismGreTestCase(LinuxbridgeMechanismBaseTestCase, base.AgentMechanismGreTestCase): pass - - -class LegacyLinuxbridgeMechanismTestCase(LinuxbridgeMechanismBaseTestCase, - base.AgentMechanismVlanTestCase): - """An old agent doesn't wire compute ports so it needs VIF_TYPE_BRIDGE.""" - VIF_TYPE = portbindings.VIF_TYPE_BRIDGE - AGENTS = copy.deepcopy(LinuxbridgeMechanismBaseTestCase.AGENTS) - AGENTS[0]['configurations'].pop('wires_compute_ports') diff --git a/releasenotes/notes/linuxbridge_cgroups-5943d85adace4de0.yaml b/releasenotes/notes/linuxbridge_cgroups-5943d85adace4de0.yaml deleted file mode 100644 index 2c27cb8e759..00000000000 --- a/releasenotes/notes/linuxbridge_cgroups-5943d85adace4de0.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -prelude: > - The Linux Bridge driver now informs Nova to use the 'tap' interface type - to wire interfaces. This requires '/dev/net/tun' to be added to the - 'cgroup_device_acl' in 'qemu.conf' before upgrading. -upgrade: - - | - The Linux Bridge driver now informs Nova to use the 'tap' interface type - to wire interfaces. This requires '/dev/net/tun' to be added to the - 'cgroup_device_acl' in 'qemu.conf' before upgrading.