From 0643ab44d8204cde78fb7e8713fdd46dad0d87df Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Tue, 14 Jan 2020 11:30:10 +0000 Subject: [PATCH] Set OpenFlow 1.0, 1.3 and 1.4 by default on bridges There is a bug in OVS 2.12 where it's impossible to change protocol on a bridge. This patch should be reverted once OVS is fixed. More information about the bug at [1]. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1782834 Related-Bug: #1852221 Change-Id: I1ead1eee48a0c56193f20797ab35be36a0458270 --- neutron/agent/common/ovs_lib.py | 10 +++++++++- neutron/tests/functional/agent/test_ovs_lib.py | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/neutron/agent/common/ovs_lib.py b/neutron/agent/common/ovs_lib.py index 81210ce4210..d448528ab1f 100644 --- a/neutron/agent/common/ovs_lib.py +++ b/neutron/agent/common/ovs_lib.py @@ -237,6 +237,12 @@ class OVSBridge(BaseOVS): self._default_cookie = generate_random_cookie() self._highest_protocol_needed = constants.OPENFLOW10 self._min_bw_qos_id = uuidutils.generate_uuid() + # TODO(jlibosva): Revert initial_protocols once launchpad bug 1852221 + # is fixed and new openvswitch containing the fix is + # released. + self.initial_protocols = { + constants.OPENFLOW10, constants.OPENFLOW13, constants.OPENFLOW14} + self.initial_protocols.add(self._highest_protocol_needed) @property def default_cookie(self): @@ -275,6 +281,7 @@ class OVSBridge(BaseOVS): self._highest_protocol_needed = max(self._highest_protocol_needed, protocol, key=version_from_protocol) + self.initial_protocols.add(self._highest_protocol_needed) def set_igmp_snooping_state(self, state): state = bool(state) @@ -301,7 +308,8 @@ class OVSBridge(BaseOVS): # transactions txn.add( self.ovsdb.db_add('Bridge', self.br_name, - 'protocols', self._highest_protocol_needed)) + 'protocols', + *self.initial_protocols)) txn.add( self.ovsdb.db_set('Bridge', self.br_name, ('other_config', other_config))) diff --git a/neutron/tests/functional/agent/test_ovs_lib.py b/neutron/tests/functional/agent/test_ovs_lib.py index c48ca9947c6..d85cdce167e 100644 --- a/neutron/tests/functional/agent/test_ovs_lib.py +++ b/neutron/tests/functional/agent/test_ovs_lib.py @@ -483,11 +483,12 @@ class OVSBridgeTestCase(OVSBridgeTestBase): def test_db_add_set(self): protocols = ["OpenFlow10", "OpenFlow11"] + expected = self.br.initial_protocols.union(protocols) self.br.ovsdb.db_add("Bridge", self.br.br_name, "protocols", *protocols).execute(check_error=True) - self.assertEqual(protocols, - self.br.db_get_val('Bridge', - self.br.br_name, "protocols")) + self.assertItemsEqual(expected, + self.br.db_get_val('Bridge', + self.br.br_name, "protocols")) def test_db_add_map(self): key = "testdata"