|
|
a56a5e |
From b990775b6f2fc8eb52d283b0745bea4a71ef751a Mon Sep 17 00:00:00 2001
|
|
|
83bbb1 |
From: Harald Hoyer <harald@redhat.com>
|
|
|
83bbb1 |
Date: Fri, 4 Apr 2014 12:48:03 +0200
|
|
|
83bbb1 |
Subject: [PATCH] ifcfg: do not bind persistent interface names to HWADDR
|
|
|
83bbb1 |
|
|
|
83bbb1 |
(cherry picked from commit fb0e5184a6506185998fd12d151f7d34d07c07b3)
|
|
|
83bbb1 |
---
|
|
|
83bbb1 |
modules.d/40network/net-lib.sh | 27 +++++++++++++++++++++++++++
|
|
|
83bbb1 |
modules.d/45ifcfg/write-ifcfg.sh | 6 +++++-
|
|
|
83bbb1 |
2 files changed, 32 insertions(+), 1 deletion(-)
|
|
|
83bbb1 |
|
|
|
83bbb1 |
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
|
|
|
1755ca |
index 7430e4ce..5d4ae32c 100755
|
|
|
83bbb1 |
--- a/modules.d/40network/net-lib.sh
|
|
|
83bbb1 |
+++ b/modules.d/40network/net-lib.sh
|
|
|
83bbb1 |
@@ -516,3 +516,30 @@ find_iface_with_link() {
|
|
|
83bbb1 |
done
|
|
|
83bbb1 |
return 1
|
|
|
83bbb1 |
}
|
|
|
83bbb1 |
+
|
|
|
83bbb1 |
+is_persistent_ethernet_name() {
|
|
|
83bbb1 |
+ [ -f /sys/class/net/$netif/addr_assign_type ] || return 1
|
|
|
83bbb1 |
+ [ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] || return 1
|
|
|
83bbb1 |
+
|
|
|
83bbb1 |
+ case "$1" in
|
|
|
83bbb1 |
+ # udev persistent interface names
|
|
|
83bbb1 |
+ eth[0-9]|eth[0-9][0-9]|eth[0-9][0-9][0-9]*)
|
|
|
83bbb1 |
+ ;;
|
|
|
83bbb1 |
+ eno[0-9]|eno[0-9][0-9]|eno[0-9][0-9][0-9]*)
|
|
|
83bbb1 |
+ ;;
|
|
|
83bbb1 |
+ ens[0-9]|ens[0-9][0-9]|ens[0-9][0-9][0-9]*)
|
|
|
83bbb1 |
+ ;;
|
|
|
83bbb1 |
+ enp[0-9]s[0-9]*|enp[0-9][0-9]s[0-9]*|enp[0-9][0-9][0-9]*s[0-9]*)
|
|
|
83bbb1 |
+ ;;
|
|
|
83bbb1 |
+ enP*p[0-9]s[0-9]*|enP*p[0-9][0-9]s[0-9]*|enP*p[0-9][0-9][0-9]*s[0-9]*)
|
|
|
83bbb1 |
+ ;;
|
|
|
83bbb1 |
+ # biosdevname
|
|
|
83bbb1 |
+ em[0-9]|em[0-9][0-9]|em[0-9][0-9][0-9]*)
|
|
|
83bbb1 |
+ ;;
|
|
|
83bbb1 |
+ p[0-9]p[0-9]*|p[0-9][0-9]p[0-9]*|p[0-9][0-9][0-9]*p[0-9]*)
|
|
|
83bbb1 |
+ ;;
|
|
|
83bbb1 |
+ *)
|
|
|
83bbb1 |
+ return 1
|
|
|
83bbb1 |
+ esac
|
|
|
83bbb1 |
+ return 0
|
|
|
83bbb1 |
+}
|
|
|
83bbb1 |
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
|
|
|
1755ca |
index 486c69a3..2631fbe2 100755
|
|
|
83bbb1 |
--- a/modules.d/45ifcfg/write-ifcfg.sh
|
|
|
83bbb1 |
+++ b/modules.d/45ifcfg/write-ifcfg.sh
|
|
|
83bbb1 |
@@ -164,7 +164,11 @@ for netup in /tmp/net.*.did-setup ; do
|
|
|
83bbb1 |
{
|
|
|
83bbb1 |
[ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
|
|
|
83bbb1 |
if ! print_s390 $netif; then
|
|
|
83bbb1 |
- [ -n "$macaddr" ] || echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
|
|
|
83bbb1 |
+ if [ -z "$macaddr" ] && \
|
|
|
83bbb1 |
+ ! is_persistent_ethernet_name "$netif" && \
|
|
|
83bbb1 |
+ [ -f /sys/class/net/$netif/address ]; then
|
|
|
83bbb1 |
+ echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
|
|
|
83bbb1 |
+ fi
|
|
|
83bbb1 |
fi
|
|
|
83bbb1 |
echo "TYPE=Ethernet"
|
|
|
83bbb1 |
echo "NAME=\"$netif\""
|