File kdump-net-0014-global-kdump_iface.patch of Package kdump

From: Petr Tesarik <ptesarik@suse.com>
Date: Mon, 12 Sep 2016 17:08:03 +0200
Subject: Add global variable kdump_iface
References: bsc#980328
Patch-mainline: v0.8.16
Git-commit: 07bf605036d4f73bd9aee222a1f4855c46c7ff00

Rename iface to kdump_iface and make it global. This allows setting
and using the variable from two different functions. The rename is
needed to protect the innocent in a global name space...

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
 init/module-setup.sh       | 11 +++++------
 init/setup-kdump.functions | 42 +++++++++++++++++++++---------------------
 2 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/init/module-setup.sh b/init/module-setup.sh
index 18613db..aefaece 100755
--- a/init/module-setup.sh
+++ b/init/module-setup.sh
@@ -79,23 +79,22 @@ kdump_cmdline_ip() {
     [ "$_if" = "default" ] && _if=$(kdump_default_netdev)
     [ "$_mode" = "auto" ] && _mode=$(kdump_netdev_mode "$_if")
 
-    local iface
     kdump_ifname_config "$_if"
 
     case "$_mode" in
 	static)
 	    printf " %s" \
-		$(kdump_ip_config "$_if" "$iface") \
-		$(kdump_ip6_config "$_if" "$iface")
+		$(kdump_ip_config "$_if" "$kdump_iface") \
+		$(kdump_ip6_config "$_if" "$kdump_iface")
 	    ;;
 	dhcp|dhcp4)
-	    echo " ip=${iface}:dhcp"
+	    echo " ip=${kdump_iface}:dhcp"
 	    ;;
 	dhcp6)
-	    echo " ip=${iface}:dhcp6"
+	    echo " ip=${kdump_iface}:dhcp6"
 	    ;;
 	auto6)
-	    echo " ip=${iface}:auto6"
+	    echo " ip=${kdump_iface}:auto6"
 	    ;;
 	*)
 	    derror "Wrong KDUMP_NETCONFIG mode: $_mode"
diff --git a/init/setup-kdump.functions b/init/setup-kdump.functions
index 533e7bb..a63dc9d 100644
--- a/init/setup-kdump.functions
+++ b/init/setup-kdump.functions
@@ -253,7 +253,7 @@ function kdump_list_slaves()						   # {{{
 # Output:
 #   corresponding bridge= initrd parameter and dependencies
 # Output variables:
-#   iface  device name in initrd
+#   kdump_iface  device name in initrd
 function kdump_bridge_config()						   # {{{
 {
     local bridge="$1"
@@ -274,13 +274,13 @@ function kdump_bridge_config()						   # {{{
     for if in $curslaves
     do
 	kdump_ifname_config "$if" || continue
-	slaves="$slaves $iface"
+	slaves="$slaves $kdump_iface"
     done
-    iface="$bridge"
+    kdump_iface="$bridge"
     [ -n "$slaves" ] || return 1
 
     slaves="${slaves# }"
-    echo -n " bridge=$iface:${slaves// /,}"
+    echo -n " bridge=$kdump_iface:${slaves// /,}"
 }									   # }}}
 
 #
@@ -291,7 +291,7 @@ function kdump_bridge_config()						   # {{{
 # Output:
 #   corresponding bond= initrd parameter and dependencies
 # Output variables:
-#   iface  device name in initrd
+#   kdump_iface  device name in initrd
 function kdump_bond_config()						   # {{{
 {
     local bond="$1"
@@ -388,13 +388,13 @@ function kdump_bond_config()						   # {{{
     for if in $curslaves
     do
 	kdump_ifname_config "$if" || continue
-	slaves="$slaves $iface"
+	slaves="$slaves $kdump_iface"
     done
-    iface="$bond"
+    kdump_iface="$bond"
     [ -n "$slaves" ] || return 1
     slaves="${slaves# }"
 
-    echo -n " bond=$iface:${slaves// /,}:${opts#,}"
+    echo -n " bond=$kdump_iface:${slaves// /,}:${opts#,}"
 }									   # }}}
 
 #
@@ -417,7 +417,7 @@ function kdump_link2vlan()                                                # {{{{
 # Output:
 #   corresponding vlan= initrd parameter and dependencies
 # Output variables:
-#   iface  device name in initrd
+#   kdump_iface  device name in initrd
 #
 # Because of dracut limitations for vlan interface naming, the initrd
 # interface name may be different from the original name.
@@ -442,8 +442,8 @@ function kdump_vlan_config()						   # {{{
     fi
 
     kdump_ifname_config "$if"
-    iface="$if.$vid"
-    echo -n " vlan=$iface:$if"
+    kdump_iface="$if.$vid"
+    echo -n " vlan=$kdump_iface:$if"
 }									   # }}}
 
 # Get the ifname parameter for a given device
@@ -453,33 +453,33 @@ function kdump_vlan_config()						   # {{{
 # Output:
 #   ifname corresponding ifname= initrd parameter (or empty)
 # Output variables:
-#   iface  device name in initrd
+#   kdump_iface  device name in initrd
 function kdump_ifname_config()						   # {{{
 {
-    iface="$1"
-    local ifkind=$(kdump_ifkind "$iface")
+    kdump_iface="$1"
+    local ifkind=$(kdump_ifkind "$kdump_iface")
 
     if [ -z "$ifkind" ]
     then
 	local hwaddr
-	local addrtype=$(<"/sys/class/net/$iface/addr_assign_type")
+	local addrtype=$(<"/sys/class/net/$kdump_iface/addr_assign_type")
 	if [ "$addrtype" -eq 0 ]
 	then
-	    hwaddr=$(<"/sys/class/net/$iface/address")
+	    hwaddr=$(<"/sys/class/net/$kdump_iface/address")
 	else
-	    hwaddr=$(ethtool -P "$iface" | sed 's/^[^:]*: *//')
+	    hwaddr=$(ethtool -P "$kdump_iface" | sed 's/^[^:]*: *//')
 	fi
-	[ -n "$hwaddr" ] && echo -n " ifname=$iface:$hwaddr"
+	[ -n "$hwaddr" ] && echo -n " ifname=$kdump_iface:$hwaddr"
     else
 	case "$ifkind" in
 	    bridge)
-		kdump_bridge_config "$iface"
+		kdump_bridge_config "$kdump_iface"
 		;;
 	    bond)
-		kdump_bond_config "$iface"
+		kdump_bond_config "$kdump_iface"
 		;;
 	    vlan)
-		kdump_vlan_config "$iface"
+		kdump_vlan_config "$kdump_iface"
 		;;
 	    *)
 		return 1
-- 
2.6.6


openSUSE Build Service is sponsored by