Comment # 18 on bug 1173402 from
(In reply to Thomas Blume from comment #16)
> (In reply to Fabian Vogt from comment #15)
> > > Hm, did you check the latest code?
> > > There is:
> > > 
> > > if [ $? -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}*)" ]; then
> > > 
> > > the leasinfo file won't be there if there was no dhcp setup.
> > 
> > Yes, but the use of $? there is still wrong AFAICT.
> 
> Ah, you mean when there is no ip= option at all and no bootdev either?

No, that "$?" is wrong because there is an if preceding it.
Example:
if false; then false; fi
echo $? # 0

So using $? after an if is not working as expected here, it will only indicate
the exit code of "do_dhcp -4" or "do_dhcp", but never of "do_dhcp -6".

> But how should the network get set up via ifup then?
> Using rd.neednet without specifying an interface would make the script bail
> out early:
> 
> -->
> # Huh? No $1?
> [ -z "$1" ] && exit 1
> --<
> 
> There is the ifname boot parameter, but that is again covered in another
> script, e.g. parse-ifname.sh.

ifup.sh is called by udev for each interface, so $1 is always set.
Just "rd.neednet=1" works fine.

> > Not tested, but would that just move the "dhcp twice" case to netroot only?
> > There's nothing which prevents the "# no ip option directed at our
> > interface?"
> > block from running after "# No ip lines default to dhcp" as the former
> > doesn't
> > touch /tmp/net.${netif}.up, does it?
> 
> Maybe, I'm overlooking something but AFAICS, the second if would call
> do_dhcp only when bootdev is set or ip=dhcp(6);

Indeed, so that would probably work. It's totally not obvious though.

> -->
>     if [ -e /tmp/net.bootdev ]; then
>         BOOTDEV=$(cat /tmp/net.bootdev)
>         if [ "$netif" = "$BOOTDEV" ] || [ "$BOOTDEV" = "$(cat
> /sys/class/net/${netif}/address)" ]; then
>             load_ipv6
>             do_dhcp
>         fi
>     else
>         if getargs 'ip=dhcp6'; then
>             load_ipv6
>             do_dhcp -6
>         fi
>         if getargs 'ip=dhcp'; then
>             do_dhcp -4
>         fi
>     fi
> --<
> 
> So, it shouldn't run again after the "# No ip lines default to dhcp" part.
> But it would write did-setup, which is fine since it could have been setup
> in "# No ip lines default to dhcp".

Yay, spaghetti...

> Please note I appreciate your comments and will try to addess them as best
> as possible, but without breaking anything working.
> Unfortunately code changes here are very delicate since it has a big impact
> on netboot.

Yep, this is the reverse-engineering part of cleanup ;-)

I don't see any downside to merging the "# No ip lines default to dhcp" block
with the "# no ip option directed at our interface?" one down below, it would
make the various options and flows much more obvious.


You are receiving this mail because: