From fe2c59e06a42b57340158549cd50a3a46cfc5001 Mon Sep 17 00:00:00 2001 From: Lee Duncan Date: Mon, 4 Apr 2022 11:06:36 -0700 Subject: 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. --- etc/systemd/ibft-rule-generator | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 etc/systemd/ibft-rule-generator 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 -- cgit v1.2.1