From 11cb81590412f1cb835fe05cb792be6cf082dc00 Mon Sep 17 00:00:00 2001 From: WANG Chao Date: Fri, 20 Dec 2013 18:06:17 +0800 Subject: [PATCH] module-setup.sh: do not add duplicate ip=xxx to 40ip.conf In the remote dump case, and if fence kdump is configured, chances are that the same network interface will be setup more than once. One time for network dump, the other times for fence kdump. The result is we will have two or more duplicate ip= configuration in 40ip.conf. These are exactly duplicates, however dracut will refuse to continue and raise a fatal error if there are duplicate configuration for the same interface. So we have to avoid adding these duplicates. Signed-off-by: WANG Chao Tested-by: Zhi Zou Tested-by: Marek Grac Acked-by: Vivek Goyal --- dracut-module-setup.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index a9d223f..0babc65 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -182,7 +182,7 @@ kdump_setup_znet() { # Setup dracut to bringup a given network interface kdump_setup_netdev() { local _netdev=$1 - local _static _proto + local _static _proto _ip_conf _ip_opts _ifname_opts if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev @@ -196,7 +196,14 @@ kdump_setup_netdev() { _proto=dhcp fi - echo " ip=${_static}$_netdev:${_proto}" > ${initdir}/etc/cmdline.d/40ip.conf + _ip_conf="${initdir}/etc/cmdline.d/40ip.conf" + _ip_opts=" ip=${_static}$_netdev:${_proto}" + + # dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. + # so we have to avoid adding duplicates + if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf; then + echo "$_ip_opts" >> $_ip_conf + fi if kdump_is_bridge "$_netdev"; then kdump_setup_bridge "$_netdev" @@ -207,7 +214,8 @@ kdump_setup_netdev() { elif kdump_is_vlan "$_netdev"; then kdump_setup_vlan "$_netdev" else - echo " ifname=$_netdev:$(kdump_get_mac_addr $_netdev)" >> ${initdir}/etc/cmdline.d/40ip.conf + _ifname_opts=" ifname=$_netdev:$(kdump_get_mac_addr $_netdev)" + echo "$_ifname_opts" >> $_ip_conf fi kdump_setup_dns "$_netdev"