hotplug: network-bridge: fix for interfaces with no gateway
authorIan Campbell <ian.campbell@citrix.com>
Wed, 25 Jul 2012 16:39:16 +0000 (17:39 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 25 Jul 2012 16:39:16 +0000 (17:39 +0100)
This comes from an old Debian bug report
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=588477 which refers to
http://lists.xen.org/archives/html/xen-users/2010-06/msg00420.html.

Although we no longer have a trap in _claim_lock as described (this was removed
in 25590:bb250383a4f5 "hotplug/Linux: use flock based locking") and the use of
network-* scripts is discouraged (in favour of using distro provided
mechanisms) the general principal that relying on the semantics of /bin/sh's &&
is unwise seems sound.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/hotplug/Linux/network-bridge

index 6f8475acb725d5b4028eec663928d376c6e5b93e..9aa9dda4841b33c92af39281d73aa7153ce083ff 100644 (file)
@@ -115,7 +115,9 @@ do_ifup() {
             ip addr add ${addr_pfx} dev $1
         fi
         ip link set dev $1 up
-        [ -n "$gateway" ] && ip route add default via ${gateway}
+        if [ -n "$gateway" ] ; then
+            ip route add default via ${gateway}
+        fi
     fi
 }