Skip to content

Commit

Permalink
selftests, bpf: Fix test_tc_tunnel hanging
Browse files Browse the repository at this point in the history
When run_kselftests.sh is run, it hangs after test_tc_tunnel.sh. The reason
is test_tc_tunnel.sh ensures the server ('nc -l') is run all the time,
starting it again every time it is expected to terminate. The exception is
the final client_connect: the server is not started anymore, which ensures
no process is kept running after the test is finished.

For a sit test, though, the script is terminated prematurely without the
final client_connect and the 'nc' process keeps running. This in turn causes
the run_one function in kselftest/runner.sh to hang forever, waiting for the
runaway process to finish.

Ensure a remaining server is terminated on cleanup.

Fixes: f6ad6ac ("selftests/bpf: expand test_tc_tunnel with SIT encap")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/bpf/60919291657a9ee89c708d8aababc28ebe1420be.1573821780.git.jbenc@redhat.com
  • Loading branch information
Jiri Benc authored and Daniel Borkmann committed Nov 18, 2019
1 parent 56bf877 commit 3b054b7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/testing/selftests/bpf/test_tc_tunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ cleanup() {
if [[ -f "${infile}" ]]; then
rm "${infile}"
fi

if [[ -n $server_pid ]]; then
kill $server_pid 2> /dev/null
fi
}

server_listen() {
Expand All @@ -77,6 +81,7 @@ client_connect() {

verify_data() {
wait "${server_pid}"
server_pid=
# sha1sum returns two fields [sha1] [filepath]
# convert to bash array and access first elem
insum=($(sha1sum ${infile}))
Expand Down

0 comments on commit 3b054b7

Please sign in to comment.