WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / reuseaddr_ports_exhausted.sh
blob20e3a2913d06b481e469cec34a42f6bdfe62cbaa
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Run tests when all ephemeral ports are exhausted.
6 # Author: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
8 set +x
9 set -e
11 readonly NETNS="ns-$(mktemp -u XXXXXX)"
13 setup() {
14 ip netns add "${NETNS}"
15 ip -netns "${NETNS}" link set lo up
16 ip netns exec "${NETNS}" \
17 sysctl -w net.ipv4.ip_local_port_range="32768 32768" \
18 > /dev/null 2>&1
19 ip netns exec "${NETNS}" \
20 sysctl -w net.ipv4.ip_autobind_reuse=1 > /dev/null 2>&1
23 cleanup() {
24 ip netns del "${NETNS}"
27 trap cleanup EXIT
28 setup
30 do_test() {
31 ip netns exec "${NETNS}" ./reuseaddr_ports_exhausted
34 do_test
35 echo "tests done"