mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 00:48:50 +00:00
7f204a7de8
This commit adds a test to check if we can fully utilize 4-tuples for connect() when all ephemeral ports are exhausted. The test program changes the local port range to use only one port and binds two sockets with or without SO_REUSEADDR and SO_REUSEPORT, and with the same EUID or with different EUIDs, then do listen(). We should be able to bind only one socket having both SO_REUSEADDR and SO_REUSEPORT per EUID, which restriction is to prevent unintentional listen(). Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp> Signed-off-by: David S. Miller <davem@davemloft.net>
35 lines
635 B
Bash
Executable file
35 lines
635 B
Bash
Executable file
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Run tests when all ephemeral ports are exhausted.
|
|
#
|
|
# Author: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
|
|
|
|
set +x
|
|
set -e
|
|
|
|
readonly NETNS="ns-$(mktemp -u XXXXXX)"
|
|
|
|
setup() {
|
|
ip netns add "${NETNS}"
|
|
ip -netns "${NETNS}" link set lo up
|
|
ip netns exec "${NETNS}" \
|
|
sysctl -w net.ipv4.ip_local_port_range="32768 32768" \
|
|
> /dev/null 2>&1
|
|
ip netns exec "${NETNS}" \
|
|
sysctl -w net.ipv4.ip_autobind_reuse=1 > /dev/null 2>&1
|
|
}
|
|
|
|
cleanup() {
|
|
ip netns del "${NETNS}"
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
setup
|
|
|
|
do_test() {
|
|
ip netns exec "${NETNS}" ./reuseaddr_ports_exhausted
|
|
}
|
|
|
|
do_test
|
|
echo "tests done"
|