Limit interface names to 15 characters

If you give your bridge a long enough name, eg. `br-external`. The
extra characters added to the veth pairs can make the interface name
go beyond the 15 character limit. We can solve this by truncating the
name of the bridge used in the veth names.

Change-Id: I5b890e24195d033897a597a0a93a1cacfb2030d2
This commit is contained in:
Erik Berg 2023-01-10 17:33:53 +01:00
parent ebd5799fd4
commit b9b90a5d5f
No known key found for this signature in database
GPG Key ID: 1182D19B0E5ED030
2 changed files with 12 additions and 3 deletions

View File

@ -154,7 +154,10 @@ class ActionModule(ActionBase):
# For a bridge, use a veth pair connected to the bridge. Otherwise
# use the interface directly.
if is_bridge:
external_interface = patch_prefix + interface + patch_suffix
# interface names can't be longer than 15 characters
char_limit = 15 - len(patch_prefix) - len(patch_suffix)
external_interface = patch_prefix + interface[:char_limit] + \
patch_suffix
else:
external_interface = interface
neutron_external_interfaces.append(external_interface)

View File

@ -49,7 +49,10 @@ def _get_veth_interface(context, bridge, inventory_hostname):
inventory_hostname)
suffix = utils.get_hostvar(context, 'network_patch_suffix_phy',
inventory_hostname)
return prefix + bridge + suffix
# interface names can't be longer than 15 characters
char_limit = 15 - len(prefix) - len(suffix)
return prefix + bridge[:char_limit] + suffix
def _get_veth_peer(context, bridge, inventory_hostname):
@ -64,7 +67,10 @@ def _get_veth_peer(context, bridge, inventory_hostname):
inventory_hostname)
suffix = utils.get_hostvar(context, 'network_patch_suffix_ovs',
inventory_hostname)
return prefix + bridge + suffix
# interface names can't be longer than 15 characters
char_limit = 15 - len(prefix) - len(suffix)
return prefix + bridge[:char_limit] + suffix
def get_ovs_veths(context, names, inventory_hostname):