summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2016-01-29 17:54:30 +0100
committerDimitri John Ledkov <xnox@ubuntu.com>2016-01-29 17:54:30 +0100
commit0037a669ac9a2bbedccdb2f483111351e8ff4659 (patch)
tree7a4054d614b337ff32effbc4d77517307b32b5e7 /src
parenta5a5f03382ba7733670d7d226ce75f98dd64e554 (diff)
udev: net_id - for ccw bus, shorten the identifier and stip leading zeros
The commmon case default qeth link is enccw0.0.0600 is rather long. Thus strip leading zeros (which doesn't make the bus_id unstable), similar to the PCI domain case. Also 'ccw' is redundant on S/390, as there aren't really other buses available which could have qeth driver interfaces. Not sure why this code is even compiled on non-s390[x] platforms. But to distinguish from e.g. MAC stable names shorten the suffix to just 'c'. Thus enccw0.0.0600 becomes enc600.
Diffstat (limited to 'src')
-rw-r--r--src/udev/udev-builtin-net_id.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index 104d5111c5..4f8a759d04 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -36,7 +36,7 @@
*
* Type of names:
* b<number> -- BCMA bus core number
- * ccw<name> -- CCW bus group name
+ * c<bus_id> -- CCW bus group name, without leading zeros [s390]
* o<index>[d<dev_port>] -- on-board device index number
* s<slot>[f<function>][d<dev_port>] -- hotplug slot index number
* x<MAC> -- MAC address
@@ -430,8 +430,15 @@ static int names_ccw(struct udev_device *dev, struct netnames *names) {
if (!bus_id_len || bus_id_len < 8 || bus_id_len > 9)
return -EINVAL;
+ /* Strip leading zeros from the bus id for aesthetic purposes. This
+ * keeps the ccw names stable, yet much shorter in general case of
+ * bus_id 0.0.0600 -> 600. This is similar to e.g. how PCI domain is
+ * not prepended when it is zero.
+ */
+ bus_id += strspn(bus_id, ".0");
+
/* Store the CCW bus-ID for use as network device name */
- rc = snprintf(names->ccw_group, sizeof(names->ccw_group), "ccw%s", bus_id);
+ rc = snprintf(names->ccw_group, sizeof(names->ccw_group), "c%s", bus_id);
if (rc >= 0 && rc < (int)sizeof(names->ccw_group))
names->type = NET_CCWGROUP;
return 0;