Harald Hoyer 308914
From 872eb69936bd849eec6d1974dd6569f23a7ad3db Mon Sep 17 00:00:00 2001
Harald Hoyer 308914
From: Kairui Song <kasong@redhat.com>
Harald Hoyer 308914
Date: Thu, 5 Mar 2020 18:44:45 +0800
Harald Hoyer 308914
Subject: [PATCH] 95znet: Add a rd.znet_ifname= option
Harald Hoyer 308914
Harald Hoyer 308914
qeth device may have a different IP for each boot, so the rd.ifname=
Harald Hoyer 308914
option will no longer work. So for znet device, introduce a
Harald Hoyer 308914
rd.znet_ifname= options, to subchannel id instead of MAC address as the
Harald Hoyer 308914
identifier and rename the interface.
Harald Hoyer 308914
Harald Hoyer 308914
Signed-off-by: Kairui Song <kasong@redhat.com>
Harald Hoyer 308914
---
Harald Hoyer 308914
 dracut.cmdline.7.asc          |  5 +++++
Harald Hoyer 308914
 modules.d/95znet/parse-ccw.sh | 18 ++++++++++++++++++
Harald Hoyer 308914
 2 files changed, 23 insertions(+)
Harald Hoyer 308914
Harald Hoyer 308914
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
Harald Hoyer 308914
index 63074353..2b38aa33 100644
Harald Hoyer 308914
--- a/dracut.cmdline.7.asc
Harald Hoyer 308914
+++ b/dracut.cmdline.7.asc
Harald Hoyer 308914
@@ -863,6 +863,11 @@ ZNET
Harald Hoyer 308914
     RHEL/Fedora with ccw_init, which is called from udev for certain
Harald Hoyer 308914
     devices on z-series.
Harald Hoyer 308914
     rd.znet can be specified multiple times on the kernel command line.
Harald Hoyer 308914
+
Harald Hoyer 308914
+**rd.znet_ifname=**__<ifname>__:__<subchannels>__::
Harald Hoyer 308914
+    Assign network device name <interface> (i.e. "bootnet") to the NIC
Harald Hoyer 308914
+    corresponds to the subchannels. This is useful when dracut's default
Harald Hoyer 308914
+    "ifname=" doesn't work due to device having a changing MAC address.
Harald Hoyer 308914
 +
Harald Hoyer 308914
 [listing]
Harald Hoyer 308914
 .Example
Harald Hoyer 308914
diff --git a/modules.d/95znet/parse-ccw.sh b/modules.d/95znet/parse-ccw.sh
Harald Hoyer 308914
index 7d40a1aa..59b588f3 100755
Harald Hoyer 308914
--- a/modules.d/95znet/parse-ccw.sh
Harald Hoyer 308914
+++ b/modules.d/95znet/parse-ccw.sh
Harald Hoyer 308914
@@ -4,4 +4,22 @@ for ccw_arg in $(getargs rd.ccw -d 'rd_CCW=') $(getargs rd.znet -d 'rd_ZNET=');
Harald Hoyer 308914
     echo $ccw_arg >> /etc/ccw.conf
Harald Hoyer 308914
 done
Harald Hoyer 308914
 
Harald Hoyer 308914
+for ifname in $(getargs rd.znet_ifname); do
Harald Hoyer 308914
+    IFS=: read ifname_if ifname_subchannels _rest <<< "$ifname"
Harald Hoyer 308914
+    if [ -z "$ifname_if" ] || [ -z "$ifname_subchannels" ] || [ -n "$_rest" ]; then
Harald Hoyer 308914
+        warn "Invalid arguments for rd.znet_ifname="
Harald Hoyer 308914
+    else
Harald Hoyer 308914
+        {
Harald Hoyer 308914
+            ifname_subchannels=${ifname_subchannels//,/|}
Harald Hoyer 308914
+
Harald Hoyer 308914
+            echo 'ACTION!="add|change", GOTO="ccw_ifname_end"'
Harald Hoyer 308914
+            echo 'ATTR{type}!="1", GOTO="ccw_ifname_end"'
Harald Hoyer 308914
+            echo 'SUBSYSTEM!="net", GOTO="ccw_ifname_end"'
Harald Hoyer 308914
+            echo "SUBSYSTEMS==\"ccwgroup\", KERNELS==\"$ifname_subchannels\", DRIVERS==\"?*\" NAME=\"$ifname_if\""
Harald Hoyer 308914
+            echo 'LABEL="ccw_ifname_end"'
Harald Hoyer 308914
+
Harald Hoyer 308914
+        } > /etc/udev/rules.d/81-ccw-ifname.rules
Harald Hoyer 308914
+    fi
Harald Hoyer 308914
+done
Harald Hoyer 308914
+
Harald Hoyer 308914
 znet_cio_free
Harald Hoyer 308914