def get_veth_name(self, prefix, name): """Construct a veth name based on the prefix and name that does not
exceed the maximum length allowed for a linux device. Longer names
are hashed to help ensure uniqueness.
"""
if len(prefix + name) <= ip_lib.VETH_MAX_NAME_LENGTH:
return prefix + name
# We can't just truncate because bridges may be distinguished
# by an ident at the end. A hash over the name should be unique.
# Leave part of the bridge name on for easier identification
hashlen = 6
namelen = ip_lib.VETH_MAX_NAME_LENGTH - len(prefix) - hashlen
new_name = ('%(prefix)s%(truncated)s%(hash)s' % {'prefix': prefix, 'truncated': name[0:namelen], 'hash': hashlib.sha1(name).hexdigest()[0:hashlen]})
Additionally, fixing this bug would require addressing the 'interface names are too long' from https:/ /bugs.launchpad .net/charm- neutron- openvswitch/ +bug/1773353
echo -n 'br-management0' | wc -c
14
15-byte byte/character limit (15 bytes for a name + \0 terminator) for interface names is kernel-imposed: /bugs.launchpad .net/juju/ +bug/1672327/ comments/ 14
https:/
echo -n 'veth-br- management0' | wc -c
19
It appears to be that hashing similar to bridge name hashing in MAAS, Juju and Neutron needs to be implemented:
https:/ /bugs.launchpad .net/juju/ +bug/1672327
https:/ /github. com/juju/ juju/pull/ 7204/commits/ 0a55ac9471df324 cdf9c1e47ccfdd8 02dce404c9# diff-65dee4d34a 1af94fb6b79057f 0c42d3bR197 (the original commit to juju)
https:/ /i316302782. restricted. launchpadlibrar ian.net/ 316302782/ 0b4d35fa- 2578-11e7- b189-002481e91f 22.txt? token=GGfWcr03W FJp1x2N6DV7rMxV 0qp1389w (the original commit to MAAS)
+ name = b"br-%s" % ifname
+ if len(name) > 15:
+ name = b"b-%s" % ifname
+ if ifname[:2] == b'en':
+ name = b"b-%s" % ifname[2:]
+ if len(name) > 15:
+ ifname_hash = (b"%06x" % (crc32(ifname) & 0xffffffff))[-6:]
+ name = b"b-%s-%s" % (ifname_hash, ifname[len(ifname) - 6:])
veth name handling in neutron which we could simply reuse:
https:/ /git.openstack. org/cgit/ openstack/ neutron/ commit/ ?id=ca7ed8f84da 6962a9c2b8ad21d 484931d297f31b
def get_veth_name(self, prefix, name):
"""Construct a veth name based on the prefix and name that does not VETH_MAX_ NAME_LENGTH: VETH_MAX_ NAME_LENGTH - len(prefix) - hashlen s%(truncated) s%(hash) s' %
{ 'prefix' : prefix, 'truncated': name[0:namelen],
'hash': hashlib. sha1(name) .hexdigest( )[0:hashlen] })
exceed the maximum length allowed for a linux device. Longer names
are hashed to help ensure uniqueness.
"""
if len(prefix + name) <= ip_lib.
return prefix + name
# We can't just truncate because bridges may be distinguished
# by an ident at the end. A hash over the name should be unique.
# Leave part of the bridge name on for easier identification
hashlen = 6
namelen = ip_lib.
new_name = ('%(prefix)