Commit 4416c5f5 authored by Hangbin Liu's avatar Hangbin Liu Committed by David S. Miller

selftests/net: use unique netns name for setup_loopback.sh setup_veth.sh

The setup_loopback and setup_veth use their own way to create namespace.
So let's just re-define server_ns/client_ns to unique name.
At the same time update the namespace name in gro.sh and toeplitz.sh.
As I don't have env to run toeplitz.sh. Here is only the gro test result.

 # ./gro.sh
 running test ipv4 data
 Expected {200 }, Total 1 packets
 Received {200 }, Total 1 packets.
 ...
 Gro::large test passed.
 All Tests Succeeded!
Acked-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 976fd1fe
...@@ -23,11 +23,11 @@ run_test() { ...@@ -23,11 +23,11 @@ run_test() {
# on every try. # on every try.
for tries in {1..3}; do for tries in {1..3}; do
# Actual test starts here # Actual test starts here
ip netns exec server_ns ./gro "${ARGS[@]}" "--rx" "--iface" "server" \ ip netns exec $server_ns ./gro "${ARGS[@]}" "--rx" "--iface" "server" \
1>>log.txt & 1>>log.txt &
server_pid=$! server_pid=$!
sleep 0.5 # to allow for socket init sleep 0.5 # to allow for socket init
ip netns exec client_ns ./gro "${ARGS[@]}" "--iface" "client" \ ip netns exec $client_ns ./gro "${ARGS[@]}" "--iface" "client" \
1>>log.txt 1>>log.txt
wait "${server_pid}" wait "${server_pid}"
exit_code=$? exit_code=$?
......
...@@ -5,6 +5,8 @@ readonly FLUSH_PATH="/sys/class/net/${dev}/gro_flush_timeout" ...@@ -5,6 +5,8 @@ readonly FLUSH_PATH="/sys/class/net/${dev}/gro_flush_timeout"
readonly IRQ_PATH="/sys/class/net/${dev}/napi_defer_hard_irqs" readonly IRQ_PATH="/sys/class/net/${dev}/napi_defer_hard_irqs"
readonly FLUSH_TIMEOUT="$(< ${FLUSH_PATH})" readonly FLUSH_TIMEOUT="$(< ${FLUSH_PATH})"
readonly HARD_IRQS="$(< ${IRQ_PATH})" readonly HARD_IRQS="$(< ${IRQ_PATH})"
readonly server_ns=$(mktemp -u server-XXXXXXXX)
readonly client_ns=$(mktemp -u client-XXXXXXXX)
netdev_check_for_carrier() { netdev_check_for_carrier() {
local -r dev="$1" local -r dev="$1"
...@@ -97,12 +99,12 @@ setup_interrupt() { ...@@ -97,12 +99,12 @@ setup_interrupt() {
setup_ns() { setup_ns() {
# Set up server_ns namespace and client_ns namespace # Set up server_ns namespace and client_ns namespace
setup_macvlan_ns "${dev}" server_ns server "${SERVER_MAC}" setup_macvlan_ns "${dev}" ${server_ns} server "${SERVER_MAC}"
setup_macvlan_ns "${dev}" client_ns client "${CLIENT_MAC}" setup_macvlan_ns "${dev}" ${client_ns} client "${CLIENT_MAC}"
} }
cleanup_ns() { cleanup_ns() {
cleanup_macvlan_ns server_ns server client_ns client cleanup_macvlan_ns ${server_ns} server ${client_ns} client
} }
setup() { setup() {
......
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
readonly server_ns=$(mktemp -u server-XXXXXXXX)
readonly client_ns=$(mktemp -u client-XXXXXXXX)
setup_veth_ns() { setup_veth_ns() {
local -r link_dev="$1" local -r link_dev="$1"
local -r ns_name="$2" local -r ns_name="$2"
...@@ -19,14 +22,14 @@ setup_ns() { ...@@ -19,14 +22,14 @@ setup_ns() {
# Set up server_ns namespace and client_ns namespace # Set up server_ns namespace and client_ns namespace
ip link add name server type veth peer name client ip link add name server type veth peer name client
setup_veth_ns "${dev}" server_ns server "${SERVER_MAC}" setup_veth_ns "${dev}" ${server_ns} server "${SERVER_MAC}"
setup_veth_ns "${dev}" client_ns client "${CLIENT_MAC}" setup_veth_ns "${dev}" ${client_ns} client "${CLIENT_MAC}"
} }
cleanup_ns() { cleanup_ns() {
local ns_name local ns_name
for ns_name in client_ns server_ns; do for ns_name in ${client_ns} ${server_ns}; do
[[ -e /var/run/netns/"${ns_name}" ]] && ip netns del "${ns_name}" [[ -e /var/run/netns/"${ns_name}" ]] && ip netns del "${ns_name}"
done done
} }
......
...@@ -147,14 +147,14 @@ setup() { ...@@ -147,14 +147,14 @@ setup() {
setup_loopback_environment "${DEV}" setup_loopback_environment "${DEV}"
# Set up server_ns namespace and client_ns namespace # Set up server_ns namespace and client_ns namespace
setup_macvlan_ns "${DEV}" server_ns server \ setup_macvlan_ns "${DEV}" $server_ns server \
"${SERVER_MAC}" "${SERVER_IP}" "${SERVER_MAC}" "${SERVER_IP}"
setup_macvlan_ns "${DEV}" client_ns client \ setup_macvlan_ns "${DEV}" $client_ns client \
"${CLIENT_MAC}" "${CLIENT_IP}" "${CLIENT_MAC}" "${CLIENT_IP}"
} }
cleanup() { cleanup() {
cleanup_macvlan_ns server_ns server client_ns client cleanup_macvlan_ns $server_ns server $client_ns client
cleanup_loopback "${DEV}" cleanup_loopback "${DEV}"
} }
...@@ -170,22 +170,22 @@ if [[ "${TEST_RSS}" = true ]]; then ...@@ -170,22 +170,22 @@ if [[ "${TEST_RSS}" = true ]]; then
# RPS/RFS must be disabled because they move packets between cpus, # RPS/RFS must be disabled because they move packets between cpus,
# which breaks the PACKET_FANOUT_CPU identification of RSS decisions. # which breaks the PACKET_FANOUT_CPU identification of RSS decisions.
eval "$(get_disable_rfs_cmd) $(get_disable_rps_cmd)" \ eval "$(get_disable_rfs_cmd) $(get_disable_rps_cmd)" \
ip netns exec server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ ip netns exec $server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \
-d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 \ -d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 \
-C "$(get_rx_irq_cpus)" -s -v & -C "$(get_rx_irq_cpus)" -s -v &
elif [[ ! -z "${RPS_MAP}" ]]; then elif [[ ! -z "${RPS_MAP}" ]]; then
eval "$(get_disable_rfs_cmd) $(get_set_rps_bitmaps_cmd ${RPS_MAP})" \ eval "$(get_disable_rfs_cmd) $(get_set_rps_bitmaps_cmd ${RPS_MAP})" \
ip netns exec server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ ip netns exec $server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \
-d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 \ -d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 \
-r "0x${RPS_MAP}" -s -v & -r "0x${RPS_MAP}" -s -v &
else else
ip netns exec server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \ ip netns exec $server_ns ./toeplitz "${IP_FLAG}" "${PROTO_FLAG}" \
-d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 -s -v & -d "${PORT}" -i "${DEV}" -k "${KEY}" -T 1000 -s -v &
fi fi
server_pid=$! server_pid=$!
ip netns exec client_ns ./toeplitz_client.sh "${PROTO_FLAG}" \ ip netns exec $client_ns ./toeplitz_client.sh "${PROTO_FLAG}" \
"${IP_FLAG}" "${SERVER_IP%%/*}" "${PORT}" & "${IP_FLAG}" "${SERVER_IP%%/*}" "${PORT}" &
client_pid=$! client_pid=$!
......
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