From a0d415da3ac345bb656ce5cabc38fde61f6b23e1 Mon Sep 17 00:00:00 2001 From: Arseny Maslennikov Date: Wed, 29 Aug 2018 04:20:43 +0300 Subject: [PATCH] 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. --- src/udev/udev-builtin-net_id.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 239a825ae5c..d808ddcfeb1 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -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) -- 2.47.3