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