Commit ced33ca0 authored by Juntong Deng's avatar Juntong Deng Committed by David S. Miller

selftests/net: Improve bind_bhash.sh to accommodate predictable network interface names

Starting with v197, systemd uses predictable interface network names,
the traditional interface naming scheme (eth0) is deprecated, therefore
it cannot be assumed that the eth0 interface exists on the host.

This modification makes the bind_bhash test program run in a separate
network namespace and no longer needs to consider the name of the
network interface on the host.
Signed-off-by: default avatarJuntong Deng <juntong.deng@outlook.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac28b1ec
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
NR_FILES=32768 NR_FILES=32768
SAVED_NR_FILES=$(ulimit -n) readonly NETNS="ns-$(mktemp -u XXXXXX)"
# default values # default values
port=443 port=443
...@@ -36,21 +36,21 @@ while getopts "ha:p:64" opt; do ...@@ -36,21 +36,21 @@ while getopts "ha:p:64" opt; do
done done
setup() { setup() {
ip netns add "${NETNS}"
ip -netns "${NETNS}" link add veth0 type veth peer name veth1
ip -netns "${NETNS}" link set lo up
ip -netns "${NETNS}" link set veth0 up
ip -netns "${NETNS}" link set veth1 up
if [[ "$use_v6" == true ]]; then if [[ "$use_v6" == true ]]; then
ip addr add $addr_v6 nodad dev eth0 ip -netns "${NETNS}" addr add $addr_v6 nodad dev veth0
else else
ip addr add $addr_v4 dev lo ip -netns "${NETNS}" addr add $addr_v4 dev lo
fi fi
ulimit -n $NR_FILES
} }
cleanup() { cleanup() {
if [[ "$use_v6" == true ]]; then ip netns del "${NETNS}"
ip addr del $addr_v6 dev eth0
else
ip addr del $addr_v4/32 dev lo
fi
ulimit -n $SAVED_NR_FILES
} }
if [[ "$addr" != "" ]]; then if [[ "$addr" != "" ]]; then
...@@ -59,8 +59,10 @@ if [[ "$addr" != "" ]]; then ...@@ -59,8 +59,10 @@ if [[ "$addr" != "" ]]; then
fi fi
setup setup
if [[ "$use_v6" == true ]] ; then if [[ "$use_v6" == true ]] ; then
./bind_bhash $port "ipv6" $addr_v6 ip netns exec "${NETNS}" sh -c \
"ulimit -n ${NR_FILES};./bind_bhash ${port} ipv6 ${addr_v6}"
else else
./bind_bhash $port "ipv4" $addr_v4 ip netns exec "${NETNS}" sh -c \
"ulimit -n ${NR_FILES};./bind_bhash ${port} ipv4 ${addr_v4}"
fi fi
cleanup cleanup
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment