[lxc-devel] [PATCH] [stable] lxc-net.conf: use +e at teardown

Serge Hallyn serge.hallyn at ubuntu.com
Thu Mar 19 18:41:46 UTC 2015


When we are shutting down the lxc network, we should not fail when
things go wrong, as that only makes it harder to clean up later.

See https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1429140 in particular

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 config/init/upstart/lxc-net.conf | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/config/init/upstart/lxc-net.conf b/config/init/upstart/lxc-net.conf
index 279cd1e..d6b2165 100644
--- a/config/init/upstart/lxc-net.conf
+++ b/config/init/upstart/lxc-net.conf
@@ -23,6 +23,7 @@ pre-start script
 	use_iptables_lock="-w"
 	iptables -w -L -n > /dev/null 2>&1 || use_iptables_lock=""
 	cleanup() {
+		set +e
 		# dnsmasq failed to start, clean up the bridge
 		iptables $use_iptables_lock -D INPUT -i ${LXC_BRIDGE} -p udp --dport 67 -j ACCEPT
 		iptables $use_iptables_lock -D INPUT -i ${LXC_BRIDGE} -p tcp --dport 67 -j ACCEPT
@@ -34,6 +35,7 @@ pre-start script
 		iptables $use_iptables_lock -t mangle -D POSTROUTING -o ${LXC_BRIDGE} -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
 		ifconfig ${LXC_BRIDGE} down || true
 		brctl delbr ${LXC_BRIDGE} || true
+		set -e
 	}
 
 	if [ -d /sys/class/net/${LXC_BRIDGE} ]; then
@@ -73,6 +75,7 @@ post-stop script
 	ls /sys/class/net/${LXC_BRIDGE}/brif/* > /dev/null 2>&1 && exit 0;
 
 	if [ -d /sys/class/net/${LXC_BRIDGE} ]; then
+		set +e
 		use_iptables_lock="-w"
 		iptables -w -L -n > /dev/null 2>&1 || use_iptables_lock=""
 		ifconfig ${LXC_BRIDGE} down
@@ -87,6 +90,7 @@ post-stop script
 		pid=`cat ${varrun}/dnsmasq.pid 2>/dev/null` && kill -9 $pid || true
 		rm -f ${varrun}/dnsmasq.pid
 		brctl delbr ${LXC_BRIDGE}
+		set -e
 	fi
 	rm -f ${varrun}/network_up
 end script
-- 
2.1.4



More information about the lxc-devel mailing list