This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
tcptracer-bpf.c: remove dead entries from the tuplepid_ipv{4,6} #23
Merged
iaguis
merged 3 commits into
weaveworks:master
from
kinvolk-archives:iaguis/fix-set-state
Mar 8, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
./pkg/tracer/tcptracer-ebpf.go | ||
./ebpf/tcptracer-ebpf.go | ||
./.git/* |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
readonly nonlistening_port=65530 | ||
|
||
for _ in $(seq 1 "$1"); do | ||
wget -q http://127.0.0.1:"${nonlistening_port}" &>/dev/null | ||
done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
if [[ $EUID -ne 0 ]]; then | ||
echo "root required - aborting" >&2 | ||
exit 1 | ||
fi | ||
|
||
readonly dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
readonly tracer="${dir}/tracer" | ||
readonly port=61111 | ||
readonly netns=$(mktemp /tmp/tcptracer-bpf-test-netns-XXXXXXXX) | ||
readonly tracer_output=$(mktemp /tmp/tcptracer-bpf-test-stdout-XXXXXXXX) | ||
exec 3<> <(tail --pid "$$" -f "${tracer_output}") | ||
server_pid=-1 | ||
tracer_pid=-1 | ||
|
||
function shutdown() { | ||
if [[ $server_pid -ne -1 ]]; then | ||
kill $server_pid 2>/dev/null || true | ||
fi | ||
if [[ $tracer_pid -ne -1 ]]; then | ||
kill $tracer_pid 2>/dev/null || true | ||
fi | ||
exec 3>&- | ||
rm "${tracer_output}" | ||
umount -f "${netns}" | ||
rm "${netns}" | ||
} | ||
|
||
trap shutdown EXIT | ||
|
||
unshare --net="${netns}" ip link set lo up | ||
nsenter --net="${netns}" "${tracer}" >&3 & | ||
tracer_pid=$! | ||
|
||
sleep 1 # wait for tracer to load | ||
|
||
# stop and fail here when tracer encountered an error and didn't start | ||
ps -p "$tracer_pid" >/dev/null | ||
|
||
# generate some refused connections to test for | ||
# https://github.com/weaveworks/tcptracer-bpf/issues/21 | ||
nsenter --net="${netns}" ./multiple_connections_refused.sh "1200" | ||
|
||
nsenter --net="${netns}" nc -l "${port}" & | ||
server_pid=$! | ||
nsenter --net="${netns}" nc 127.0.0.1 "${port}" & | ||
|
||
lines_found=0 | ||
lines_read=0 | ||
while [[ $lines_read -lt 4 ]]; do | ||
read -r -u 3 line | ||
# 48704147610580 cpu#1 connect 2074 nc 127.0.0.1:52414 127.0.0.1:61111 4026532567 | ||
if [[ "$line" =~ ^[0-9]+\ cpu#[0-9]\ ([a-z]+)\ [0-9]+\ nc\ (127.0.0.1\:[0-9]+)\ (127.0.0.1\:[0-9]+)\ [0-9]+$ ]]; then | ||
action=${BASH_REMATCH[1]} | ||
saddr=${BASH_REMATCH[2]} | ||
daddr=${BASH_REMATCH[3]} | ||
lines_read=$((lines_read + 1)) | ||
printf "action: %s program: nc saddr: %s daddr: %s\n" "${action}" "${saddr}" "${daddr}" | ||
if [[ "${action}" == "connect" && "$daddr" == "127.0.0.1:${port}" ]] \ | ||
|| [[ "${action}" == "accept" && "$saddr" == "127.0.0.1:${port}" ]] \ | ||
|| [[ "${action}" == "close" && "$daddr" == "127.0.0.1:${port}" ]] \ | ||
|| [[ "${action}" == "close" && "$saddr" == "127.0.0.1:${port}" ]]; then | ||
lines_found=$((lines_found + 1)) | ||
else | ||
echo "^^^ unexpected values in event" | ||
fi | ||
fi | ||
done | ||
|
||
if [[ $lines_found -eq 4 ]]; then | ||
echo "success" | ||
exit 0 | ||
else | ||
echo "failure" | ||
exit 1 | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
Sorry, something went wrong.