udev: Disable HW-address-based naming for IB NICs

An InfiniBand network address is 20 bytes long. Only the least
significant 8 bytes can be interpreted as a persistent hardware unit
identifier; the other 12 are transiently derived at runtime from metadata
specific to the protocol stack.

However, since the network interface name length is hard-capped by
IFNAMSIZ at 16 chars and the 2-byte type prefix with '\0' at the end
leave us only at 13, we cannot squeeze a descriptive representation of a
HW address into an interface name. Thus, it makes the most sense to drop
the scheme for IPoIB interfaces entirely.

Currently udev just gets confused and does what it has been taught
to do: fetches the first six bytes and puts them into a permanent
device attribute.
This commit is contained in:
Arseny Maslennikov 2018-08-29 04:20:43 +03:00
parent 938d30aa98
commit a0d415da3a
1 changed files with 17 additions and 0 deletions

View File

@ -658,6 +658,23 @@ static int names_mac(struct udev_device *dev, struct netnames *names) {
unsigned int i;
unsigned int a1, a2, a3, a4, a5, a6;
/* Some kinds of devices tend to have hardware addresses
* that are impossible to use in an iface name.
*/
s = udev_device_get_sysattr_value(dev, "type");
if (!s)
return EXIT_FAILURE;
i = strtoul(s, NULL, 0);
switch (i) {
/* The persistent part of a hardware address of an InfiniBand NIC
* is 8 bytes long. We cannot fit this much in an iface name.
*/
case ARPHRD_INFINIBAND:
return -EINVAL;
default:
break;
}
/* check for NET_ADDR_PERM, skip random MAC addresses */
s = udev_device_get_sysattr_value(dev, "addr_assign_type");
if (!s)