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