This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 110164 - Long delay when initializing network card when cable is not connected
Long delay when initializing network card when cable is not connected
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-11-15 13:06 EST by Roel Gloudemans
Modified: 2014-03-16 22:40 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-11-17 15:29:48 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch for /etc/sysconfig/network-scripts/network-functions (1.75 KB, patch)
2003-11-15 13:07 EST, Roel Gloudemans
no flags Details | Diff
patch against Fedora Core 3 network-functions (1.22 KB, patch)
2004-11-14 19:25 EST, David Baron
no flags Details | Diff

  None (edit)
Description Roel Gloudemans 2003-11-15 13:06:37 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5)
Gecko/20031007 Firebird/0.7

Description of problem:
I'm using a laptop with wireless pcmcia card (eth1) at home and wired
to eth0 at work.

When using the wireless card it eth0 is still started during boot.
This is normal expected behavoir. Under RH9 it would be detected that
there is no link. Fedora however doesnot and starts dhclient, which
will fail. But it takes a long time to do so.

To help things along I fixed the error. The patch is attached to this
report. See additional information for the innards of the patch

Version-Release number of selected component (if applicable):
initscripts-7.42-1

How reproducible:
Always

Steps to Reproduce:
1.Boot without a network cable connected
2.
3.
    

Actual Results:  A long gray beard ;)

Expected Results:  No link detected after several seconds

Additional info:

The patch contains a fix for
/etc/sysconfig/network-scripts/network-functions

Main patch is in check_link_down function
check_link_down ()
{
    if [ -x /sbin/mii-tool -o -x /sbin/ethtool ]; then
        if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then
# Forget the above if statement. Due to hotplug the network is 
# brought up when modprobing the networking card. Thus ifup is started
# twice when starting /etc/init.d/network when no module is loaded 
# When one ifup is working, the second one will think the link is up
           ip link set dev $1 up >/dev/null 2>&1
           timeout=0
           while [ $timeout -le 10 ]; do
                check_mii_tool $1
                m=$?
                check_ethtool $1
                e=$?
                if [ $m -eq 1 ] || [ $e -eq 1 ] ; then
# The above statement should use && instead of ||. During link 
# negotiation the link will appear and disappear several times
# using and && will let things die out a bit before forging ahead
# (this is notably a problem when using ifplugd)
# However the check_mii_tool and check_ethtool should be modified
# because of this (what when one of the tools in not present)
                    return 1
                fi
                if [ $m -eq 2 ] && [ $e -eq 2 ] ; then
                    return 1
                fi
                usleep 500000
                timeout=$((timeout+1))
           done
           return 0
        fi
# remove above fi
    fi
    return 1
}

check_ethtool ()
{
   [ -x /sbin/ethtool ] || return 2
# Above line should be [ -x /sbin/ethtool ] || return 1
# same for check_mii_tool
Comment 1 Roel Gloudemans 2003-11-15 13:07:49 EST
Created attachment 95994 [details]
Patch for /etc/sysconfig/network-scripts/network-functions
Comment 2 Bill Nottingham 2003-11-17 15:29:48 EST
The patch changes the semantics of ethtool/mii-tool not being
installed to mean 'immediately assume the link is up'.

That's the wrong behavior.
Comment 3 Roel Gloudemans 2003-11-18 01:10:58 EST
The result is the same in the old script. The return value of 2 also
leads to the assumption the link is up.

Anyway, wathever the solution may be, I think the current script is
bugged. I don;'t wan't to wait for a minute (!) before the boot
process resumes (especially since Fedora Core 1 is partially targeted
at laptop users; laptop mode patch)
Comment 4 Roel Gloudemans 2003-11-18 08:10:23 EST
OK, new solution
Drop the modifications in check_ethtool and check_mii_tool. In the
patch for check_link_down modify
>while [ $timeout -le 10 ]; do
>  	check_mii_tool $1
>	m=$?
>	check_ethtool $1
>	e=$?
>	if [ $m -eq 1 ] && [ $e -eq 1 ] ; then
>	    return 1
>	fi
>	if [ $m -eq 2 ] && [ $e -eq 2 ] ; then
>	    return 1
>	fi
>	usleep 500000
>	timeout=$((timeout+1))
>   done

in

>while [ $timeout -le 10 ]; do
>  	check_mii_tool $1
>	m=$?
>	check_ethtool $1
>	e=$?
>	if [ $m -gt 0 ] && [ $e -gt 0 ] ; then
>	    return 1
>	fi
>	usleep 500000
>	timeout=$((timeout+1))
>   done

Which does the same as the original patch and satisfies your comments
on the original patch.
Comment 5 Bill Nottingham 2003-11-18 11:04:05 EST
Sorry, reading back at your original comments:

        if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then
# Forget the above if statement. Due to hotplug the network is 
# brought up when modprobing the networking card. Thus ifup is started
# twice when starting /etc/init.d/network when no module is loaded 
# When one ifup is working, the second one will think the link is up

Hotplug is *disabled* in /etc/init.d/network.

# The above statement should use && instead of ||. 

No. That requires that any adapter support *both* methods, and that
both methods reliably report the same data (in many cases, they
don't.) If you've changed it as such, it *will* lead to longer startup
times.
Comment 6 Roel Gloudemans 2003-11-20 01:19:44 EST
 sysctl -w kernel.hotplug="/bin/true" > /dev/null 2>&1

in /etc/init.d/network before ifup is executed. Also after modprobing
the network module ifup is started.

The second solution with the if statements is better than the original
one. It does exactly the same with less statements.
Comment 7 Bill Nottingham 2003-11-20 02:32:25 EST
'The second solution'? Which particular one are you referring to - all
the solutions I've seen so far are based on the original false premises.
Comment 8 Roel Gloudemans 2003-11-20 02:41:44 EST
I'm referring to the changes in comment #4, in which check_mii_tool en
check_ethtool are unchanged.

The if constructs in check_link_down are only based on a specific link
down detection (first and second if construct in the while loop are
mashed together). I don't know if you count that as a false premise.

(OMG. Look at the time of your response; 02:32)
Comment 9 David Baron 2004-11-14 19:22:44 EST
I don't have the ability to reopen this bug, but I experienced the
same regression when upgrading from RH9 to FC1, and it persisted in
FC2 and FC3.  The necessary patch seems to me to be moving a single
line -- I'm not sure what all the other proposed changes by the bug
reporter were for.

(I previously blamed this issue on a change of network driver, since
the machine in question has a Broadcom 4400, and that upgrade was when
I switched from compiling the bcm4400 driver to using the provided b44
driver.)

The problem seems to be that the test in check_link_down:
  if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP
leads to most of the function being skipped.  I'm not sure why the
whole function gets skipped when the link is reported as "UP", or what
the exact semantics of being "UP" are, but when doing "ifup eth0" with
my b44, it's "UP" at this point in check_link_down (even though it
wasn't before doing "ifup eth0").

I'll attach that patch shortly.
Comment 10 David Baron 2004-11-14 19:25:17 EST
Created attachment 106686 [details]
patch against Fedora Core 3 network-functions

This is the patch mentioned in the previous comment, with appropriate
reindenting (and fixes for a bit of the indentation in the function being
off-by-one).

As a |diff -U10 -b| it looks like this (much clearer):

 check_link_down ()
 {
     if [ -x /sbin/mii-tool -o -x /sbin/ethtool ]; then
	 if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then
	   ip link set dev $1 up >/dev/null 2>&1
+	fi
	   timeout=0
	   while [ $timeout -le 10 ]; do
		check_mii_tool $1
		m=$?
		check_ethtool $1
		e=$?
		if [ $m -eq 1 ] || [ $e -eq 1 ] ; then
		    return 1
		fi
		if [ $m -eq 2 ] && [ $e -eq 2 ] ; then
		    return 1
		fi
		usleep 500000
		timeout=$((timeout+1))
	   done
	   return 0
-	fi
     fi
     return 1
 }
Comment 11 Bill Nottingham 2004-11-14 22:59:46 EST
Added, will be in 7.97-1
Comment 12 Tim Powers 2005-05-18 11:35:55 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2005-123.html

Note You need to log in before you can comment on or make changes to this bug.