FS#13334 - [netcfg] PRE_UP not working properly with ifconfig

Attached to Project: Arch Linux
Opened by Fabio Zanini (iosonofabio) - Tuesday, 17 February 2009, 10:29 GMT
Last edited by James Rayner (iphitus) - Saturday, 27 June 2009, 01:49 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To James Rayner (iphitus)
Architecture i686
Severity Low
Priority Normal
Reported Version None
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

After I boot my system and log in (TTY or X-server), I have to execute netcfg TWICE to get my ethernet connection to work:

$ sudo netcfg eth
Password:
:: eth up - No connection available [FAIL]
$ sudo netcfg eth
:: eth up [DONE]
$

I put an 'ifconfig eth0 up' command into PRE_UP (see below). After this, every other attempt to load the profile works. The bug is seen only in the first attempt after boot.

Additional info:
* package version(s)

core/netcfg 2.1.2-1

* config and/or log files etc.

My ethernet profile is /etc/network.d/eth and look like this:

CONNECTION="ethernet"
DESCRIPTION="using dhcp"
INTERFACE=eth0
IP="dhcp"
DHCP_TIMEOUT=10
PRE_UP='sudo ifconfig eth0 up'
POST_DOWN='sudo ifconfig eth0 down'

I also tried with double quotes "" instead of single quotes ''. Same problem. Also tried with POST_UP instead of PRE_UP. Same problem.

Steps to reproduce:

I'm using netcfg to manage both ethernet and wireless. network daemon is not started at boot (see wiki). Neither net-profiles nor net-auto are started at boot.
This task depends upon

Closed by  James Rayner (iphitus)
Saturday, 27 June 2009, 01:49 GMT
Reason for closing:  Works for me
Comment by Jan de Groot (JGC) - Tuesday, 17 February 2009, 11:14 GMT
why are you using sudo inside a program that is supposed to be run as root?
Also, it could be that your networkcard is a bit slow in getting the link up, could you try to change the PRE_UP to "ifconfig eth0 up && sleep 1"?
Comment by Fabio Zanini (iosonofabio) - Tuesday, 17 February 2009, 12:28 GMT
Hi!
The sudo before ifconfig is not necessary, I just put it for oversecurity. I tried the suggestion you say, but it doesn't change. Moreover, if I take the ethernet interface down after it has worked once, and then reput it up, it works as supposed to.

That is, if the eth card is slow, it is slow just the first time after booting, every other time is just quick enough. Strange, isn't it?
Comment by Fabio Zanini (iosonofabio) - Tuesday, 17 February 2009, 14:06 GMT
Retried your suggestion with a longer time, namely:

PRE_UP='ifconfig eth0 up && sleep 3'

now it works. It needs in total 10 seconds to connect, but it works. I tick the bug as solved, even if that is not completely true.
Thanks
Comment by Jan de Groot (JGC) - Tuesday, 17 February 2009, 14:08 GMT
This looks like the same issue I have with the networkcard in this machine. When my machine boots up from a cold boot, it takes several seconds before the interface comes really up. This makes dhcpcd timeout on bootup now and then. It's not only limited to linux, my collegue running Vista on the same type of machine has replaced his onboard Intel e1000 NIC with a realtek 8139 already because of this.
Comment by Greg (dolby) - Tuesday, 17 February 2009, 14:18 GMT Comment by James Rayner (iphitus) - Wednesday, 18 February 2009, 10:35 GMT
The newer netcfg packages don't have a sleep, so they probably won't make much of a difference

Fabio: Would you be able to blacklist your ethernet driver, and then run this for me after boot. Run it as a script, not individual commands as I want the output of ip at each time.

modprobe drivername
ip link
sleep 1
ip link
sleep 20
ip link

I'm just curious if ip shows any indication that the driver is not ready. In the meantime you could also push networking back in your startup.
Comment by Fabio Zanini (iosonofabio) - Wednesday, 18 February 2009, 14:52 GMT
Let's go! I copied your command in a bash script, blacklisted my e1000e ethernet driver and started the script after logging into X. Put the stout into attachment (ethcheck.log).

From what I can understand, everything looks ok. Anyway, now the netcfg is working with 2 second sleep instead of 3; this is 33% better :-) (this is indipendent from loading the module at boot time or later).
Comment by Jan de Groot (JGC) - Wednesday, 18 February 2009, 14:57 GMT
try adding an "ifconfig eth0 up" command after loading the module. If the interface isn't configured, ip link will show it as down, no matter how much time you spend sleeping in the script.
Comment by Fabio Zanini (iosonofabio) - Thursday, 19 February 2009, 14:18 GMT
Ok guys, I modified the script as shown in attachment (ethcheck2.sh) loading also ifconfig eth0. Now it looks quite strange, since one of the middle states is UNKNOWN. Have a look at the stout (ethcheck2.log). Thanks.
Comment by Jan de Groot (JGC) - Thursday, 19 February 2009, 15:19 GMT
ok, just what I expected. It takes a while to detect link on your system. This could be a limitation in your networkcard, a limitation in the e1000e driver, or a problem with autonegotiation between your networkcard and the switch.
Comment by James Rayner (iphitus) - Friday, 20 February 2009, 12:21 GMT
Would it be a good idea to add a check by default or just as an opt-in "quirk"?

It's possible other hardware might have similar issues, like wireless hardware loading firmware.

while ip link show $INTERFACE|grep -q "state UNKNOWN";
do
sleep 0.5
done

(except without infinite loop chance)
Comment by Fabio Zanini (iosonofabio) - Friday, 20 February 2009, 13:24 GMT
Yes, this can be a good idea, but I would state it differently, i.e. something like (syntax maybe wrong):

while !(ip link show $INTERFACE|grep -q "state UP")
do
sleep 0.5
done

Another option could be to add a line similar to the IWCONFIG for wireless.

I don't think that adding a sleep by default is a good idea; network cards are generally quick, they would be delayed.
Comment by James Rayner (iphitus) - Tuesday, 03 March 2009, 08:31 GMT
Not closing this yet, someone has filed a second bug which may be related.

I'm not sure whether this could affect more drivers than just e1000e, or whether drivers are legitimately allowed to take this time.
Comment by Nathanael Schaeffer (john_schaf) - Sunday, 22 March 2009, 00:10 GMT
Hello,

I seem to have a similar problem : "netcfg eth" has to be run twice to work with my ethernet connection.
- I use netcfg 2.1.3-2
- my driver is sky2
- I tried to add PRE_UP as stated above (even with sleep 5)
- I run the ethcheck2 script, and link is UP 2 seconds after ifconfig.

May I suggest a simple (yet unelegant) workaround : if first attempt fails, re-run everything from beggining.

Otherwise netcfg rocks !
Comment by Fabio Zanini (iosonofabio) - Sunday, 22 March 2009, 05:50 GMT
Well, you could try with very high values for sleep (like 10 sec or more), see whether it works, then try with shorter values and find the threshold of your card. Maybe you could write a script to execute netcfg and contemporareously check the status of your card.

IMHO, an elegant solution would be to add a grep UP to the netcfg script, but I do not know whether it is a feasible solution for the programmer (Iphitus?)
Comment by James Rayner (iphitus) - Tuesday, 28 April 2009, 12:45 GMT
There's an attempt to patch this in the latest git.
Comment by James Rayner (iphitus) - Saturday, 06 June 2009, 02:17 GMT
ok, while that might have fixed it for some, it's broken it for others[1]. In that forum post it seems to continually report "UNKNOWN"

Some more changes for this in -b3.

[1] http://bbs.archlinux.org/viewtopic.php?pid=563710#p563710

Loading...