Bug 7731 - /etc/network/if-up.d/ does not always trigger on connection change
: /etc/network/if-up.d/ does not always trigger on connection change
Status: RESOLVED WORKSFORME
Product: Connectivity
Networking
: 5.0/(2.2009.51-1)
: N900 Maemo
: Unspecified normal with 3 votes (vote)
: ---
Assigned To: unassigned
: networking-bugs
: http://talk.maemo.org/showthread.php?...
: moreinfo
:
:
  Show dependency tree
 
Reported: 2010-01-07 02:42 UTC by Frederik Niedernolte
Modified: 2010-08-26 13:48 UTC (History)
3 users (show)

See Also:


Attachments
Script for /etc/network/if-up.d/ (653 bytes, application/octet-stream)
2010-01-07 02:49 UTC, Frederik Niedernolte
Details
Test script (930 bytes, application/octet-stream)
2010-01-07 11:33 UTC, Frederik Niedernolte
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description Frederik Niedernolte (reporter) 2010-01-07 02:42:15 UTC
SOFTWARE VERSION: 2009.42

EXACT STEPS LEADING TO PROBLEM: 
1. Intall the last script mentioned in
http://talk.maemo.org/showthread.php?p=453662#post453662 in
/etc/network/if-up.d/script and chmod + x
2. Change the connection from grps0 to wlan0 or vice versa (manually or
automatically)

EXPECTED OUTCOME:
Every connection change should trigger all scripts in /etc/network/if-up.d/

ACTUAL OUTCOME:
The scripts in /etc/network/if-up.d/ are only triggered sometimes, not always.
It doesn't depend on the connection type (happens for gprs0 and wlan0) and I
cannot figure out a reason

REPRODUCIBILITY:
5/10

EXTRA SOFTWARE INSTALLED:
Not important

OTHER COMMENTS:
Scripts in /etc/network/if-up.d/ should be ran every time the connection
changes.

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.6)
Gecko/20091201 Firefox/3.5.6
Comment 1 Frederik Niedernolte (reporter) 2010-01-07 02:49:09 UTC
Created an attachment (id=1944) [details]
Script for /etc/network/if-up.d/

Script for /etc/network/if-up.d/ 
chmod + x
Comment 2 Lucas Maneos 2010-01-07 06:00:04 UTC
Couldn't reproduce on 2.2009.51-1 after 10 connection changes with this simpler
script:

#!/bin/sh
echo $ICD_CONNECTION_TYPE >> /tmp/test.log

(I've also been running the attachment from bug 995 for over a month on
1.2009.42-11 and I never noticed it not working.)

How do you determine that the script is not executed?

Do you also have an equivalent if-down.d script?  If so, note that when
switching connections the old connection's if-down.d script will run after the
new connection's if-up.d script.

Note also that the filename must consist only of alphanumeric, "-" and "_"
characters or run-parts will ignore it.
Comment 3 Frederik Niedernolte (reporter) 2010-01-07 07:14:29 UTC
(In reply to comment #2)

I don't have build 51-1 so I cannot say anything about that.

I can see in the log file that not every connection change (especially the
automatic connection changes) has executed the script.
At least there should be one more empty line because of the echo " ".
Have you switched the connection manually all the time?

I don't have an if-down.d script.

The name of the script on my device is "dyndns" so there shouldn't be a problem
with that.
Comment 4 Lucas Maneos 2010-01-07 08:02:57 UTC
(In reply to comment #3)
> I can see in the log file that not every connection change (especially the
> automatic connection changes) has executed the script.
> At least there should be one more empty line because of the echo " ".

Can you reproduce with a simpler script like the one in comment 2?  The
attached script has syntax errors (missing closing quotes in the two "up" echo
lines) so all bets are off ;-)

There's also a possible race condition when switching from GPRS to WLAN: if the
first if condition succeeds just before gprs0 goes down the following while
loop may not terminate until gprs0 goes up again (when switching a connection,
instead of disconnecting and reconnecting in two steps, there is a small window
when both connections are up).  If there are multiple copies of the script
running and appending to the log at the same time the contents of the log will
be unpredictable.

> Have you switched the connection manually all the time?

Yes.
Comment 5 Frederik Niedernolte (reporter) 2010-01-07 11:33:45 UTC
Created an attachment (id=1945) [details]
Test script

(In reply to comment #4)

Because I $ICD_CONNECTION_TYPE is not always set on my phone I have created the
attached script. Together with a sleep 10 command it should be pretty reliable
and give more information. It worked for the first two connection changes but
on the third I have this entry in the log:

Thu Jan  7 20:02:43 GMT-11 2010 - gprs0
wlan0 WLAN_INFRA
Thu Jan  7 20:02:54 GMT-11 2010 - No interface found!

It makes no sense because first it shows that the if-up.d script is executed
when GPRS is still active and after that it shows the WLAN connection but then
it detects none of them.
Comment 6 Lucas Maneos 2010-01-07 18:38:24 UTC
(In reply to comment #5)
> Because I $ICD_CONNECTION_TYPE is not always set on my phone

Ah, that's interesting.  It seems to work on 2.2009.51-1, but could you add a
comment about it to bug 7733?

> It worked for the first two connection changes but
> on the third I have this entry in the log:
> 
> Thu Jan  7 20:02:43 GMT-11 2010 - gprs0
> wlan0 WLAN_INFRA
> Thu Jan  7 20:02:54 GMT-11 2010 - No interface found!

That's really strange, $interface shouldn't change value during the sleep.  You
can maybe also try logging the process id ($$) to make sure it's really the
same instance of the script that logs both lines...

But this is a bit off-topic here, at least it did write to the log proving it
executed.
Comment 7 Frederik Niedernolte (reporter) 2010-01-08 09:32:12 UTC
I thinkg that is the problem. Today I found another output which makes no
sense:

Fri Jan  8 16:38:30 GMT-11 2010 - gprs0
wlan0 WLAN_INFRA
Fri Jan  8 16:38:50 GMT-11 2010 - gprs0
wlan0 WLAN_INFRA
Fri Jan  8 16:38:50 GMT-11 2010 - No interface found!

This confirms your bug 7733 but I wonder why the script doesn't work because
wlan0 is correct and should be identified as it is.
And also why do I have the output lines without a date (wlan0 WLAN_INFRA)? I
don't have them added to the script and the "Fri Jan  8 16:38:50 GMT-11 2010 -
gprs0" line is wrong because the connection changed to WLAN at this time.
Comment 8 Frederik Niedernolte (reporter) 2010-01-19 01:47:42 UTC
An update to 51-1 didn't change anything...
Comment 9 Andre Klapper maemo.org 2010-02-13 02:44:16 UTC
Adding assumed dependency.
Comment 10 Aymeric Brisse 2010-02-16 05:50:21 UTC
*** This bug has been confirmed by popular vote. ***
Comment 11 Lucas Maneos 2010-02-16 06:24:01 UTC
(In reply to comment #9)
> Adding assumed dependency.

No dependency actually, it was just something I came across while testing this.

Still can't reproduce by the way.  Do any of the voters have a different script
exhibiting this problem?  Both attached scripts have syntax errors and so can
not be expected to produce any meaningful outcome, while the pre-installed and 
my own if-up.d scripts still appear to work fine.

A *simple* and *valid* test case without race/concurrency issues would be
welcome.
Comment 12 Aymeric Brisse 2010-02-16 06:36:52 UTC
Couldn't reproduce it either (my vote was a mistake)

Works well with me, if-up.d and if-down.d are triggered every time.
Comment 13 Aymeric Brisse 2010-02-17 03:27:06 UTC
Hi there! I made a small script in if.d :

#!/bin/sh
echo "$IFACE" >> /var/log/ifup.log

When I connect to the Wifi, $IFACE="wlan0", but when i connect to the 3G,
$IFACE="" instead of "gprs0".

Any idea why ?
Thanks.
Comment 14 Lucas Maneos 2010-02-17 10:42:00 UTC
(In reply to comment #13)
> When I connect to the Wifi, $IFACE="wlan0", but when i connect to the 3G,
> $IFACE="" instead of "gprs0".
> 
> Any idea why ?

Yes, that's bug 7733.
Comment 15 Andre Klapper maemo.org 2010-08-26 13:48:20 UTC
Closing this bug report as the issue could not be reproduced. Please feel free
to reopen this report if you can provide better steps to reproduce this and if
this is still an issue in the latest version.