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
This commit is contained in:
Slawek Kaplonski 2020-11-10 22:28:32 +01:00
parent b70a6e97dc
commit 279fa8676e
5 changed files with 37 additions and 2 deletions

View File

@ -291,3 +291,6 @@ NEUTRON_AVAILABILITY_ZONES = 'neutron-availability-zones'
OVN_CMS_OPTIONS = 'ovn-cms-options' OVN_CMS_OPTIONS = 'ovn-cms-options'
CMS_OPT_CHASSIS_AS_GW = 'enable-chassis-as-gw' CMS_OPT_CHASSIS_AS_GW = 'enable-chassis-as-gw'
CMS_OPT_AVAILABILITY_ZONES = 'availability-zones' CMS_OPT_AVAILABILITY_ZONES = 'availability-zones'
# OVN vlan transparency option
VLAN_PASSTHRU = 'vlan-passthru'

View File

@ -152,6 +152,10 @@ class OVNMechanismDriver(api.MechanismDriver):
def sb_ovn(self): def sb_ovn(self):
return self._sb_ovn return self._sb_ovn
def check_vlan_transparency(self, context):
"""OVN driver vlan transparency support."""
return True
def _setup_vif_port_bindings(self): def _setup_vif_port_bindings(self):
self.supported_vnic_types = [portbindings.VNIC_NORMAL, self.supported_vnic_types = [portbindings.VNIC_NORMAL,
portbindings.VNIC_DIRECT, portbindings.VNIC_DIRECT,

View File

@ -1588,8 +1588,11 @@ class OVNClient(object):
# Enable IGMP snooping if igmp_snooping_enable is enabled in Neutron # Enable IGMP snooping if igmp_snooping_enable is enabled in Neutron
value = 'true' if ovn_conf.is_igmp_snooping_enabled() else 'false' 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, 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 return params
def create_network(self, context, network): def create_network(self, context, network):

View File

@ -83,6 +83,7 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
group='ovn') group='ovn')
ovn_conf.cfg.CONF.set_override('dns_servers', ['8.8.8.8'], ovn_conf.cfg.CONF.set_override('dns_servers', ['8.8.8.8'],
group='ovn') group='ovn')
cfg.CONF.set_override('vlan_transparent', True)
super(TestOVNMechanismDriver, self).setUp() super(TestOVNMechanismDriver, self).setUp()
mm = directory.get_plugin().mechanism_manager mm = directory.get_plugin().mechanism_manager
self.mech_driver = mm.mech_drivers['ovn'].obj 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, ovn_utils.ovn_name(net['id']), external_ids=mock.ANY,
may_exist=True, may_exist=True,
other_config={ovn_const.MCAST_SNOOP: value, 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): def test_create_network_igmp_snoop_enabled(self):
self._create_network_igmp_snoop(enabled=True) self._create_network_igmp_snoop(enabled=True)
@ -725,6 +727,25 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
def test_create_network_igmp_snoop_disabled(self): def test_create_network_igmp_snoop_disabled(self):
self._create_network_igmp_snoop(enabled=False) 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): def test_create_network_create_localnet_port_tunnel_network_type(self):
nb_idl = self.mech_driver._ovn_client._nb_idl nb_idl = self.mech_driver._ovn_client._nb_idl
self._make_network(self.fmt, name='net1', self._make_network(self.fmt, name='net1',

View File

@ -0,0 +1,4 @@
---
features:
- |
Added support for the ``vlan-transparent`` in the OVN mechanism driver.