Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net-test: packetdrill: tcpdump: reduce sleep #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions gtests/net/packetdrill/in_netns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ setup() {
ip netns add "${NETNS}"
ip -netns "${NETNS}" link set lo up
if [ -n "${TCPDUMP_OUTPUT}" ]; then
ip netns exec "${NETNS}" tcpdump -i any -s 150 -w "${TCPDUMP_OUTPUT}" &
mkdir -p "$(dirname "${TCPDUMP_OUTPUT}")"

ip netns exec "${NETNS}" tcpdump -i any -s 150 --immediate-mode --packet-buffered -w "${TCPDUMP_OUTPUT}" &
TCPDUMP_PID=$!
sleep 1 # give some time to TCPDump to start

# give some time to TCPDump to start
for _ in $(seq 10); do
[ -s "${TCPDUMP_OUTPUT}" ] && break
# BusyBox's sleep doesn't support float numbers, just wait 1 sec
if ! sleep 0.1 2>/dev/null; then
sleep 1
break
fi
done
fi
}

cleanup() {
if [ -n "${TCPDUMP_PID}" ]; then
sleep 1 # give some time to TCPDump to process the packets
# give some time to TCPDump to get the last packets
sleep 0.1 2>/dev/null || sleep 1
kill "${TCPDUMP_PID}"
wait "${TCPDUMP_PID}" 2>/dev/null || true
fi
Expand Down