:: Re: [DNG] ascii an waiting for dhcp…
Pàgina inicial
Delete this message
Reply to this message
Autor: Didier Kryn
Data:  
A: dng
Assumpte: Re: [DNG] ascii an waiting for dhcp on boot
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