Summary: | net_eth0 script should detect that there is no cable - fix included | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Leo <bugs.gentoo.org> |
Component: | [OLD] Core system | Assignee: | Martin Schlemmer (RETIRED) <azarah> |
Status: | RESOLVED DUPLICATE | ||
Severity: | enhancement | CC: | aalmenar, henrik, ms, pfeifer |
Priority: | High | ||
Version: | 1.4_rc4 | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
new /etc/init.d/net.eth0 with link check
More simpel patch against current CVS Even MORE simple link detection. |
Description
Leo
2003-07-28 22:14:32 UTC
Created attachment 15170 [details]
new /etc/init.d/net.eth0 with link check
*** Bug 26628 has been marked as a duplicate of this bug. *** Created attachment 16370 [details, diff]
More simpel patch against current CVS
I've added a patch I came up with on my own a few days ago. This patch is
against current CVS and I think it conforms better to the coding style used
throughout the init scripts.
I am not saying this is better than the above patch - I am merely saying it's
an alternative.
Here's an even simpler patch -- the link state is reported via ifconfig, which can be caught in setup_env(): --- net.eth0.orig 2003-11-08 11:04:50.000000000 -0800 +++ net.eth0 2003-11-08 10:55:17.000000000 -0800 @@ -33,6 +33,7 @@ inet6_IFACE="$(eval echo \$\{inet6_${iface}\})" alias_IFACE="$(eval echo \$\{alias_${iface}\})" status_IFACE="$(ifconfig | gawk -v IFACE="${iface}" '/Link/ { if ($1 == IFACE) print "up" }')" + carrier_IFACE="$(ifconfig | gawk -v IFACE="${iface}" '/RUNNING/ { if ($1 == IFACE) print "running" }')" vlans="$(eval echo \$\{iface_${IFACE}_vlans\})" } @@ -63,11 +64,18 @@ # Check that eth0 was not brough up by the kernel ... if [ "${status_IFACE}" != "up" ] then - /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE} >/dev/null || { - retval=$? - eend ${retval} "Failed to bring ${IFACE} up" - return ${retval} - } + # Check that the interface has a carrier + if [ "${carrier_IFACE}" == "running" ] + then + /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE} >/dev/null || { + retval=$? + eend ${retval} "Failed to bring ${IFACE} up" + return ${retval} + } + else + eend 1 "${IFACE} is not plugged in or has no carrier signal" + return 1 + fi fi fi Created attachment 20446 [details, diff]
Even MORE simple link detection.
Instead of using mii-tool to get link state, we can re-use the link state
"RUNNING" from ifconfig (which comes from the ioctl SIOCGIFFLAGS, which equates
to the netif_carrier_ok (netdevice.h) from the kernel's net_device struct).
This patch simply augments setup_env() with one more variable.
The checking of the link is a good idea, however it does not allow my interface to come up. I am running net-tools 1.60-r7 with the development-sources-2.6.0_test8. Before eth0 is started ifconfig does not report eth0 to be RUNNING and therefore the test fails. By commenting out the check I was able to start my connection. Here is my unstarted eth0 output from ifconfig: eth0 Link encap:Ethernet HWaddr 00:02:3F:8B:B8:79 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:3588 errors:0 dropped:0 overruns:0 frame:0 TX packets:3894 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2642385 (2.5 Mb) TX bytes:574093 (560.6 Kb) Interrupt:10 Base address:0x4000 Here is the output after eth0 is started: eth0 Link encap:Ethernet HWaddr 00:02:3F:8B:B8:79 inet addr:192.168.0.166 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::202:3fff:fe8b:b879/64 Scope:Link UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3624 errors:0 dropped:0 overruns:0 frame:0 TX packets:3904 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2646421 (2.5 Mb) TX bytes:575301 (561.8 Kb) Interrupt:10 Base address:0x4000 At this point RUNNING is in the output, but before it was not. Here is the code I commented out from /etc/init.d/net.eth0 version 1.32: # Check that the interface has a carrier #if [ "${carrier_IFACE}" = "running" ] #then /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE} >/dev/null || { retval=$? eend ${retval} "Failed to bring ${IFACE} up" return ${retval} } #else #eend 1 "${IFACE} is not plugged in or has no carrier signal" #return 1 #fi Hope this helps AFAIK latest ~arch baselayout haas this, and its causing me problems with dhcp. I hve the cable plugged and it always says "eth0 is not plugged in or has no carrier signal". btw if i runn by hand dhcpcd eth0 my network card works perfectly. Im using development-sources-2.6.0_beta9. |