On 8/22/06, Frederick Brown <[EMAIL PROTECTED]> wrote:
Submitted By: Brian Weber
Date: 22 August 2006
Name: blfs-bootscripts-6.1.dhcpcd.no-carrier.patch
Description: The patch handles the case of a missing carrier on a NIC,
ie an unplugged cable or a router/hub down, at startup time by issuing
a
warning and skipping the startup of dhcp instead of mindlessly waiting
for the timeout.
<snip>
+# Abort startup and issue a warning if interface lacks a carrier.
+link_status=`ip link show ${1} 2> /dev/null`
+if [ "$2" = "up" ] && echo $link_status | grep -q "NO-CARRIER" ; then
+ boot_mesg "Skipping startup of dhcpcd: '${1}' NO-CARRIER!"
${WARNING}
+ echo_warning
+ exit 0
+else
+
This is almost two months old now, but I'm looking at getting it in
right now. I hope you're still there. And I brought this to blfs-dev
to get more eyes.
So, I want to talk about the use of the ip command and a possible
alternative. Starting w/ linux-2.6.10 approximately, the carrier
information is exported through sysfs. So, we don't have to spawn a
process and then try to parse the output. Try these commands, where
<device> is, e.g., eth0.
$ cat /sys/class/net/<device>/carrier
It returns 1 if the cable is connected and 0 if it's not. This
corresponds with the output from ip's NO-CARRIER. You can read more
here:
http://lkml.org/lkml/2004/9/26/83
On my laptop, this works as advertised. And the SuSE distro I
installed on there initially uses this in their network scripts.
Essentially, the test is:
if [ "`cat /sys/class/net/$1/carrier`" = 1 ]; then
echo "cable connected on $1"
else
echo "cable disconnected on $1"
fi
Could you see if this works on your computer?
--
Dan
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page