Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

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
Task Type Bug Report
Category System
Status Closed
Assigned To Aaron Griffin (phrakture)
Architecture All
Severity Medium
Priority Normal
Reported Version 2007.05 Duke
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

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
Comment by Loic Nageleisen (lloeki) - Thursday, 02 August 2007, 12:15 GMT
my fix, change line 36 to:
[ "`/sbin/ifconfig ${1} 2>/dev/null | grep UP | grep 'inet addr:'`" ] && return 0
Comment by Tobias Powalowski (tpowa) - Tuesday, 16 October 2007, 06:16 GMT
[ "`/sbin/ifconfig ${1} 2>/dev/null | grep -e 'UP' -e 'inet addr:' -e 'inet6 addr:'`" ] && return 0

because else your second grep is useless
Comment by Loic Nageleisen (lloeki) - Tuesday, 08 January 2008, 13:20 GMT
  • Field changed: Percent Complete (100% → 0%)
well, in fact it is not: having an 'inet addr:' implies being UP. therefore, since two -e are OR'ed by grep, the 'inet addr' part is totally useless. that's why I AND'd them by separating them.
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'.
Comment by Aaron Griffin (phrakture) - Tuesday, 08 January 2008, 13:23 GMT
This is an initscripts task, and I'm releasing a new package with umpteen minor changes soon, so I'll claim ownership here.

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
Comment by Loic Nageleisen (lloeki) - Tuesday, 08 January 2008, 14:44 GMT
I'm only trying to point out a bug, and build up on current code (and way it is coded) to exhibit what I suppose to be correct behavior. Sadly I made a mistake, which was followed by another one.

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.
Comment by Aaron Griffin (phrakture) - Tuesday, 08 January 2008, 15:15 GMT Comment by Loic Nageleisen (lloeki) - Wednesday, 09 January 2008, 13:47 GMT
It works for me with dhcp ipv4 + local link ipv6, both 'manually' with rc.conf INTERFACES and with ifplugd.

Loading...