FS#7554 - /etc/rc.d/network ambiguous assumptions
Attached to Project:
Arch Linux
Opened by Loic Nageleisen (lloeki) - Tuesday, 03 July 2007, 13:28 GMT
Last edited by Aaron Griffin (phrakture) - Wednesday, 09 January 2008, 18:19 GMT
Opened by Loic Nageleisen (lloeki) - Tuesday, 03 July 2007, 13:28 GMT
Last edited by Aaron Griffin (phrakture) - Wednesday, 09 January 2008, 18:19 GMT
|
Details
Description:
in /etc/rc.d/network problem: line 35: [ "`/sbin/ifconfig ${1} 2>/dev/null | grep UP`" ] && return 0 this implies ifup() only runs when interface is marked up line 61: kill `cat /var/run/dhcpcd-${1}.pid` this being alone implies interface up after ifdown(): killing dhcpcd does not bring down interface those two lines alone are inconsistent, resulting in task 7165, but there is more behind it. consequence: - task 7165 - blocks ifplugd from calling /etc/network in a proper manner cause: one wanted to abuse UP status into matching operational state, which is wrong: interface being UP does not mean it has an IP, but that MAC level is UP (thus UP is needed by ifplugd&al to get cable status), thus dhcp/ifconfig may need to be run even if UP is present in ifconfig output. solution: network script obviously does not handle anything else than inet addr, so one should grep for "inet addr:" together with "UP". Additional info: * initscripts 0.8-12 note: this is related to task 7165, but has a wider scope. |
This task depends upon
Closed by Aaron Griffin (phrakture)
Wednesday, 09 January 2008, 18:19 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in git
Wednesday, 09 January 2008, 18:19 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in git
[ "`/sbin/ifconfig ${1} 2>/dev/null | grep UP | grep 'inet addr:'`" ] && return 0
because else your second grep is useless
besides having an 'inet6 addr' is counterproductive, because once the interface is UP'd with the ipv6 kernel module loaded the interface will get the default MACtoIPV6 address, thus preventing any dhcp request to be made. therefore, if one wants ipv6 to be handled, one should construct the MACtoIPV6 address from the mac, and grep it out before grepping for 'inet6 addr'.
Loic, I'm not entirely sure what you're saying here. I'm sure there are FAR better ways to check for an interface being up than a complex grep like this. Perhaps something in /proc can help us out.
I'm generally not a fan of string compares here
Besides, I'm totally making a fool of myself again: it should be sufficient to discard lines beginning with 'inet6 addr: fe80:' given the definition of the v6 link-local prefix...
So the line testing if we need to dhcp/config should read:
[ "`/sbin/ifconfig ${1} 2>/dev/null | grep -v 'inet6 addr: fe80:' | grep -e 'inet addr:' -e 'inet6 addr:'`" ] && return 0
That said, I totally agree, there must be a smarter way to do this than endless grep'ing (though I don't think ifconfig output will change soon enough), and I wouldn't expect what I exhibit here to be included as is. That's merely proof-of-concept and quick fix to me.