From 013bb485b8a8b836f11a4c2b67f6549899ef393b Mon Sep 17 00:00:00 2001 From: WANG Chao Date: Mon, 22 Sep 2014 15:46:57 +0800 Subject: [PATCH] module-setup: do not add duplicate ip=xxx In case of iscsi boot, kernel cmdline will contain ip=xxx kernel parameter for dracut setting up iscsi root in initramfs. For example: "root=xxx ip=192.168.3.26:::255.255.255.0:localhost.localdomain:eno19:none ..." dracut doesn't allow duplicate ip conf for the same network card. dracut will not ignore the either of the duplicate. Instead, it refuses to continue: [ 15.876306] dracut: FATAL: For argument 'ip=192.168.3.26:::255.255.255.0:localhost.localdomain:eno19:none'\n Duplication configurations for 'eno19' [ 16.055513] dracut: Refusing to continue ev argument for multiple ip= lines That's why in our code we don't add a duplicate ip conf when handling the same network card the second time. But we never consider the case that ip conf is already added in kernel cmdline for some special purpose, for example, iscsi boot. Now we also look up /proc/cmdline for ip conf. If it exists, we use the existing one. The existing one should work out of box because dracut will handle it in second kernel like it does for first kernel. That said, the network card will be brought up and root disk will be mounted under /sysroot. Signed-off-by: WANG Chao Acked-by: Vivek Goyal --- dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 02a0557..38801de 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -234,7 +234,10 @@ kdump_setup_netdev() { # 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 + # We should also check /proc/cmdline for existing ip=xx arg. + # For example, iscsi boot will specify ip=xxx arg in cmdline. + if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ + ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf fi