From 279fa8676e967e7c9103b726c581348f38a15ee8 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Tue, 10 Nov 2020 22:28:32 +0100 Subject: [PATCH] Add support for vlan transparency in the OVN driver This patch adds support for vlan_transparent in the ovn mechanism driver. So ovn is now second mech_driver after linuxbridge which can be used with vlan_transparent networks. It just adds "vlan-passthru" option to the Logical Switch's "other config". This needs also changes in the core OVN which are available only in OVN master branch for now. See [1] for details. [1] https://patchwork.ozlabs.org/project/ovn/patch/20201110023449.194642-1-ihrachys@redhat.com/ Change-Id: I76b8ba959398dcffff112d26ae7d81ff428be992 --- neutron/common/ovn/constants.py | 3 +++ .../drivers/ovn/mech_driver/mech_driver.py | 4 ++++ .../ovn/mech_driver/ovsdb/ovn_client.py | 5 +++- .../ovn/mech_driver/test_mech_driver.py | 23 ++++++++++++++++++- ...or-vlan-transparency-3ac9d965f5093a15.yaml | 4 ++++ 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/ovn-driver-adds-support-for-vlan-transparency-3ac9d965f5093a15.yaml diff --git a/neutron/common/ovn/constants.py b/neutron/common/ovn/constants.py index 2977162553e..236b74d6eb9 100644 --- a/neutron/common/ovn/constants.py +++ b/neutron/common/ovn/constants.py @@ -291,3 +291,6 @@ NEUTRON_AVAILABILITY_ZONES = 'neutron-availability-zones' OVN_CMS_OPTIONS = 'ovn-cms-options' CMS_OPT_CHASSIS_AS_GW = 'enable-chassis-as-gw' CMS_OPT_AVAILABILITY_ZONES = 'availability-zones' + +# OVN vlan transparency option +VLAN_PASSTHRU = 'vlan-passthru' diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py index 8008a47127d..53be7cfa40e 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py @@ -152,6 +152,10 @@ class OVNMechanismDriver(api.MechanismDriver): def sb_ovn(self): return self._sb_ovn + def check_vlan_transparency(self, context): + """OVN driver vlan transparency support.""" + return True + def _setup_vif_port_bindings(self): self.supported_vnic_types = [portbindings.VNIC_NORMAL, portbindings.VNIC_DIRECT, diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py index 4e4176196fd..3135876b6ed 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py @@ -1588,8 +1588,11 @@ class OVNClient(object): # Enable IGMP snooping if igmp_snooping_enable is enabled in Neutron value = 'true' if ovn_conf.is_igmp_snooping_enabled() else 'false' + vlan_transparent = ( + 'true' if network.get('vlan_transparent') else 'false') params['other_config'] = {ovn_const.MCAST_SNOOP: value, - ovn_const.MCAST_FLOOD_UNREGISTERED: value} + ovn_const.MCAST_FLOOD_UNREGISTERED: value, + ovn_const.VLAN_PASSTHRU: vlan_transparent} return params def create_network(self, context, network): diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py index 3aec319d626..e4ad65b19ba 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py @@ -83,6 +83,7 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase): group='ovn') ovn_conf.cfg.CONF.set_override('dns_servers', ['8.8.8.8'], group='ovn') + cfg.CONF.set_override('vlan_transparent', True) super(TestOVNMechanismDriver, self).setUp() mm = directory.get_plugin().mechanism_manager self.mech_driver = mm.mech_drivers['ovn'].obj @@ -717,7 +718,8 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase): ovn_utils.ovn_name(net['id']), external_ids=mock.ANY, may_exist=True, other_config={ovn_const.MCAST_SNOOP: value, - ovn_const.MCAST_FLOOD_UNREGISTERED: value}) + ovn_const.MCAST_FLOOD_UNREGISTERED: value, + ovn_const.VLAN_PASSTHRU: 'false'}) def test_create_network_igmp_snoop_enabled(self): self._create_network_igmp_snoop(enabled=True) @@ -725,6 +727,25 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase): def test_create_network_igmp_snoop_disabled(self): self._create_network_igmp_snoop(enabled=False) + def _create_network_vlan_passthru(self, enabled): + nb_idl = self.mech_driver._ovn_client._nb_idl + net = self._make_network(self.fmt, name='net1', + admin_state_up=True, + vlan_transparent=enabled)['network'] + value = 'true' if enabled else 'false' + nb_idl.ls_add.assert_called_once_with( + ovn_utils.ovn_name(net['id']), external_ids=mock.ANY, + may_exist=True, + other_config={ovn_const.MCAST_SNOOP: 'false', + ovn_const.MCAST_FLOOD_UNREGISTERED: 'false', + ovn_const.VLAN_PASSTHRU: value}) + + def test_create_network_vlan_passthru_enabled(self): + self._create_network_vlan_passthru(enabled=True) + + def test_create_network_vlan_passthru_disabled(self): + self._create_network_vlan_passthru(enabled=False) + def test_create_network_create_localnet_port_tunnel_network_type(self): nb_idl = self.mech_driver._ovn_client._nb_idl self._make_network(self.fmt, name='net1', diff --git a/releasenotes/notes/ovn-driver-adds-support-for-vlan-transparency-3ac9d965f5093a15.yaml b/releasenotes/notes/ovn-driver-adds-support-for-vlan-transparency-3ac9d965f5093a15.yaml new file mode 100644 index 00000000000..eaccad019c0 --- /dev/null +++ b/releasenotes/notes/ovn-driver-adds-support-for-vlan-transparency-3ac9d965f5093a15.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Added support for the ``vlan-transparent`` in the OVN mechanism driver.