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