dracut/0045-network-ifname-genrules.sh-check-for-multiple-ifname.patch
Harald Hoyer 2d3fda91ea dracut-020-51.git20120706
- cope with systemd-udevd unit renaming
- fixed network renaming
- removed dash module
2012-07-06 14:41:00 +02:00

39 lines
1.6 KiB
Diff

From f1e7add2bf74b836bc29d20df2e4e53638e49936 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 6 Jul 2012 12:57:17 +0200
Subject: [PATCH] network/ifname-genrules.sh: check for multiple ifname= lines
---
modules.d/40network/ifname-genrules.sh | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/modules.d/40network/ifname-genrules.sh b/modules.d/40network/ifname-genrules.sh
index d5f8b0f..3cf4be7 100755
--- a/modules.d/40network/ifname-genrules.sh
+++ b/modules.d/40network/ifname-genrules.sh
@@ -12,7 +12,23 @@ command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
{
for p in $(getargs ifname=); do
parse_ifname_opts $p
+
+ if [ -f /tmp/ifname-$ifname_mac ]; then
+ read oldif < /tmp/ifname-$ifname_mac
+ fi
+ if [ -f /tmp/ifname-$ifname_if ]; then
+ read oldmac < /tmp/ifname-$ifname_if
+ fi
+ if [ -n "$oldif" -a -n "$oldmac" -a "$oldif" = "$ifname_if" -a "$oldmac" = "$ifname_mac" ]; then
+ # skip same ifname= declaration
+ continue
+ fi
+
+ [ -n "$oldif" ] && warn "Multiple interface names specified for MAC $ifname_mac: $oldif"
+ [ -n "$oldmac" ] && warn "Multiple MAC specified for $ifname_if: $oldmac"
+
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", NAME="%s"\n' "$ifname_mac" "$ifname_if"
+ echo $ifname_if > /tmp/ifname-$ifname_mac
+ echo $ifname_mac > /tmp/ifname-$ifname_if
done
-
} >> /etc/udev/rules.d/80-ifname.rules