ifplugd does not detect link up

Denys Vlasenko vda.linux at googlemail.com
Fri Jan 8 10:43:44 UTC 2010


>> On Thu, Jan 7, 2010 at 1:41 PM, Ladislav Michl <Ladislav.Michl at seznam.cz> wrote:
>> > Busybox's ifplugd was a bit modified since derived from its original and now
>> > it no longer works with smc91x (linux-2.6.32). After cable removal and
>> > interface deconfiguration so subsequent link up is reported. Change
>> > responsible for this behaviour is listed bellow. Could we revert this change
>> > (or eventually add an option for that)?
>>
>> I want it to be documented. I think I disabled it because
>> I was puzzled when ifplugd kept upping the interface.
>>
>> Let's confirm it: the device which you have problem with
>> says "using IFF_RUNNING detection mode", right?
>
> ifplugd(eth0): using SIOCETHTOOL detection mode

This throws everything in my line of thought off-balance.
Pity you did not show ifplugd output at once.

>> It means that when cable is unplugged, interface cannot be "upped",
>> and this is used to detect that. With unfortunate effect that now admin
>> cannot set "up/down" status as he pleases.
>>
>> Can you check this by doing "ip l set dev ethN up; ip l l"
>> and seeing whether device is up or not, with and without cable inserted?
>
> (lo interface snipped)
>
> [Interface deconfigured, cable plugged or unplugged]
> # ip l l
> 2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast qlen 1000
>    link/ether 00:50:c2:81:fe:78 brd ff:ff:ff:ff:ff:ff

Aha. In this case, the interface doesn't report LOWER_UP even if link is up.
So IFF mode will indeed require iface to be UP for detection to work.

However. ETHTOOL mode does not use LOWER_UP as a detection mechanism, it uses:
static smallint detect_link_ethtool(void)
{
        struct ifreq ifreq;
        struct ethtool_value edata;
        set_ifreq_to_ifname(&ifreq);
        edata.cmd = ETHTOOL_GLINK;
        ifreq.ifr_data = (void*) &edata;
        if (network_ioctl(SIOCETHTOOL, &ifreq) < 0) {
                bb_perror_msg("ETHTOOL_GLINK failed");
                return IFSTATUS_ERR;
        }
        return edata.data ? IFSTATUS_UP : IFSTATUS_DOWN;
}

and I just checked:

# ./busybox ifplugd -nsa -r true
    (I run "ip l set dev eth0 down" in another xterm)
ifplugd(eth0): link is down
ifplugd(eth0): link is up

ETHTOOL momentarily sees "down", but in ~1 second it again sees
that link is up, even though "ip l" doesn't show UP or LOWER_UP:

2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:0d:87:03:94:40 brd ff:ff:ff:ff:ff:ff

Thus at least on some machines ETHTOOL does not require
upping of the iface in order to detect link state.

What happens if you do the same experiment on your machine?
--
vda


More information about the busybox mailing list