/etc/networking/* are executed multiple times

Bug #1126560 reported by Removed by request
6
Affects Status Importance Assigned to Milestone
ifupdown (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I'm using Ubuntu 13.04 dev with ifupdown 0.7.5ubuntu2. I have noticed that on booting my system in /etc/networking the scripts in if-pre-up.d and if-up.d are executed multiple times. On my observations I have noticed that they can even be executed parallelized. I have logged what happened on a boot:

1. The content of /etc/networking/if-pre-up.d is executed parallelized 2 times.
2. After they have finished the content of /etc/networking/if-up.d is excuted.
3. Then the content of /etc/networking/if-pre-up.d is excuted again.
4. At last the content of /etc/networking/if-up.d is executed again too.

As a summary: The content of /etc/networking/if-pre-up.d was executed 3times and /etc/networking/if-up.d 2 times.

Revision history for this message
Stéphane Graber (stgraber) wrote :

Please attach your /etc/network/interfaces

Changed in ifupdown (Ubuntu):
status: New → Incomplete
Revision history for this message
Removed by request (removed3425744) wrote :
Changed in ifupdown (Ubuntu):
status: Incomplete → New
Revision history for this message
Stéphane Graber (stgraber) wrote :

Ok, with that config you should have all the scripts run twice in theory, once for the loopback device and once for eth0.
Not sure why you're seeing one running 3 times though.

All the .d scripts are run once per interface, so it's perfectly normal for them to be called multiple times. Interfaces are brought up as they show up from the kernel, so they can indeed be brought up in parallel. Scripts should expect that and deal with that accordingly. If they don't, a bug against the package providing the script is the way forward.

Revision history for this message
Removed by request (removed3425744) wrote :

> Interfaces are brought up as they show up from the kernel, so they can indeed be brought up in parallel.

I have tested this and it seems to be false (assuming there is a bug on booting). I have written a script which helps me debugging this problem and placed it in /etc/network/if-pre-up.d/ and /etc/network/if-up.d/. The script delays itself to 5 seconds and logs at which PID it is currently running. So it is possible to say in which order ifupdown has called the scripts and if they are running sequentially or parallel.

network_reboot.log contains the information what happens after a system reboot. In this log if-pre-up.d and if-up.d were called parallelized 3 times.
network_restart contains the information what happens after calling /etc/init.d/networking restart. In this log if-pre-up.d and if-up.d were called sequentially 2 times.

Because I'm having only 2 network devices I'm assuming the second variant is the correct one. It would be a little easier to know for which network device the scripts were running. But I have already opened a feature request for this (https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1128403).

Revision history for this message
Removed by request (removed3425744) wrote :
Revision history for this message
Removed by request (removed3425744) wrote :
Revision history for this message
Andrej Shadura (andrew.sh) wrote :

This is fine, not a bug :) Read the man page regarding --all.

Changed in ifupdown (Ubuntu):
status: New → Invalid
Revision history for this message
Removed by request (removed3425744) wrote :

--all does not explain why 2 interfaces in /etc/network/interfaces marked as auto are causing 3 starts of network devices.

Changed in ifupdown (Ubuntu):
status: Invalid → New
Revision history for this message
Removed by request (removed3425744) wrote :

I have now extended my script with $IFACE and the result is very annoying. On restarting the network with /etc/init.d/networking restart (network_restart2.log) --all and eth0 were registered. I'm wondering why eth0 is registered there if --all is already used or why lo is missing. On rebooting the system (network_reboot2.log) it is more confusing. eth0 was registered on if-pre-up.d 2 times, lo 1 time and --all 1 time. On if-up.d lo, eth0 and --all were registered 1 time. I'm wondering here too why --all is registered if eth0 and lo are already registered. But it is even annoying why eth0 was registered 2 times on if-pre-up.d. The difference why restarting the network is calling the scripts sequentially and rebooting the system parallel makes the chaos perfect.

Revision history for this message
Removed by request (removed3425744) wrote :
Revision history for this message
Removed by request (removed3425744) wrote :
Revision history for this message
Stéphane Graber (stgraber) wrote :

From the manpage:
"""
       When ifupdown is being called with the --all option, before doing anything to interfaces, if calls all the hook scripts (pre-up or down) with IFACE set to
       "--all", LOGICAL set to the current value of --allow parameter (or "auto" if it's not set), ADDRFAM="meta" and METHOD="none". After all the interfaces have
       been brought up or taken down, the appropriate scripts (up or post-down) are executed.
"""

So when called with -a, it'll first call the hooks with IFACE="--all" and then call them again for each interface.

Changed in ifupdown (Ubuntu):
status: New → Invalid
Revision history for this message
Removed by request (removed3425744) wrote :

This does not explain:

- Why lo is missing on /etc/init.d/networking restart.
- Why eth0 was registered 2 times (if-pre-up.d) on rebooting.
- The difference between sequential executing (on restarting with /etc/init.d/networking restart) and parallel executing (on rebooting the system).

Changed in ifupdown (Ubuntu):
status: Invalid → New
Revision history for this message
Stéphane Graber (stgraber) wrote :

- Why lo is missing on /etc/init.d/networking restart.
  - Because we never bring down "lo" on networking restart.

 - Why eth0 was registered 2 times (if-pre-up.d) on rebooting.
 No idea and I can't reproduce this here.
 Here I see the pre-up scripts being called 3 times:
  - once for --all
  - once for eth0
  - once for lo

- The difference between sequential executing (on restarting with /etc/init.d/networking restart) and parallel executing (on rebooting the system).
 The only difference should be the absence of "lo" as state above. My best guess for why you're getting eth0 twice is that of a race condition between the event based bring up and the standard init based bringup.

Revision history for this message
Removed by request (removed3425744) wrote :

Maybe there is a problem with an upstart script or something else. But what is now the correct behavior? The sequential or parallel executing? Maybe the parallelization comes from upstart too.

Revision history for this message
Stéphane Graber (stgraber) wrote :

both are the correct behaviour.

Most interfaces are brought up through udev events as soon as the kernel finds them, however the standard "sequential" bring up is still there for the few cases where we fail to get kernel events.
Those cases include ethX interfaces in containers, tunnel devices, complex bonding setup, bridges, complex vlan setup, ...

Changed in ifupdown (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.