From a418d55bc282990847626a2dcb09a8c97604582a Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Thu, 16 Jul 2020 11:39:02 +0200 Subject: [PATCH] ovn-migration-mtu: Support migrating MTU of GRE networks Add support for adjusting MTU on GRE networks the same way the tool already supports adjusting MTU on VXLAN networks. Change-Id: I3f62b91a21ac7e708fb04154194f45a6ff1b6a76 Closes-Bug: #1887781 --- neutron/cmd/ovn/migration_mtu.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/neutron/cmd/ovn/migration_mtu.py b/neutron/cmd/ovn/migration_mtu.py index d9f722063e1..a303238144c 100644 --- a/neutron/cmd/ovn/migration_mtu.py +++ b/neutron/cmd/ovn/migration_mtu.py @@ -16,10 +16,18 @@ import os import sys +from neutron_lib import constants from openstack import connection -# TODO(dalvarez): support also GRE -GENEVE_TO_VXLAN_OVERHEAD = 8 + +# Overhead size of Geneve is configurable, use the recommended value +GENEVE_ENCAP_OVERHEAD = 38 +# map of network types to migrate and the difference in overhead size when +# converted to Geneve. +NETWORK_TYPE_OVERHEAD_DIFF = { + 'vxlan': GENEVE_ENCAP_OVERHEAD - constants.VXLAN_ENCAP_OVERHEAD, + 'gre': GENEVE_ENCAP_OVERHEAD - constants.GRE_ENCAP_OVERHEAD, +} def get_connection(): @@ -75,7 +83,7 @@ def verify_network_mtu(): success = True for network in conn.network.networks(): if network.provider_physical_network is None and ( - network.provider_network_type == 'vxlan') and ( + network.provider_network_type in NETWORK_TYPE_OVERHEAD_DIFF) and ( 'adapted_mtu' not in network.tags): print("adapted_mtu tag is not set for the Network " "[" + str(network.name) + "]") @@ -95,7 +103,8 @@ def update_network_mtu(): for network in conn.network.networks(): try: if network.provider_physical_network is None and ( - network.provider_network_type == 'vxlan') and ( + network.provider_network_type in + NETWORK_TYPE_OVERHEAD_DIFF) and ( 'adapted_mtu' not in network.tags): print("Updating the mtu and the tag 'adapted_mtu" " of the network - " + str(network.name)) @@ -103,7 +112,8 @@ def update_network_mtu(): new_tags.append('adapted_mtu') conn.network.update_network( network, - mtu=int(network.mtu) - GENEVE_TO_VXLAN_OVERHEAD) + mtu=int(network.mtu) - NETWORK_TYPE_OVERHEAD_DIFF[ + network.provider_network_type]) conn.network.set_tags(network, new_tags) except Exception as e: print("Exception occured while updating the MTU:" + str(e))