Browse Source

Only set "unknown" in LSP that makes sense

Prior to this patch, the "unknown" address was being set the logical
switch ports solely based on whether the port security was enabled or
disabled. That's not how it's intended to work.

With this patch the "unknown" address is only set to the normal logical
switch ports, those which types are "router", "localnet" or "localport"
won't be affected.

The maintenance task was updated to correct this behavior for existing
ports (the maintenance was suppose to be removed in the T cycle, this
patch bumps it to U cycle instead due to this change).

Closes-Bug: #1838535
Related-Bug: #1815270
Change-Id: I3c01bd7d1685c8a7e13a55e545e98baf19e9a0f9
Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
(cherry picked from commit 6a89dbfe47)
tags/6.0.1
Lucas Alvares Gomes Maciej Józefczyk 8 months ago
parent
commit
86eee7957b
3 changed files with 33 additions and 17 deletions
  1. +5
    -0
      networking_ovn/common/constants.py
  2. +15
    -6
      networking_ovn/common/maintenance.py
  3. +13
    -11
      networking_ovn/common/ovn_client.py

+ 5
- 0
networking_ovn/common/constants.py View File

@@ -161,3 +161,8 @@ LB_VIP_PORT_PREFIX = "ovn-lb-vip-"

# Maximum chassis count where a gateway port can be hosted
MAX_GW_CHASSIS = 5

UNKNOWN_ADDR = 'unknown'

# TODO(lucasagomes): Create constants for other LSP types
LSP_TYPE_LOCALNET = 'localnet'

+ 15
- 6
networking_ovn/common/maintenance.py View File

@@ -425,7 +425,7 @@ class DBInconsistenciesPeriodics(object):

raise periodics.NeverAgain()

# TODO(lucasagomes): Remove this in the T cycle
# TODO(lucasagomes): Remove this in the U cycle
# A static spacing value is used here, but this method will only run
# once per lock due to the use of periodics.NeverAgain().
@periodics.periodic(spacing=600, run_immediately=True)
@@ -435,13 +435,22 @@ class DBInconsistenciesPeriodics(object):
return

for port in self._nb_idl.lsp_list().execute(check_error=True):

if port.type == ovn_const.LSP_TYPE_LOCALNET:
continue

addresses = port.addresses
if not port.port_security and 'unknown' not in addresses:
addresses.append('unknown')
elif port.port_security and 'unknown' in addresses:
addresses.remove('unknown')
type_ = port.type.strip()
if not port.port_security:
if not type_ and ovn_const.UNKNOWN_ADDR not in addresses:
addresses.append(ovn_const.UNKNOWN_ADDR)
elif type_ and ovn_const.UNKNOWN_ADDR in addresses:
addresses.remove(ovn_const.UNKNOWN_ADDR)
else:
continue
if type_ and ovn_const.UNKNOWN_ADDR in addresses:
addresses.remove(ovn_const.UNKNOWN_ADDR)
elif not type_ and ovn_const.UNKNOWN_ADDR in addresses:
addresses.remove(ovn_const.UNKNOWN_ADDR)

self._nb_idl.lsp_set_addresses(
port.name, addresses=addresses).execute(check_error=True)


+ 13
- 11
networking_ovn/common/ovn_client.py View File

@@ -204,7 +204,7 @@ class OVNClient(object):
port_type = 'vtep'
options = {'vtep-physical-switch': vtep_physical_switch,
'vtep-logical-switch': vtep_logical_switch}
addresses = ["unknown"]
addresses = [ovn_const.UNKNOWN_ADDR]
parent_name = []
tag = []
port_security = []
@@ -227,20 +227,22 @@ class OVNClient(object):
addresses = [address]
addresses.extend(new_macs)

if not port_security:
# Port security is disabled for this port.
# So this port can send traffic with any mac address.
# OVN allows any mac address from a port if "unknown"
# is added to the Logical_Switch_Port.addresses column.
# So add it.
addresses.append("unknown")

# Only adjust the OVN type if the port is not owned by Neutron
# DHCP agents.
if (port['device_owner'] == const.DEVICE_OWNER_DHCP and
not port['device_id'].startswith('dhcp')):
port_type = 'localport'

# The "unknown" address should only be set for the normal LSP
# ports (the ones which type is empty)
if not port_security and not port_type:
# Port security is disabled for this port.
# So this port can send traffic with any mac address.
# OVN allows any mac address from a port if "unknown"
# is added to the Logical_Switch_Port.addresses column.
# So add it.
addresses.append(ovn_const.UNKNOWN_ADDR)

dhcpv4_options = self._get_port_dhcp_options(port, const.IP_VERSION_4)
dhcpv6_options = self._get_port_dhcp_options(port, const.IP_VERSION_6)

@@ -1362,9 +1364,9 @@ class OVNClient(object):
txn.add(self._nb_idl.create_lswitch_port(
lport_name=utils.ovn_provnet_port_name(network['id']),
lswitch_name=utils.ovn_name(network['id']),
addresses=['unknown'],
addresses=[ovn_const.UNKNOWN_ADDR],
external_ids={},
type='localnet',
type=ovn_const.LSP_TYPE_LOCALNET,
tag=tag if tag else [],
options={'network_name': physnet}))



Loading…
Cancel
Save