Bug in net.eth0?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Bug in net.eth0?

Hareesh Nagarajan-3

Some verison info:
Version: # $Header:
/home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.41 2004/05/10
14:16:35 agriffis Exp $

Some background info:
I have my ethernet driver compiled into my kernel.

hareesh: hareesh/ $ lspci | grep Ethernet
0000:00:12.0 Ethernet controller: National Semiconductor Corporation
DP83815 (MacPhyter) Ethernet Controller

The problem:
After I shutdown my eth0 interface I see an UP in the ifconfig output.

hareesh: hareesh/ $ s ifconfig eth0 down
hareesh: hareesh/ $ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0F:20:C7:25:5C
          RX packets:28225 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24421 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:22196299 (21.1 Mb)  TX bytes:4732287 (4.5 Mb)

The /etc/init.d/net.eth0 script does the following check:

status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
if [[ ${status_IFACE} == up ]]; then
        einfo "Keeping kernel configuration for ${IFACE}"
        ebegin "Bringing ${IFACE} up via DHCP"
        /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}

So when I do the following, I get:
# /etc/init.d/net.eth0 start
 * Keeping kernel configuration for eth0

So as we can see, the script hasn't given my interface an IP.

Obviously, when I do this, I get:
hareesh: hareesh/ $ wget www.google.com
--14:09:55--  http://www.google.com/
           => `index.html'
Resolving www.google.com... failed: Temporary failure in name resolution.

So then, I do:
# /etc/init.d/net.eth0 stop
 * Bringing eth0 down...

So I guess, if you have the ethernet driver compiled in, ifconfig
<interface> still seems to show UP, no idea why. So I think, the
script needs to be modified to test if, ifconfig spits a line with
'inet', to truly test if the interface is up.

More importantly, UP just says that the device is functioning
correctly and does not say that interface actually has an IP address
assigned to it. So we need something more to rely on, to actually test
if the interface is up and running with an IP address assigned to it.

My modifications are as follows. This script, is just a hack, so all
you bash gurus please forgive me. Maybe there is a better way of doing
all this with the help of the /proc interface:

--- /etc/init.d/net.eth0.1      2005-11-17 12:55:47.000000000 -0800
+++ /etc/init.d/net.eth0        2005-11-17 14:09:33.000000000 -0800
@@ -50,8 +50,13 @@
 #      ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
 setup_vars() {
        local i iface="${1//\./_}"
-       status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP"
{print "up"}')"
+       #status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP"
{print "up"}')"
+       temp_IFACE="$(ifconfig  ${1} | gawk '{print $1}' | head -n 2 |
tr '\n' '_')"
+       if [[ ${temp_IFACE} == "${1}_inet_" ]]; then
+               status_IFACE=up
+       else
+               status_IFACE=
+       fi
        eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
        eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
        eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"

Now, when I execute the script, I get the following:

# s /etc/init.d/net.eth0 start
 * Bringing eth0 up via DHCP...[ ok ]
 *   eth0 received address

So is this a bug in net.eth0 or am I missing something obvious?



[hidden email] mailing list

Reply | Threaded
Open this post in threaded view

Re: Bug in net.eth0?

Neil Bothwick
On Thu, 17 Nov 2005 15:01:29 -0800, Hareesh Nagarajan wrote:

> Version: # $Header:
> /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.41 2004/05/10
> 14:16:35 agriffis Exp $

This looks like a very old script. /etc/init.d/net.eth0 should now be a
symlink to net.lo.

Neil Bothwick

Press any key to continue... <click> Except that one..

signature.asc (196 bytes) Download Attachment