blob: 8310a473fd0297520a09d0ee2e5057003bd3ff4b [file] [log] [blame]
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Start network for a container"
author "chromium-os-dev@chromium.org"
start on started arc-boot-continue
stop on stopped arc-boot-continue
env ARC_IFNAME=arcbr0
env CONTAINER_NAME=android
import CONTAINER_PID
pre-start script
{
echo "Pre-start arc-networkd - container booting"
set -x
# Wait until the container's network namespace is changed before setting up
# the network.
init_ns=$(readlink "/proc/1/ns/net")
for i in `seq 1 50`; do
if [ -d "/proc/${CONTAINER_PID}" ]; then
ns=$(readlink "/proc/${CONTAINER_PID}/ns/net")
if [ -n "${ns}" -a "${ns}" != "${init_ns}" ]; then
break
fi
fi
sleep 0.1
done
# Enable IPv6 routing and neighbor discovery proxying.
sysctl net.ipv6.conf.all.forwarding=1
sysctl net.ipv6.conf.all.proxy_ndp=1
# Temporary workaround for b/27932574 permission check.
chown 655360:655360 /sys/class/xt_idletimer
# Signal arc-networkd that the container is booting.
pkill -x -USR1 arc-networkd
} 2>&1 | logger -t "${UPSTART_JOB}"
end script
post-stop script
{
echo "Post-stop arc-networkd - container going down"
set +e -x
# Signal arc-networkd that the container is shutting down.
pkill -x -USR2 arc-networkd
} 2>&1 | logger -t "${UPSTART_JOB}"
end script