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

WANG Chao chaowang at redhat.com
Tue Sep 23 01:56:12 UTC 2014


On 09/22/14 at 11:24am, Vivek Goyal wrote:
> On Mon, Sep 22, 2014 at 04:09:38PM +0800, WANG Chao wrote:
> > 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
> 
> Chao,
> 
> Minor nit. Can we move comment before the start of line. Now we have
> split the "if line" and put a comment in between. Which is very hard
> to read.

Yeah, sure.

> 
> Secondly, what happens if we end up putting ip= option in ip.conf and
> it is present on command line too. Dracut does not have a mechanism where
> it can ignore one of those?

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

> 
> Thanks
> Vivek
> 
> >          echo "$_ip_opts" >> $_ip_conf
> >      fi
> >  
> > -- 
> > 1.9.3
> > 
> > _______________________________________________
> > kexec mailing list
> > kexec at lists.fedoraproject.org
> > https://lists.fedoraproject.org/mailman/listinfo/kexec


More information about the kexec mailing list