mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 20:48:49 +08:00
selftests: mptcp: declare var as local
Just to avoid classical Bash pitfall where variables are accidentally overridden by other functions because the proper scope has not been defined. That's also what is done in other MPTCP selftests scripts where all non local variables are defined at the beginning of the script and the others are defined with the "local" keyword. Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
de2392028a
commit
5f17f8e315
@ -22,6 +22,7 @@ add_mark_rules()
|
||||
local ns=$1
|
||||
local m=$2
|
||||
|
||||
local t
|
||||
for t in iptables ip6tables; do
|
||||
# just to debug: check we have multiple subflows connection requests
|
||||
ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
|
||||
@ -36,6 +37,7 @@ add_mark_rules()
|
||||
|
||||
init()
|
||||
{
|
||||
local netns
|
||||
for netns in "$ns1" "$ns2" "$ns_sbox";do
|
||||
ip netns add $netns || exit $ksft_skip
|
||||
ip -net $netns link set lo up
|
||||
@ -44,6 +46,7 @@ init()
|
||||
ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
|
||||
done
|
||||
|
||||
local i
|
||||
for i in `seq 1 4`; do
|
||||
ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
|
||||
ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i
|
||||
@ -73,6 +76,7 @@ init()
|
||||
|
||||
cleanup()
|
||||
{
|
||||
local netns
|
||||
for netns in "$ns1" "$ns2" "$ns_sbox"; do
|
||||
ip netns del $netns
|
||||
done
|
||||
@ -103,15 +107,17 @@ check_mark()
|
||||
local ns=$1
|
||||
local af=$2
|
||||
|
||||
tables=iptables
|
||||
local tables=iptables
|
||||
|
||||
if [ $af -eq 6 ];then
|
||||
tables=ip6tables
|
||||
fi
|
||||
|
||||
local counters values
|
||||
counters=$(ip netns exec $ns $tables -v -L OUTPUT | grep DROP)
|
||||
values=${counters%DROP*}
|
||||
|
||||
local v
|
||||
for v in $values; do
|
||||
if [ $v -ne 0 ]; then
|
||||
echo "FAIL: got $tables $values in ns $ns , not 0 - not all expected packets marked" 1>&2
|
||||
@ -131,9 +137,9 @@ print_file_err()
|
||||
|
||||
check_transfer()
|
||||
{
|
||||
in=$1
|
||||
out=$2
|
||||
what=$3
|
||||
local in=$1
|
||||
local out=$2
|
||||
local what=$3
|
||||
|
||||
cmp "$in" "$out" > /dev/null 2>&1
|
||||
if [ $? -ne 0 ] ;then
|
||||
@ -156,18 +162,18 @@ is_v6()
|
||||
|
||||
do_transfer()
|
||||
{
|
||||
listener_ns="$1"
|
||||
connector_ns="$2"
|
||||
cl_proto="$3"
|
||||
srv_proto="$4"
|
||||
connect_addr="$5"
|
||||
local listener_ns="$1"
|
||||
local connector_ns="$2"
|
||||
local cl_proto="$3"
|
||||
local srv_proto="$4"
|
||||
local connect_addr="$5"
|
||||
|
||||
port=12001
|
||||
local port=12001
|
||||
|
||||
:> "$cout"
|
||||
:> "$sout"
|
||||
|
||||
mptcp_connect="./mptcp_connect -r 20"
|
||||
local mptcp_connect="./mptcp_connect -r 20"
|
||||
|
||||
local local_addr
|
||||
if is_v6 "${connect_addr}"; then
|
||||
@ -180,7 +186,7 @@ do_transfer()
|
||||
ip netns exec ${listener_ns} \
|
||||
$mptcp_connect -t ${timeout_poll} -l -M 1 -p $port -s ${srv_proto} -c TIMESTAMPNS,TCPINQ \
|
||||
${local_addr} < "$sin" > "$sout" &
|
||||
spid=$!
|
||||
local spid=$!
|
||||
|
||||
sleep 1
|
||||
|
||||
@ -189,12 +195,12 @@ do_transfer()
|
||||
$mptcp_connect -t ${timeout_poll} -M 2 -p $port -s ${cl_proto} -c TIMESTAMPNS,TCPINQ \
|
||||
$connect_addr < "$cin" > "$cout" &
|
||||
|
||||
cpid=$!
|
||||
local cpid=$!
|
||||
|
||||
wait $cpid
|
||||
retc=$?
|
||||
local retc=$?
|
||||
wait $spid
|
||||
rets=$?
|
||||
local rets=$?
|
||||
|
||||
if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
|
||||
echo " client exit code $retc, server $rets" 1>&2
|
||||
@ -229,9 +235,9 @@ do_transfer()
|
||||
|
||||
make_file()
|
||||
{
|
||||
name=$1
|
||||
who=$2
|
||||
size=$3
|
||||
local name=$1
|
||||
local who=$2
|
||||
local size=$3
|
||||
|
||||
dd if=/dev/urandom of="$name" bs=1024 count=$size 2> /dev/null
|
||||
echo -e "\nMPTCP_TEST_FILE_END_MARKER" >> "$name"
|
||||
@ -264,9 +270,9 @@ do_mptcp_sockopt_tests()
|
||||
|
||||
run_tests()
|
||||
{
|
||||
listener_ns="$1"
|
||||
connector_ns="$2"
|
||||
connect_addr="$3"
|
||||
local listener_ns="$1"
|
||||
local connector_ns="$2"
|
||||
local connect_addr="$3"
|
||||
local lret=0
|
||||
|
||||
do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr}
|
||||
@ -282,7 +288,7 @@ run_tests()
|
||||
do_tcpinq_test()
|
||||
{
|
||||
ip netns exec "$ns_sbox" ./mptcp_inq "$@"
|
||||
lret=$?
|
||||
local lret=$?
|
||||
if [ $lret -ne 0 ];then
|
||||
ret=$lret
|
||||
echo "FAIL: mptcp_inq $@" 1>&2
|
||||
@ -297,6 +303,7 @@ do_tcpinq_tests()
|
||||
{
|
||||
local lret=0
|
||||
|
||||
local args
|
||||
for args in "-t tcp" "-r tcp"; do
|
||||
do_tcpinq_test $args
|
||||
lret=$?
|
||||
|
Loading…
Reference in New Issue
Block a user