-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpf: use sched_process_fork instead of clone/clone3/fork/vfork
- Loading branch information
Showing
9 changed files
with
153 additions
and
105 deletions.
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 |
---|---|---|
|
@@ -78,18 +78,9 @@ jobs: | |
uname -a | ||
cat /etc/issue | ||
timeout 20s /host/ptcpdump/ptcpdump -c 1 -i any --print -w ptcpdump.pcapng 'dst host 1.1.1.1 and tcp[tcpflags] = tcp-syn' 2>&1 1>/tmp/log | (read _; curl -m 10 1.1.1.1 &>/dev/null || true) | ||
bash /host/ptcpdump/testdata/test_base.sh /host/ptcpdump/ptcpdump | ||
cat /tmp/log | ||
cat /tmp/log | grep '/usr/bin/curl' | ||
cat /tmp/log | grep -F ' > 1.1.1.1.80: Flags [S],' | ||
apt update || true | ||
apt install -y tcpdump | ||
tcpdump -nr ./ptcpdump.pcapng | ||
tcpdump -nr ./ptcpdump.pcapng | grep -F ' > 1.1.1.1.80: Flags [S],' | ||
- name: Test filter by process | ||
- name: Test filter by process name | ||
uses: cilium/little-vm-helper@908ab1ff8a596a03cd5221a1f8602dc44c3f906d # v0.0.12 | ||
with: | ||
provision: 'false' | ||
|
@@ -99,19 +90,19 @@ jobs: | |
uname -a | ||
cat /etc/issue | ||
timeout 20s /host/ptcpdump/ptcpdump -c 3 --pname curl -i any --print -w ptcpdump.pcapng 2>&1 1>/tmp/log | (read _; curl -m 10 1.1.1.1 &>/dev/null || true) | ||
bash /host/ptcpdump/testdata/test_pname_filter.sh /host/ptcpdump/ptcpdump | ||
cat /tmp/log | ||
cat /tmp/log | grep '/usr/bin/curl' | ||
cat /tmp/log | grep -F ' > 1.1.1.1.80: Flags [S],' | ||
cat /tmp/log | grep -P '1.1.1.1.80 > .*: Flags \[S.\],' | ||
- name: Test filter by process id | ||
uses: cilium/[email protected] | ||
with: | ||
provision: 'false' | ||
dns-resolver: '1.1.1.1' | ||
cmd: | | ||
set -ex | ||
uname -a | ||
cat /etc/issue | ||
apt update || true | ||
apt install -y tcpdump | ||
tcpdump -nr ./ptcpdump.pcapng | ||
tcpdump -nr ./ptcpdump.pcapng | grep -F ' > 1.1.1.1.80: Flags [S],' | ||
tcpdump -nr ./ptcpdump.pcapng | grep -P '1.1.1.1.80 > .*: Flags \[S.\],' | ||
bash /host/ptcpdump/testdata/test_pid_filter.sh /host/ptcpdump/ptcpdump | ||
releaser-test: | ||
runs-on: ubuntu-latest | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
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
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,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
CMD="$1" | ||
FNAME="/tmp/base.pcapng" | ||
LNAME="/tmp/base.log" | ||
|
||
|
||
function test_ptcpdump() { | ||
timeout 20s ${CMD} -c 1 -i any --print -w "${FNAME}" \ | ||
'dst host 1.1.1.1 and tcp[tcpflags] = tcp-syn' 2>&1 | tee "${LNAME}" | (read _; curl -m 10 1.1.1.1 &>/dev/null || true) | ||
|
||
cat "${LNAME}" | ||
cat "${LNAME}" | grep '/usr/bin/curl' | ||
cat "${LNAME}" | grep -F ' > 1.1.1.1.80: Flags [S],' # SYN | ||
} | ||
|
||
function test_tcpdump_read() { | ||
which tcpdump || (apt update || true && apt install -y tcpdump) | ||
tcpdump -nr "${FNAME}" | ||
tcpdump -nr "${FNAME}" | grep -F ' > 1.1.1.1.80: Flags [S],' # SYN | ||
} | ||
|
||
function main() { | ||
test_ptcpdump | ||
test_tcpdump_read | ||
} | ||
|
||
main |
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,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
CMD="$1" | ||
FNAME="/tmp/filter_by_pid.pcapng" | ||
LNAME="/tmp/filter_by_pid.log" | ||
|
||
|
||
function test_ptcpdump() { | ||
timeout 30s ${CMD} -c 3 --pid $$ -f -i any --print -w "${FNAME}" 2>&1 | tee "${LNAME}" & | ||
sleep 10 | ||
curl -m 10 1.1.1.1 &>/dev/null || true | ||
echo $$ | ||
wait | ||
|
||
cat "${LNAME}" | ||
cat "${LNAME}" | grep '/usr/bin/curl' | ||
cat "${LNAME}" | grep -F ' > 1.1.1.1.80: Flags [S],' # SYN | ||
cat "${LNAME}" | grep -P '1.1.1.1.80 > .*: Flags \[S.\],' # SYN-ACK | ||
cat "${LNAME}" | grep -F ' > 1.1.1.1.80: Flags [.],' # ACK | ||
} | ||
|
||
function test_tcpdump_read() { | ||
which tcpdump || (apt update || true && apt install -y tcpdump) | ||
tcpdump -nr "${FNAME}" | ||
tcpdump -nr "${FNAME}" | grep -F ' > 1.1.1.1.80: Flags [S],' # SYN | ||
tcpdump -nr "${FNAME}" | grep -P '1.1.1.1.80 > .*: Flags \[S.\],' # SYN-ACK | ||
tcpdump -nr "${FNAME}" | grep -F ' > 1.1.1.1.80: Flags [.],' # ACK | ||
} | ||
|
||
|
||
function main() { | ||
test_ptcpdump | ||
test_tcpdump_read | ||
} | ||
|
||
main |
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,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
CMD="$1" | ||
FNAME="/tmp/filter_by_pname.pcapng" | ||
LNAME="/tmp/filter_by_pname.log" | ||
|
||
|
||
function test_ptcpdump() { | ||
timeout 20s ${CMD} -c 3 --pname curl -f -i any \ | ||
--print -w "${FNAME}" 2>&1 | tee "${LNAME}" | (read _; curl -m 10 1.1.1.1 &>/dev/null || true) | ||
|
||
cat "${LNAME}" | ||
cat "${LNAME}" | grep '/usr/bin/curl' | ||
cat "${LNAME}" | grep -F ' > 1.1.1.1.80: Flags [S],' # SYN | ||
cat "${LNAME}" | grep -P '1.1.1.1.80 > .*: Flags \[S.\],' # SYN-ACK | ||
cat "${LNAME}" | grep -F ' > 1.1.1.1.80: Flags [.],' # ACK | ||
} | ||
|
||
function test_tcpdump_read() { | ||
which tcpdump || (apt update || true && apt install -y tcpdump) | ||
tcpdump -nr "${FNAME}" | ||
tcpdump -nr "${FNAME}" | grep -F ' > 1.1.1.1.80: Flags [S],' # SYN | ||
tcpdump -nr "${FNAME}" | grep -P '1.1.1.1.80 > .*: Flags \[S.\],' # SYN-ACK | ||
tcpdump -nr "${FNAME}" | grep -F ' > 1.1.1.1.80: Flags [.],' # ACK | ||
} | ||
|
||
function main() { | ||
test_ptcpdump | ||
test_tcpdump_read | ||
} | ||
|
||
main |