Linux 4.19.133
[linux/fpc-iii.git] / tools / testing / selftests / net / in_netns.sh
blob88795b510b32c02229a52e5441a048482fba7e93
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 # Execute a subprocess in a network namespace
6 set -e
8 readonly NETNS="ns-$(mktemp -u XXXXXX)"
10 setup() {
11 ip netns add "${NETNS}"
12 ip -netns "${NETNS}" link set lo up
15 cleanup() {
16 ip netns del "${NETNS}"
19 trap cleanup EXIT
20 setup
22 ip netns exec "${NETNS}" "$@"
23 exit "$?"