1
0
Fork 0
android_kernel_rockchip_tart/tools/testing/selftests/net/in_netns.sh
2025-06-27 00:32:42 -05:00

23 lines
323 B
Bash
Executable file

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Execute a subprocess in a network namespace
set -e
readonly NETNS="ns-$(mktemp -u XXXXXX)"
setup() {
ip netns add "${NETNS}"
ip -netns "${NETNS}" link set lo up
}
cleanup() {
ip netns del "${NETNS}"
}
trap cleanup EXIT
setup
ip netns exec "${NETNS}" "$@"
exit "$?"