Gentoo Archives: gentoo-user

From: Hareesh Nagarajan <hareesh.nagarajan@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Bug in net.eth0?
Date: Thu, 17 Nov 2005 23:09:13
Message-Id: 7728232c0511171501j53defd2bk7a26da4e22134f8d@mail.gmail.com
1 Hi,
2
3 Some verison info:
4 Version: # $Header:
5 /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.41 2004/05/10
6 14:16:35 agriffis Exp $
7
8 Some background info:
9 I have my ethernet driver compiled into my kernel.
10
11 hareesh: hareesh/ $ lspci | grep Ethernet
12 0000:00:12.0 Ethernet controller: National Semiconductor Corporation
13 DP83815 (MacPhyter) Ethernet Controller
14
15 The problem:
16 After I shutdown my eth0 interface I see an UP in the ifconfig output.
17
18 hareesh: hareesh/ $ s ifconfig eth0 down
19 hareesh: hareesh/ $ ifconfig
20 eth0 Link encap:Ethernet HWaddr 00:0F:20:C7:25:5C
21 UP BROADCAST NOTRAILERS MULTICAST MTU:1500 Metric:1
22 RX packets:28225 errors:0 dropped:0 overruns:0 frame:0
23 TX packets:24421 errors:0 dropped:0 overruns:0 carrier:0
24 collisions:0 txqueuelen:1000
25 RX bytes:22196299 (21.1 Mb) TX bytes:4732287 (4.5 Mb)
26 Interrupt:11
27
28 The /etc/init.d/net.eth0 script does the following check:
29
30 <script>
31 status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"
32 [...]
33 if [[ ${status_IFACE} == up ]]; then
34 einfo "Keeping kernel configuration for ${IFACE}"
35 else
36 ebegin "Bringing ${IFACE} up via DHCP"
37 /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}
38 </script>
39
40 So when I do the following, I get:
41 # /etc/init.d/net.eth0 start
42 * Keeping kernel configuration for eth0
43
44 So as we can see, the script hasn't given my interface an IP.
45
46 Obviously, when I do this, I get:
47 hareesh: hareesh/ $ wget www.google.com
48 --14:09:55-- http://www.google.com/
49 => `index.html'
50 Resolving www.google.com... failed: Temporary failure in name resolution.
51
52 So then, I do:
53 # /etc/init.d/net.eth0 stop
54 * Bringing eth0 down...
55
56 So I guess, if you have the ethernet driver compiled in, ifconfig
57 <interface> still seems to show UP, no idea why. So I think, the
58 script needs to be modified to test if, ifconfig spits a line with
59 'inet', to truly test if the interface is up.
60
61 More importantly, UP just says that the device is functioning
62 correctly and does not say that interface actually has an IP address
63 assigned to it. So we need something more to rely on, to actually test
64 if the interface is up and running with an IP address assigned to it.
65
66 My modifications are as follows. This script, is just a hack, so all
67 you bash gurus please forgive me. Maybe there is a better way of doing
68 all this with the help of the /proc interface:
69
70 <patch>
71 --- /etc/init.d/net.eth0.1 2005-11-17 12:55:47.000000000 -0800
72 +++ /etc/init.d/net.eth0 2005-11-17 14:09:33.000000000 -0800
73 @@ -50,8 +50,13 @@
74 # ifconfig_fallback_IFACE (fallback ifconfig if dhcp fails)
75 setup_vars() {
76 local i iface="${1//\./_}"
77 -
78 - status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP"
79 {print "up"}')"
80 + #status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP"
81 {print "up"}')"
82 + temp_IFACE="$(ifconfig ${1} | gawk '{print $1}' | head -n 2 |
83 tr '\n' '_')"
84 + if [[ ${temp_IFACE} == "${1}_inet_" ]]; then
85 + status_IFACE=up
86 + else
87 + status_IFACE=
88 + fi
89 eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"
90 eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )
91 eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"
92 </patch>
93
94 Now, when I execute the script, I get the following:
95
96 # s /etc/init.d/net.eth0 start
97 * Bringing eth0 up via DHCP...[ ok ]
98 * eth0 received address 140.221.222.55
99
100 So is this a bug in net.eth0 or am I missing something obvious?
101
102 Thanks,
103
104 ./hareesh
105
106 --
107 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Bug in net.eth0? Neil Bothwick <neil@××××××××××.uk>