[lxc-devel] [PATCH] [stable] lxc-net.conf: use +e at teardown
Stéphane Graber
stgraber at ubuntu.com
Mon Apr 6 15:50:41 UTC 2015
On Thu, Mar 19, 2015 at 06:41:46PM +0000, Serge Hallyn wrote:
> 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>
Acked-by: Stéphane Graber <stgraber 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
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150406/6a5c4de8/attachment.sig>
More information about the lxc-devel
mailing list