summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2022-04-04 11:06:36 -0700
committerLee Duncan <lduncan@suse.com>2022-04-04 13:36:13 -0700
commitfe2c59e06a42b57340158549cd50a3a46cfc5001 (patch)
tree0faf271ee7e41987a047782cce9d3fbff95f1bff
parent6a20131db3bd4715a456f80776400a2e78e7a994 (diff)
downloadopen-iscsi-fe2c59e06a42b57340158549cd50a3a46cfc5001.tar.gz
Create an systemd iBFT rule generator
When dracut is booted with 'ip=ibft' it will rename the interfaces to "ibft*". This will cause error messages during booting, as later on systemd is trying to rename the ianterfaces again, which doesn't work as the interface is busy. So create a systemd generator for creating a dynamic udev rule to stop udev from renaming that interface.
-rw-r--r--etc/systemd/ibft-rule-generator36
1 files changed, 36 insertions, 0 deletions
diff --git a/etc/systemd/ibft-rule-generator b/etc/systemd/ibft-rule-generator
new file mode 100644
index 0000000..038a4c2
--- /dev/null
+++ b/etc/systemd/ibft-rule-generator
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Systemd rule generator for ibft interfaces
+#
+# Copyright (c) 2022 Hannes Reinecke, SUSE Labs
+# This script is licensed under the GPL.
+#
+# When booted with 'ip=ibft' dracut will rename the
+# interface to 'ibft*'. After systemd has started
+# it'll try to rename the interface yet again with
+# a persistent name.
+# But as the ibft interface is already renamed _and_
+# in use, the second renaming will fail and udev
+# will complain.
+# So add a dummy rule which signals udev the correct name
+#
+# Interface renaming happes at 80-net-setup-link.rules,
+# so we need to hook in before that.
+#
+IBFT_RULE_DIR=/run/udev/rules.d
+IBFT_RULES=$(IBFT_RULE_DIR)/79-ibft.rules
+
+# ensure we have a rules directory and no rules file
+if [ -d ${IBFT_RULE_DIR} ] ; then
+ rm -f ${IBFT_RULES} 2> /dev/null
+else
+ mkdir -p ${IBFT_RULE_DIR}
+fi
+
+# create an iBFT udev rule for each iBFT NIC found
+for d in /sys/firmware/ibft/ethernet* ; do
+ [ -d "$d" ] || break
+ num="${d##*/ethernet}"
+ read mac < $d/mac
+ printf 'SUBSYSTEM=="net", KERNEL=="ibft*", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="ibft%s"\n' "$mac" "$num" >> $IBFT_RULES
+done