File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed
Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change 1313 unset LOGGER
1414fi
1515
16+ LOCKFILE=/run/network/.lock
17+
1618# for diagnostics
1719if [ -t 1 -a -z " $LOGGER " ] || [ ! -e ' /dev/log' ]; then
1820 mesg () {
@@ -49,19 +51,21 @@ wait_for_interface() {
4951
5052net_ifup () {
5153
52- # exit if the interface is not configured as allow-hotplug
53- TARGET_IFACE=$( /sbin/ifquery --allow hotplug -l " $INTERFACE " || true)
54- if [ -z " $TARGET_IFACE " ]; then
54+ # exit if the interface is not configured as allow-hotplug (querying does not require a lock)
55+ if ! $( /sbin/ifquery --allow=hotplug -l 2> /dev/null | grep -w -q " ^$INTERFACE $" ) ; then
5556 exit 0
5657 fi
5758
5859 if [ -d /run/systemd/system ]; then
59- exec systemctl --no-block start
$( systemd-escape --template [email protected] $TARGET_IFACE ) 60+ exec systemctl --no-block start
$( systemd-escape --template [email protected] $INTERFACE ) 6061 fi
6162
62- wait_for_interface lo
63-
64- exec ifup --allow=hotplug $INTERFACE
63+ # Take the lock and wait for lo before exec ifup.
64+ (
65+ flock 9
66+ wait_for_interface lo
67+ exec ifup $INTERFACE -L 9
68+ ) 9> $LOCKFILE
6569}
6670
6771net_ifdown () {
@@ -72,7 +76,16 @@ net_ifdown() {
7276 exit 0
7377 fi
7478
75- exec ifdown --allow=hotplug $INTERFACE
79+ # exit if the interface is not configured as allow-hotplug (querying does not require a lock)
80+ if ! $( /sbin/ifquery --allow=hotplug -l 2> /dev/null | grep -w -q " ^$INTERFACE $" ) ; then
81+ exit 0
82+ fi
83+
84+ # Take the lock and exec ifdown.
85+ (
86+ flock 9
87+ exec ifdown $INTERFACE -L 9
88+ ) 9> $LOCKFILE
7689}
7790
7891do_everything () {
You can’t perform that action at this time.
0 commit comments