Bug 110164

Summary: Long delay when initializing network card when cable is not connected
Product: [Fedora] Fedora Reporter: Roel Gloudemans <roel>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED ERRATA QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 1CC: dbaron, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-11-17 20:29:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch for /etc/sysconfig/network-scripts/network-functions
none
patch against Fedora Core 3 network-functions none

Description Roel Gloudemans 2003-11-15 18:06:37 UTC
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 18:07:49 UTC
Created attachment 95994 [details]
Patch for /etc/sysconfig/network-scripts/network-functions

Comment 2 Bill Nottingham 2003-11-17 20:29:48 UTC
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 06:10:58 UTC
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 13:10:23 UTC
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 16:04:05 UTC
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 06:19:44 UTC
 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 07:32:25 UTC
'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 07:41:44 UTC
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-15 00:22:44 UTC
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-15 00:25:17 UTC
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-15 03:59:46 UTC
Added, will be in 7.97-1

Comment 12 Tim Powers 2005-05-18 15:35:55 UTC
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