Commit 1cc94ac1 authored by Geliang Tang's avatar Geliang Tang Committed by Jakub Kicinski

selftests: mptcp: make evts global in userspace_pm

This patch makes server_evts and client_evts global in userspace_pm.sh,
then these two variables could be used in test_announce(), test_remove()
and test_subflows(). The local variable 'evts' in these three functions
then could be dropped.

Also move local variable 'file' as a global one.
Suggested-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarGeliang Tang <geliang.tang@suse.com>
Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7dff74f5
...@@ -15,7 +15,11 @@ SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED ...@@ -15,7 +15,11 @@ SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED
AF_INET=2 AF_INET=2
AF_INET6=10 AF_INET6=10
evts_pid=0 file=""
server_evts=""
client_evts=""
server_evts_pid=0
client_evts_pid=0
client4_pid=0 client4_pid=0
server4_pid=0 server4_pid=0
client6_pid=0 client6_pid=0
...@@ -47,7 +51,7 @@ cleanup() ...@@ -47,7 +51,7 @@ cleanup()
{ {
echo "cleanup" echo "cleanup"
rm -rf $file rm -rf $file $client_evts $server_evts
# Terminate the MPTCP connection and related processes # Terminate the MPTCP connection and related processes
if [ $client4_pid -ne 0 ]; then if [ $client4_pid -ne 0 ]; then
...@@ -62,8 +66,11 @@ cleanup() ...@@ -62,8 +66,11 @@ cleanup()
if [ $server6_pid -ne 0 ]; then if [ $server6_pid -ne 0 ]; then
kill_wait $server6_pid kill_wait $server6_pid
fi fi
if [ $evts_pid -ne 0 ]; then if [ $server_evts_pid -ne 0 ]; then
kill_wait $evts_pid kill_wait $server_evts_pid
fi
if [ $client_evts_pid -ne 0 ]; then
kill_wait $client_evts_pid
fi fi
local netns local netns
for netns in "$ns1" "$ns2" ;do for netns in "$ns1" "$ns2" ;do
...@@ -113,8 +120,9 @@ make_file() ...@@ -113,8 +120,9 @@ make_file()
make_connection() make_connection()
{ {
local file if [ -z "$file" ]; then
file=$(mktemp) file=$(mktemp)
fi
make_file "$file" "client" make_file "$file" "client"
local is_v6=$1 local is_v6=$1
...@@ -132,16 +140,24 @@ make_connection() ...@@ -132,16 +140,24 @@ make_connection()
# Capture netlink events over the two network namespaces running # Capture netlink events over the two network namespaces running
# the MPTCP client and server # the MPTCP client and server
local client_evts if [ -z "$client_evts" ]; then
client_evts=$(mktemp) client_evts=$(mktemp)
fi
:>"$client_evts" :>"$client_evts"
if [ $client_evts_pid -ne 0 ]; then
kill_wait $client_evts_pid
fi
ip netns exec "$ns2" ./pm_nl_ctl events >> "$client_evts" 2>&1 & ip netns exec "$ns2" ./pm_nl_ctl events >> "$client_evts" 2>&1 &
local client_evts_pid=$! client_evts_pid=$!
local server_evts if [ -z "$server_evts" ]; then
server_evts=$(mktemp) server_evts=$(mktemp)
fi
:>"$server_evts" :>"$server_evts"
if [ $server_evts_pid -ne 0 ]; then
kill_wait $server_evts_pid
fi
ip netns exec "$ns1" ./pm_nl_ctl events >> "$server_evts" 2>&1 & ip netns exec "$ns1" ./pm_nl_ctl events >> "$server_evts" 2>&1 &
local server_evts_pid=$! server_evts_pid=$!
sleep 0.5 sleep 0.5
# Run the server # Run the server
...@@ -159,7 +175,6 @@ make_connection() ...@@ -159,7 +175,6 @@ make_connection()
sleep 1 sleep 1
# Capture client/server attributes from MPTCP connection netlink events # Capture client/server attributes from MPTCP connection netlink events
kill_wait $client_evts_pid
local client_token local client_token
local client_port local client_port
...@@ -171,12 +186,10 @@ make_connection() ...@@ -171,12 +186,10 @@ make_connection()
client_port=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$client_evts") client_port=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$client_evts")
client_serverside=$(sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q'\ client_serverside=$(sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q'\
"$client_evts") "$client_evts")
kill_wait $server_evts_pid
server_token=$(grep "type:1," "$server_evts" | server_token=$(grep "type:1," "$server_evts" |
sed --unbuffered -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q') sed --unbuffered -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q')
server_serverside=$(grep "type:1," "$server_evts" | server_serverside=$(grep "type:1," "$server_evts" |
sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q') sed --unbuffered -n 's/.*\(server_side:\)\([[:digit:]]*\).*$/\2/p;q')
rm -f "$client_evts" "$server_evts" "$file"
if [ "$client_token" != "" ] && [ "$server_token" != "" ] && [ "$client_serverside" = 0 ] && if [ "$client_token" != "" ] && [ "$server_token" != "" ] && [ "$client_serverside" = 0 ] &&
[ "$server_serverside" = 1 ] [ "$server_serverside" = 1 ]
...@@ -240,13 +253,8 @@ verify_announce_event() ...@@ -240,13 +253,8 @@ verify_announce_event()
test_announce() test_announce()
{ {
local evts
evts=$(mktemp)
# Capture events on the network namespace running the server # Capture events on the network namespace running the server
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl events >> "$evts" 2>&1 &
evts_pid=$!
sleep 0.5
# ADD_ADDR using an invalid token should result in no action # ADD_ADDR using an invalid token should result in no action
local invalid_token=$(( client4_token - 1)) local invalid_token=$(( client4_token - 1))
...@@ -254,7 +262,7 @@ test_announce() ...@@ -254,7 +262,7 @@ test_announce()
$client_addr_id dev ns2eth1 > /dev/null 2>&1 $client_addr_id dev ns2eth1 > /dev/null 2>&1
local type local type
type=$(sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") type=$(sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts")
stdbuf -o0 -e0 printf "ADD_ADDR 10.0.2.2 (ns2) => ns1, invalid token \t\t" stdbuf -o0 -e0 printf "ADD_ADDR 10.0.2.2 (ns2) => ns1, invalid token \t\t"
if [ "$type" = "" ] if [ "$type" = "" ]
then then
...@@ -265,71 +273,63 @@ test_announce() ...@@ -265,71 +273,63 @@ test_announce()
fi fi
# ADD_ADDR from the client to server machine reusing the subflow port # ADD_ADDR from the client to server machine reusing the subflow port
:>"$evts" :>"$server_evts"
ip netns exec "$ns2"\ ip netns exec "$ns2"\
./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id $client_addr_id dev\ ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id $client_addr_id dev\
ns2eth1 > /dev/null 2>&1 ns2eth1 > /dev/null 2>&1
stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.2 (ns2) => ns1, reuse port \t\t" $client_addr_id stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.2 (ns2) => ns1, reuse port \t\t" $client_addr_id
sleep 0.5 sleep 0.5
verify_announce_event "$evts" "$ANNOUNCED" "$server4_token" "10.0.2.2" "$client_addr_id"\ verify_announce_event $server_evts $ANNOUNCED $server4_token "10.0.2.2" $client_addr_id \
"$client4_port" "$client4_port"
# ADD_ADDR6 from the client to server machine reusing the subflow port # ADD_ADDR6 from the client to server machine reusing the subflow port
:>"$evts" :>"$server_evts"
ip netns exec "$ns2" ./pm_nl_ctl ann\ ip netns exec "$ns2" ./pm_nl_ctl ann\
dead:beef:2::2 token "$client6_token" id $client_addr_id dev ns2eth1 > /dev/null 2>&1 dead:beef:2::2 token "$client6_token" id $client_addr_id dev ns2eth1 > /dev/null 2>&1
stdbuf -o0 -e0 printf "ADD_ADDR6 id:%d dead:beef:2::2 (ns2) => ns1, reuse port\t\t" $client_addr_id stdbuf -o0 -e0 printf "ADD_ADDR6 id:%d dead:beef:2::2 (ns2) => ns1, reuse port\t\t" $client_addr_id
sleep 0.5 sleep 0.5
verify_announce_event "$evts" "$ANNOUNCED" "$server6_token" "dead:beef:2::2"\ verify_announce_event "$server_evts" "$ANNOUNCED" "$server6_token" "dead:beef:2::2"\
"$client_addr_id" "$client6_port" "v6" "$client_addr_id" "$client6_port" "v6"
# ADD_ADDR from the client to server machine using a new port # ADD_ADDR from the client to server machine using a new port
:>"$evts" :>"$server_evts"
client_addr_id=$((client_addr_id+1)) client_addr_id=$((client_addr_id+1))
ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\ ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\
$client_addr_id dev ns2eth1 port $new4_port > /dev/null 2>&1 $client_addr_id dev ns2eth1 port $new4_port > /dev/null 2>&1
stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.2 (ns2) => ns1, new port \t\t\t" $client_addr_id stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.2 (ns2) => ns1, new port \t\t\t" $client_addr_id
sleep 0.5 sleep 0.5
verify_announce_event "$evts" "$ANNOUNCED" "$server4_token" "10.0.2.2"\ verify_announce_event "$server_evts" "$ANNOUNCED" "$server4_token" "10.0.2.2"\
"$client_addr_id" "$new4_port" "$client_addr_id" "$new4_port"
kill_wait $evts_pid
# Capture events on the network namespace running the client # Capture events on the network namespace running the client
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl events >> "$evts" 2>&1 &
evts_pid=$!
sleep 0.5
# ADD_ADDR from the server to client machine reusing the subflow port # ADD_ADDR from the server to client machine reusing the subflow port
ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\ ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\
$server_addr_id dev ns1eth2 > /dev/null 2>&1 $server_addr_id dev ns1eth2 > /dev/null 2>&1
stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.1 (ns1) => ns2, reuse port \t\t" $server_addr_id stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.1 (ns1) => ns2, reuse port \t\t" $server_addr_id
sleep 0.5 sleep 0.5
verify_announce_event "$evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\ verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\
"$server_addr_id" "$app4_port" "$server_addr_id" "$app4_port"
# ADD_ADDR6 from the server to client machine reusing the subflow port # ADD_ADDR6 from the server to client machine reusing the subflow port
:>"$evts" :>"$client_evts"
ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\ ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\
$server_addr_id dev ns1eth2 > /dev/null 2>&1 $server_addr_id dev ns1eth2 > /dev/null 2>&1
stdbuf -o0 -e0 printf "ADD_ADDR6 id:%d dead:beef:2::1 (ns1) => ns2, reuse port\t\t" $server_addr_id stdbuf -o0 -e0 printf "ADD_ADDR6 id:%d dead:beef:2::1 (ns1) => ns2, reuse port\t\t" $server_addr_id
sleep 0.5 sleep 0.5
verify_announce_event "$evts" "$ANNOUNCED" "$client6_token" "dead:beef:2::1"\ verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "dead:beef:2::1"\
"$server_addr_id" "$app6_port" "v6" "$server_addr_id" "$app6_port" "v6"
# ADD_ADDR from the server to client machine using a new port # ADD_ADDR from the server to client machine using a new port
:>"$evts" :>"$client_evts"
server_addr_id=$((server_addr_id+1)) server_addr_id=$((server_addr_id+1))
ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\ ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\
$server_addr_id dev ns1eth2 port $new4_port > /dev/null 2>&1 $server_addr_id dev ns1eth2 port $new4_port > /dev/null 2>&1
stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.1 (ns1) => ns2, new port \t\t\t" $server_addr_id stdbuf -o0 -e0 printf "ADD_ADDR id:%d 10.0.2.1 (ns1) => ns2, new port \t\t\t" $server_addr_id
sleep 0.5 sleep 0.5
verify_announce_event "$evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\ verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\
"$server_addr_id" "$new4_port" "$server_addr_id" "$new4_port"
kill_wait $evts_pid
rm -f "$evts"
} }
verify_remove_event() verify_remove_event()
...@@ -357,14 +357,8 @@ verify_remove_event() ...@@ -357,14 +357,8 @@ verify_remove_event()
test_remove() test_remove()
{ {
local evts
evts=$(mktemp)
# Capture events on the network namespace running the server # Capture events on the network namespace running the server
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl events >> "$evts" 2>&1 &
evts_pid=$!
sleep 0.5
# RM_ADDR using an invalid token should result in no action # RM_ADDR using an invalid token should result in no action
local invalid_token=$(( client4_token - 1 )) local invalid_token=$(( client4_token - 1 ))
...@@ -373,7 +367,7 @@ test_remove() ...@@ -373,7 +367,7 @@ test_remove()
stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1, invalid token \t"\ stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1, invalid token \t"\
$client_addr_id $client_addr_id
local type local type
type=$(sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") type=$(sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts")
if [ "$type" = "" ] if [ "$type" = "" ]
then then
stdbuf -o0 -e0 printf "[OK]\n" stdbuf -o0 -e0 printf "[OK]\n"
...@@ -387,7 +381,7 @@ test_remove() ...@@ -387,7 +381,7 @@ test_remove()
$invalid_id > /dev/null 2>&1 $invalid_id > /dev/null 2>&1
stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1, invalid id \t"\ stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1, invalid id \t"\
$invalid_id $invalid_id
type=$(sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") type=$(sed --unbuffered -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts")
if [ "$type" = "" ] if [ "$type" = "" ]
then then
stdbuf -o0 -e0 printf "[OK]\n" stdbuf -o0 -e0 printf "[OK]\n"
...@@ -396,40 +390,35 @@ test_remove() ...@@ -396,40 +390,35 @@ test_remove()
fi fi
# RM_ADDR from the client to server machine # RM_ADDR from the client to server machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\ ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\
$client_addr_id > /dev/null 2>&1 $client_addr_id > /dev/null 2>&1
stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1 \t"\ stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1 \t"\
$client_addr_id $client_addr_id
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$server4_token" "$client_addr_id" verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_addr_id"
# RM_ADDR from the client to server machine # RM_ADDR from the client to server machine
:>"$evts" :>"$server_evts"
client_addr_id=$(( client_addr_id - 1 )) client_addr_id=$(( client_addr_id - 1 ))
ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\ ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\
$client_addr_id > /dev/null 2>&1 $client_addr_id > /dev/null 2>&1
stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1 \t"\ stdbuf -o0 -e0 printf "RM_ADDR id:%d ns2 => ns1 \t"\
$client_addr_id $client_addr_id
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$server4_token" "$client_addr_id" verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_addr_id"
# RM_ADDR6 from the client to server machine # RM_ADDR6 from the client to server machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns2" ./pm_nl_ctl rem token "$client6_token" id\ ip netns exec "$ns2" ./pm_nl_ctl rem token "$client6_token" id\
$client_addr_id > /dev/null 2>&1 $client_addr_id > /dev/null 2>&1
stdbuf -o0 -e0 printf "RM_ADDR6 id:%d ns2 => ns1 \t"\ stdbuf -o0 -e0 printf "RM_ADDR6 id:%d ns2 => ns1 \t"\
$client_addr_id $client_addr_id
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$server6_token" "$client_addr_id" verify_remove_event "$server_evts" "$REMOVED" "$server6_token" "$client_addr_id"
kill_wait $evts_pid
# Capture events on the network namespace running the client # Capture events on the network namespace running the client
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl events >> "$evts" 2>&1 &
evts_pid=$!
sleep 0.5
# RM_ADDR from the server to client machine # RM_ADDR from the server to client machine
ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\ ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\
...@@ -437,27 +426,24 @@ test_remove() ...@@ -437,27 +426,24 @@ test_remove()
stdbuf -o0 -e0 printf "RM_ADDR id:%d ns1 => ns2 \t"\ stdbuf -o0 -e0 printf "RM_ADDR id:%d ns1 => ns2 \t"\
$server_addr_id $server_addr_id
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$client4_token" "$server_addr_id" verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_addr_id"
# RM_ADDR from the server to client machine # RM_ADDR from the server to client machine
:>"$evts" :>"$client_evts"
server_addr_id=$(( server_addr_id - 1 )) server_addr_id=$(( server_addr_id - 1 ))
ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\ ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\
$server_addr_id > /dev/null 2>&1 $server_addr_id > /dev/null 2>&1
stdbuf -o0 -e0 printf "RM_ADDR id:%d ns1 => ns2 \t" $server_addr_id stdbuf -o0 -e0 printf "RM_ADDR id:%d ns1 => ns2 \t" $server_addr_id
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$client4_token" "$server_addr_id" verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_addr_id"
# RM_ADDR6 from the server to client machine # RM_ADDR6 from the server to client machine
:>"$evts" :>"$client_evts"
ip netns exec "$ns1" ./pm_nl_ctl rem token "$server6_token" id\ ip netns exec "$ns1" ./pm_nl_ctl rem token "$server6_token" id\
$server_addr_id > /dev/null 2>&1 $server_addr_id > /dev/null 2>&1
stdbuf -o0 -e0 printf "RM_ADDR6 id:%d ns1 => ns2 \t" $server_addr_id stdbuf -o0 -e0 printf "RM_ADDR6 id:%d ns1 => ns2 \t" $server_addr_id
sleep 0.5 sleep 0.5
verify_remove_event "$evts" "$REMOVED" "$client6_token" "$server_addr_id" verify_remove_event "$client_evts" "$REMOVED" "$client6_token" "$server_addr_id"
kill_wait $evts_pid
rm -f "$evts"
} }
verify_subflow_events() verify_subflow_events()
...@@ -533,13 +519,8 @@ verify_subflow_events() ...@@ -533,13 +519,8 @@ verify_subflow_events()
test_subflows() test_subflows()
{ {
local evts
evts=$(mktemp)
# Capture events on the network namespace running the server # Capture events on the network namespace running the server
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl events >> "$evts" 2>&1 &
evts_pid=$!
sleep 0.5
# Attempt to add a listener at 10.0.2.2:<subflow-port> # Attempt to add a listener at 10.0.2.2:<subflow-port>
ip netns exec "$ns2" ./pm_nl_ctl listen 10.0.2.2\ ip netns exec "$ns2" ./pm_nl_ctl listen 10.0.2.2\
...@@ -552,25 +533,25 @@ test_subflows() ...@@ -552,25 +533,25 @@ test_subflows()
sleep 0.5 sleep 0.5
# CREATE_SUBFLOW from server to client machine # CREATE_SUBFLOW from server to client machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2\ ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2\
rport "$client4_port" token "$server4_token" > /dev/null 2>&1 rport "$client4_port" token "$server4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_ESTABLISHED" "$server4_token" "$AF_INET" "10.0.2.1"\ verify_subflow_events $server_evts $SUB_ESTABLISHED $server4_token $AF_INET "10.0.2.1" \
"10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2" "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2"
# Delete the listener from the client ns, if one was created # Delete the listener from the client ns, if one was created
kill_wait $listener_pid kill_wait $listener_pid
local sport local sport
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts")
# DESTROY_SUBFLOW from server to client machine # DESTROY_SUBFLOW from server to client machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\ ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\
"$client4_port" token "$server4_token" > /dev/null 2>&1 "$client4_port" token "$server4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\ verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\
"10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2" "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2"
# RM_ADDR from client to server machine # RM_ADDR from client to server machine
...@@ -584,31 +565,31 @@ test_subflows() ...@@ -584,31 +565,31 @@ test_subflows()
listener_pid=$! listener_pid=$!
# ADD_ADDR6 from client to server machine reusing the subflow port # ADD_ADDR6 from client to server machine reusing the subflow port
:>"$evts" :>"$server_evts"
ip netns exec "$ns2" ./pm_nl_ctl ann dead:beef:2::2 token "$client6_token" id\ ip netns exec "$ns2" ./pm_nl_ctl ann dead:beef:2::2 token "$client6_token" id\
$client_addr_id > /dev/null 2>&1 $client_addr_id > /dev/null 2>&1
sleep 0.5 sleep 0.5
# CREATE_SUBFLOW6 from server to client machine # CREATE_SUBFLOW6 from server to client machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl csf lip dead:beef:2::1 lid 23 rip\ ip netns exec "$ns1" ./pm_nl_ctl csf lip dead:beef:2::1 lid 23 rip\
dead:beef:2::2 rport "$client6_port" token "$server6_token" > /dev/null 2>&1 dead:beef:2::2 rport "$client6_port" token "$server6_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_ESTABLISHED" "$server6_token" "$AF_INET6"\ verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server6_token" "$AF_INET6"\
"dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\ "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\
"$client_addr_id" "ns1" "ns2" "$client_addr_id" "ns1" "ns2"
# Delete the listener from the client ns, if one was created # Delete the listener from the client ns, if one was created
kill_wait $listener_pid kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts")
# DESTROY_SUBFLOW6 from server to client machine # DESTROY_SUBFLOW6 from server to client machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl dsf lip dead:beef:2::1 lport "$sport" rip\ ip netns exec "$ns1" ./pm_nl_ctl dsf lip dead:beef:2::1 lport "$sport" rip\
dead:beef:2::2 rport "$client6_port" token "$server6_token" > /dev/null 2>&1 dead:beef:2::2 rport "$client6_port" token "$server6_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_CLOSED" "$server6_token" "$AF_INET6"\ verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server6_token" "$AF_INET6"\
"dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\ "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\
"$client_addr_id" "ns1" "ns2" "$client_addr_id" "ns1" "ns2"
...@@ -623,44 +604,39 @@ test_subflows() ...@@ -623,44 +604,39 @@ test_subflows()
listener_pid=$! listener_pid=$!
# ADD_ADDR from client to server machine using a new port # ADD_ADDR from client to server machine using a new port
:>"$evts" :>"$server_evts"
ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\ ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\
$client_addr_id port $new4_port > /dev/null 2>&1 $client_addr_id port $new4_port > /dev/null 2>&1
sleep 0.5 sleep 0.5
# CREATE_SUBFLOW from server to client machine # CREATE_SUBFLOW from server to client machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2 rport\ ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2 rport\
$new4_port token "$server4_token" > /dev/null 2>&1 $new4_port token "$server4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_ESTABLISHED" "$server4_token" "$AF_INET"\ verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server4_token" "$AF_INET"\
"10.0.2.1" "10.0.2.2" "$new4_port" "23"\ "10.0.2.1" "10.0.2.2" "$new4_port" "23"\
"$client_addr_id" "ns1" "ns2" "$client_addr_id" "ns1" "ns2"
# Delete the listener from the client ns, if one was created # Delete the listener from the client ns, if one was created
kill_wait $listener_pid kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$server_evts")
# DESTROY_SUBFLOW from server to client machine # DESTROY_SUBFLOW from server to client machine
:>"$evts" :>"$server_evts"
ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\ ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\
$new4_port token "$server4_token" > /dev/null 2>&1 $new4_port token "$server4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\ verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\
"10.0.2.2" "$new4_port" "23" "$client_addr_id" "ns1" "ns2" "10.0.2.2" "$new4_port" "23" "$client_addr_id" "ns1" "ns2"
# RM_ADDR from client to server machine # RM_ADDR from client to server machine
ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\ ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\
"$client4_token" > /dev/null 2>&1 "$client4_token" > /dev/null 2>&1
kill_wait $evts_pid
# Capture events on the network namespace running the client # Capture events on the network namespace running the client
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl events >> "$evts" 2>&1 &
evts_pid=$!
sleep 0.5
# Attempt to add a listener at 10.0.2.1:<subflow-port> # Attempt to add a listener at 10.0.2.1:<subflow-port>
ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\ ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\
...@@ -673,24 +649,24 @@ test_subflows() ...@@ -673,24 +649,24 @@ test_subflows()
sleep 0.5 sleep 0.5
# CREATE_SUBFLOW from client to server machine # CREATE_SUBFLOW from client to server machine
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\ ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\
$app4_port token "$client4_token" > /dev/null 2>&1 $app4_port token "$client4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_ESTABLISHED" "$client4_token" "$AF_INET" "10.0.2.2"\ verify_subflow_events $client_evts $SUB_ESTABLISHED $client4_token $AF_INET "10.0.2.2"\
"10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1"
# Delete the listener from the server ns, if one was created # Delete the listener from the server ns, if one was created
kill_wait $listener_pid kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$client_evts")
# DESTROY_SUBFLOW from client to server machine # DESTROY_SUBFLOW from client to server machine
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\
$app4_port token "$client4_token" > /dev/null 2>&1 $app4_port token "$client4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\ verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\
"10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1" "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1"
# RM_ADDR from server to client machine # RM_ADDR from server to client machine
...@@ -704,17 +680,17 @@ test_subflows() ...@@ -704,17 +680,17 @@ test_subflows()
listener_pid=$! listener_pid=$!
# ADD_ADDR6 from server to client machine reusing the subflow port # ADD_ADDR6 from server to client machine reusing the subflow port
:>"$evts" :>"$client_evts"
ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\ ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\
$server_addr_id > /dev/null 2>&1 $server_addr_id > /dev/null 2>&1
sleep 0.5 sleep 0.5
# CREATE_SUBFLOW6 from client to server machine # CREATE_SUBFLOW6 from client to server machine
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl csf lip dead:beef:2::2 lid 23 rip\ ip netns exec "$ns2" ./pm_nl_ctl csf lip dead:beef:2::2 lid 23 rip\
dead:beef:2::1 rport $app6_port token "$client6_token" > /dev/null 2>&1 dead:beef:2::1 rport $app6_port token "$client6_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_ESTABLISHED" "$client6_token"\ verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\
"$AF_INET6" "dead:beef:2::2"\ "$AF_INET6" "dead:beef:2::2"\
"dead:beef:2::1" "$app6_port" "23"\ "dead:beef:2::1" "$app6_port" "23"\
"$server_addr_id" "ns2" "ns1" "$server_addr_id" "ns2" "ns1"
...@@ -722,14 +698,14 @@ test_subflows() ...@@ -722,14 +698,14 @@ test_subflows()
# Delete the listener from the server ns, if one was created # Delete the listener from the server ns, if one was created
kill_wait $listener_pid kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$client_evts")
# DESTROY_SUBFLOW6 from client to server machine # DESTROY_SUBFLOW6 from client to server machine
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl dsf lip dead:beef:2::2 lport "$sport" rip\ ip netns exec "$ns2" ./pm_nl_ctl dsf lip dead:beef:2::2 lport "$sport" rip\
dead:beef:2::1 rport $app6_port token "$client6_token" > /dev/null 2>&1 dead:beef:2::1 rport $app6_port token "$client6_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_CLOSED" "$client6_token" "$AF_INET6" "dead:beef:2::2"\ verify_subflow_events $client_evts $SUB_CLOSED $client6_token $AF_INET6 "dead:beef:2::2"\
"dead:beef:2::1" "$app6_port" "23" "$server_addr_id" "ns2" "ns1" "dead:beef:2::1" "$app6_port" "23" "$server_addr_id" "ns2" "ns1"
# RM_ADDR6 from server to client machine # RM_ADDR6 from server to client machine
...@@ -743,38 +719,35 @@ test_subflows() ...@@ -743,38 +719,35 @@ test_subflows()
listener_pid=$! listener_pid=$!
# ADD_ADDR from server to client machine using a new port # ADD_ADDR from server to client machine using a new port
:>"$evts" :>"$client_evts"
ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\ ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\
$server_addr_id port $new4_port > /dev/null 2>&1 $server_addr_id port $new4_port > /dev/null 2>&1
sleep 0.5 sleep 0.5
# CREATE_SUBFLOW from client to server machine # CREATE_SUBFLOW from client to server machine
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\ ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\
$new4_port token "$client4_token" > /dev/null 2>&1 $new4_port token "$client4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_ESTABLISHED" "$client4_token" "$AF_INET"\ verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client4_token" "$AF_INET"\
"10.0.2.2" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1" "10.0.2.2" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1"
# Delete the listener from the server ns, if one was created # Delete the listener from the server ns, if one was created
kill_wait $listener_pid kill_wait $listener_pid
sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts") sport=$(sed --unbuffered -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q' "$client_evts")
# DESTROY_SUBFLOW from client to server machine # DESTROY_SUBFLOW from client to server machine
:>"$evts" :>"$client_evts"
ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\ ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\
$new4_port token "$client4_token" > /dev/null 2>&1 $new4_port token "$client4_token" > /dev/null 2>&1
sleep 0.5 sleep 0.5
verify_subflow_events "$evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\ verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\
"10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1"
# RM_ADDR from server to client machine # RM_ADDR from server to client machine
ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\ ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\
"$server4_token" > /dev/null 2>&1 "$server4_token" > /dev/null 2>&1
kill_wait $evts_pid
rm -f "$evts"
} }
test_prio() test_prio()
......
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