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