:: Re: [DNG] ascii an waiting for dhcp…
トップ ページ
このメッセージを削除
このメッセージに返信
著者: Dr. Nikolaus Klepp
日付:  
To: dng
題目: Re: [DNG] ascii an waiting for dhcp on boot
Am Montag, 18. Dezember 2017 schrieb Didier Kryn:
> Le 18/12/2017 à 11:42, Dr. Nikolaus Klepp a écrit :
> > Am Montag, 18. Dezember 2017 schrieb Didier Kryn:
> >> Le 18/12/2017 à 09:01, Dr. Nikolaus Klepp a écrit :
> >>>>>>> Apply this patch to /lib/udev/ifupdown-hotplug-original. It changes line 78 from
> >>>>>>>     
> >>>>>>>     exec ifup --allow=hotplug $INTERFACE

> >>>>>>>
> >>>>>>> to
> >>>>>>>
> >>>>>>>        if [ -z "${INTERFACE##eth[0-9]*}" ]; then
> >>>>>>>            if [ $(cat /sys/class/net/$INTERFACE/carrier) -eq 1 ]; then
> >>>>>>>                    exec ifup --allow=hotplug $INTERFACE
> >>>>>>>            fi
> >>>>>>>        else
> >>>>>>>            exec ifup --allow=hotplug $INTERFACE
> >>>>>>>        fi

> >>>>>>>
> >>>>>>>
> >>>>>>> Which hopefully brings up eth[0-9]* if the cable is plugged in. Most likely it would be a speed improvement if the lines "exec ifup --allow=hotplug $INTERFACE" are changed to "exec ifup --allow=hotplug $INTERFACE &", but this works for me. It won't work if your eth is not called eth[0-9]* :-)
> >>>>>>
> >>>>>>> Nik
> >>>>>>>
> >>>>>>>
> >>>>> Just saw a typo in my mail: the file is "/lib/udev/ifupdown-hotplug" (not "/lib/udev/ifupdown-hotplug-original").
> >>>>        Now it launches dhclient on eth0 right away, which incurs some
> >>>> delay before it goes to background. Shorther than before, but still a delay.

> >>>>
> >>>>        Didier
> >>> I think you tried the version without "&" at the end of "exec ifup --allow=hotplug $INTERFACE". Could you please edit the two lines (80 and 83) in "/lib/udev/ifupdown-hotplug" so that they say "exec ifup --allow=hotplug $INTERFACE &" - i.e. add the "&" at the end and try again?
> >>       I fact, my situation wasn't the same as the one you reported in the
> >> first place. The message on the console was the following:

> >>
> >>     Configure network interfaces...ifup: waiting for lock on
> >> /run/network/ifstate.eth0
> >>     This has now disapeared and I am dealing with waiting on DHCP for
> >> an interface without any cable plugged in.
> >>
> >>     I wondered if there was an interplay with ifplugd there.
> >>
> >>     I tried disabling all interfaces in ifplugd and the result was the
> >> same.
> >>
> >>     Then I introduced some debug prints in ifupdown-hotplug to debug
> >> the logic:
> >> ...
> >>     printf 'ifupdown-hotplug invoked for interface %s\n' "$INTERFACE"
> >> >/run/$INTERFACE.log;
> >>
> >>     if [ -z "${INTERFACE##eth[0-9]*}" ]; then
> >>         if [ $(cat /sys/class/net/$INTERFACE/carrier) -eq 1 ]; then
> >>             printf 'Carrier detected; setting up.\n' >>/run/$INTERFACE.log
> >>             exec ifup --allow=hotplug $INTERFACE &
> >>         else
> >>             printf 'No carrier; do not set up.\n' >>/run/$INTERFACE.log;
> >>         fi
> >>     else
> >>         printf 'Not an ethernet interface; setting up.\n'
> >> >>/run/$INTERFACE.log;
> >>         exec ifup --allow=hotplug $INTERFACE &
> >>     fi
> >>   ...
> >>
> >> The result is as expected:
> >> $ cat /run/eth0.log
> >> ifupdown-hotplug invoked for interface eth0
> >> No carrier; do not set up.
> >>
> >>     DHCPDISCOVER is probably launched by the caller of
> >> ifupdown-hotplug. I tried to exit with return-code 1 in case the carrier
> >> isn't detected, but this has no effect.
> >>
> >>     Didier
> > Well, yes, that's to expect, but does it also block the boot process? And do you get an IP adress, when, you plug in a cable later?
>     With ifplugd uninstalled, I get an ipv6 address on eth0 when I plug
> a cable. This address persists after the cable is removed. After
> re-installing ifplugd, as expected, I need to ifup/ifdown eth0 for the
> situation to change and I get IPV6 and IPV4 addresses on eth0.
>
>     I'm not sure I understand well what's happening with this network
> initialization, but don't you think the most logical place to check for
> carrier presence is just where dhclient is invoked?
>
>         Didier


Hi!

That is a good question. I think dhclient should not be called, when no cable is present. Looks like ifplugd is of different opinion. When I read the sources of ifplugd correctly, then the package installes a file "ifplugd.action". In this file line 27 says:

    [ "$2" = "up" ] && exec /sbin/ifup $1


Now change this line to

    if [ -z "${1##eth[0-9]*}" ]; then
        if [ $(cat /sys/class/net/$1/carrier) -eq 1 ]; then
            exec /sbin/ifup $1
        fi
    fi


Please try this (hope I have no typo).

Nik


--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...