From a70f07deb155eef450d59ccd897730298f360a0a Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 22 Mar 2019 16:11:04 +0000 Subject: [PATCH] Add "connectivity" parameter in vif_details Added "connectivity" parameter to mech driver vif_details. The default value is "legacy". The in-tree drivers (Linux Bridge, Open vSwitch, SR-IOV and MacVTap) have "l2" connectivity. Change-Id: I45480986fc89e0b2f475ee0ceb13d8742fb8c530 Related-Bug: #1821058 --- .../linuxbridge/mech_driver/mech_linuxbridge.py | 5 ++++- .../ml2/drivers/macvtap/mech_driver/mech_macvtap.py | 5 ++++- neutron/plugins/ml2/drivers/mech_agent.py | 4 +++- .../drivers/mech_sriov/mech_driver/mech_driver.py | 4 +++- .../openvswitch/mech_driver/mech_openvswitch.py | 4 +++- .../mech_driver/test_mech_openvswitch.py | 13 ++++++------- 6 files changed, 23 insertions(+), 12 deletions(-) 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 98afdf6d6d0..07063bbfa20 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py @@ -33,10 +33,13 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): def __init__(self): sg_enabled = securitygroups_rpc.is_firewall_enabled() + vif_details = {portbindings.CAP_PORT_FILTER: sg_enabled, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2} super(LinuxbridgeMechanismDriver, self).__init__( constants.AGENT_TYPE_LINUXBRIDGE, portbindings.VIF_TYPE_BRIDGE, - {portbindings.CAP_PORT_FILTER: sg_enabled}) + vif_details) lb_qos_driver.register() def get_allowed_network_types(self, agent): diff --git a/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py b/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py index 25df0b3ba80..31bcc45c00c 100644 --- a/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py +++ b/neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py @@ -38,10 +38,13 @@ class MacvtapMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): """ def __init__(self): + vif_details = {portbindings.CAP_PORT_FILTER: False, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2} super(MacvtapMechanismDriver, self).__init__( constants.AGENT_TYPE_MACVTAP, portbindings.VIF_TYPE_MACVTAP, - {portbindings.CAP_PORT_FILTER: False}) + vif_details) def get_allowed_network_types(self, agent): return [constants.TYPE_FLAT, constants.TYPE_VLAN] diff --git a/neutron/plugins/ml2/drivers/mech_agent.py b/neutron/plugins/ml2/drivers/mech_agent.py index e13d97d2ae4..348427f51f5 100644 --- a/neutron/plugins/ml2/drivers/mech_agent.py +++ b/neutron/plugins/ml2/drivers/mech_agent.py @@ -265,7 +265,9 @@ class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase): super(SimpleAgentMechanismDriverBase, self).__init__( agent_type, supported_vnic_types) self.vif_type = vif_type - self.vif_details = vif_details + self.vif_details = {portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_LEGACY} + self.vif_details.update(vif_details) def try_to_bind_segment_for_agent(self, context, segment, agent): if self.check_segment_for_agent(segment, agent): diff --git a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py index 8a5d1531425..009c02176b9 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py @@ -55,7 +55,9 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): def __init__(self, agent_type=constants.AGENT_TYPE_NIC_SWITCH, - vif_details={portbindings.CAP_PORT_FILTER: False}, + vif_details={portbindings.CAP_PORT_FILTER: False, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2}, supported_vnic_types=[portbindings.VNIC_DIRECT, portbindings.VNIC_MACVTAP, portbindings.VNIC_DIRECT_PHYSICAL]): diff --git a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py index 25f3832a708..422c5708483 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py @@ -62,7 +62,9 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): IPTABLES_FW_DRIVER_FULL, 'iptables_hybrid') ) and sg_enabled vif_details = {portbindings.CAP_PORT_FILTER: sg_enabled, - portbindings.OVS_HYBRID_PLUG: hybrid_plug_required} + portbindings.OVS_HYBRID_PLUG: hybrid_plug_required, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2} # NOTE(moshele): Bind DIRECT (SR-IOV) port allows # to offload the OVS flows using tc to the SR-IOV NIC. # We are using OVS mechanism driver because the openvswitch (>=2.8.0) diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py index 6de5964ac0a..e813443f735 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py @@ -34,7 +34,9 @@ class OpenvswitchMechanismBaseTestCase(base.AgentMechanismBaseTestCase): VIF_DETAILS = {'bridge_name': 'br-int', portbindings.OVS_DATAPATH_TYPE: 'system', portbindings.CAP_PORT_FILTER: True, - portbindings.OVS_HYBRID_PLUG: True} + portbindings.OVS_HYBRID_PLUG: True, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2} AGENT_TYPE = constants.AGENT_TYPE_OVS GOOD_MAPPINGS = {'fake_physical_network': 'fake_bridge'} @@ -112,7 +114,9 @@ class OpenvswitchMechanismSGDisabledBaseTestCase( VIF_DETAILS = {'bridge_name': 'br-int', portbindings.OVS_DATAPATH_TYPE: 'system', portbindings.CAP_PORT_FILTER: False, - portbindings.OVS_HYBRID_PLUG: False} + portbindings.OVS_HYBRID_PLUG: False, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2} def setUp(self): cfg.CONF.set_override('enable_security_group', @@ -218,11 +222,6 @@ class OpenvswitchMechanismSGDisabledLocalTestCase( class OpenvswitchMechanismFirewallUndefinedTestCase( OpenvswitchMechanismBaseTestCase, base.AgentMechanismLocalTestCase): - VIF_DETAILS = {'bridge_name': 'br-int', - portbindings.OVS_DATAPATH_TYPE: 'system', - portbindings.CAP_PORT_FILTER: True, - portbindings.OVS_HYBRID_PLUG: True} - def setUp(self): # this simple test case just ensures backward compatibility where # the server has no firewall driver configured, which should result