Browse Source

[OVN] Don't set virtual port type on ports with similar addresses

Because of broken check why one port has similar address to the other
one, the first one by mistake could be set as virtual.
Example:
 port_1: 10.11.1.100
 port_2: 10.11.1.10

On create of port_2 it is set as 'virtual', but shouldn't.

This patch fixes that bug by using common function
utils.get_ovn_port_addresses().

Cherry-picked from Neutron: https://review.opendev.org/#/c/732690/

Change-Id: Ia4b986146c77edf0616015380359e37233df80fc
Closes-Bug: #1881759
(cherry picked from commit e6023ecb48)
changes/32/733632/2
Maciej Józefczyk 3 months ago
parent
commit
ec16fd75d2
2 changed files with 18 additions and 2 deletions
  1. +3
    -2
      networking_ovn/common/ovn_client.py
  2. +15
    -0
      networking_ovn/tests/functional/test_mech_driver.py

+ 3
- 2
networking_ovn/common/ovn_client.py View File

@@ -199,8 +199,9 @@ class OVNClient(object):
def get_virtual_port_parents(self, virtual_ip, port):
ls = self._nb_idl.ls_get(utils.ovn_name(port['network_id'])).execute(
check_error=True)
return [lsp.name for lsp in ls.ports for ps in lsp.port_security
if lsp.name != port['id'] and virtual_ip in ps]
return [lsp.name for lsp in ls.ports
if lsp.name != port['id'] and
virtual_ip in utils.get_ovn_port_addresses(lsp)]

def _get_port_options(self, port, qos_options=None):
context = n_context.get_admin_context()


+ 15
- 0
networking_ovn/tests/functional/test_mech_driver.py View File

@@ -414,3 +414,18 @@ class TestVirtualPorts(base.TestOVNFunctionalBase):
ovn_vport.options)
self.assertNotIn(ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY,
ovn_vport.options)

def test_virtual_port_not_set_similiar_address(self):
# Create one port
self._create_port(fixed_ip='10.0.0.110')
# Create second port with similar IP, so that
# string matching will return True
second_port = self._create_port(fixed_ip='10.0.0.11')

# Assert the virtual port has not been set.
ovn_vport = self._find_port_row(second_port['id'])
self.assertEqual("", ovn_vport.type)
self.assertNotIn(ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY,
ovn_vport.options)
self.assertNotIn(ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY,
ovn_vport.options)

Loading…
Cancel
Save