Blame SOURCES/0571-95znet-Add-a-rd.znet_ifname-option.patch

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