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