[PATCH] module-setup: do not add duplicate ip=xxx

WANG Chao chaowang at redhat.com
Mon Sep 22 08:09:38 UTC 2014


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. 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 <chaowang at redhat.com>
---
 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..4feeef5 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
+    if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\
+        # We should also check /proc/cmdline for existing ip=xx arg.
+        # For example, iscsi boot will specify ip=xxx arg in cmdline.
+        ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then
         echo "$_ip_opts" >> $_ip_conf
     fi
 
-- 
1.9.3



More information about the kexec mailing list