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

Merge pull request iovisor#3691 from chenhengqi/add-mdflush #3

Merged
merged 30 commits into from
Jun 24, 2022
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4f59913
libbpf-tools: Add mdflush
chenhengqi Nov 8, 2021
63103fa
bcc: add method to close file descriptors
terceiro Mar 22, 2022
9d06ced
tools/tcplife: Remove dead code
chenhengqi Jun 2, 2022
02f0f5a
Merge pull request #4032 from chenhengqi/cleanup-tcplife
davemarchevsky Jun 2, 2022
42a84ed
Fixed 'getElementType() is deprecated' compile warning.
Rtoax May 29, 2022
65efffe
tools/exitsnoop: Use task->real_parent instead of task->parent (#4025)
xingfeng2510 Jun 3, 2022
ae680db
tools/biolatency: Add disk filter support (#4026)
xingfeng2510 Jun 3, 2022
aad64e4
docs: Add missing entries for CGROUP_SOCK_ADDR family
chenhengqi Jun 2, 2022
9541c9c
sync with laest libbpf repo
yonghong-song Jun 3, 2022
730ced2
libbpf-tools: add support for cross compilation
May 13, 2022
67b8cfb
libbpf-tools/klockstat: Flush stdout after print_stats()
namhyung May 11, 2022
bfccfe6
libbpf-tools/klockstat: Print human friendly time stats
namhyung May 11, 2022
5e3d41e
libbpf-tools/klockstat: Add --per-thread/-P option
namhyung May 11, 2022
a184f09
libbpf-tools: Fix bio tools
chenhengqi Jun 10, 2022
70e8a9b
Merge pull request #3919 from terceiro/python-bpf-close
davemarchevsky Jun 13, 2022
45f5df4
libbpf-tools: Remove map flag BPF_F_NO_PREALLOC
chenhengqi Jun 10, 2022
8e608ed
Remove executable permissions and extra spaces for "funcinterval.8".
Rtoax Jun 14, 2022
e345542
Merge pull request #4049 from Rtoax/patch-17-funcinterval.8-x
davemarchevsky Jun 14, 2022
16eab39
Add tracepoint:skb:kfree_skb if no tcp_drop() kprobe.
Rtoax Jun 15, 2022
1c0808d
Fix: Failed to load BPF program b'trace_read_return': Permission denied
Rtoax Jun 15, 2022
37c3f97
libbpf-tools: fix tcpconnect build errors
aspsk Jun 15, 2022
e16b628
Add more hints for error kprobe.
Rtoax Jun 17, 2022
dbb7b83
Merge pull request #4055 from Rtoax/patch-21-warn-inlined
davemarchevsky Jun 17, 2022
e84e46f
sync with latest libbpf repo
chantra Jun 20, 2022
1900809
backport `struct bpf_create_map_attr`
chantra Jun 20, 2022
10e3cd4
tools/syscount: Beautify output of syscall list
xingfeng2510 Jun 21, 2022
13b5563
Merge pull request #4062 from chantra/remove_bpf_create_map
davemarchevsky Jun 21, 2022
a409bf5
Merge pull request #4050 from Rtoax/patch-18-tcpdrop-reason
davemarchevsky Jun 24, 2022
21e18d1
Merge pull request #4063 from xingfeng2510/enhance
davemarchevsky Jun 24, 2022
9627312
Merge pull request #3691 from chenhengqi/add-mdflush
davemarchevsky Jun 24, 2022
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
Prev Previous commit
Next Next commit
Add tracepoint:skb:kfree_skb if no tcp_drop() kprobe.
  • Loading branch information
Rtoax committed Jun 16, 2022
commit 16eab39171eb5174423f2e7f02b921f470b7ae16
39 changes: 36 additions & 3 deletions tools/tcpdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
#
# 30-May-2018 Brendan Gregg Created this.
# 15-Jun-2022 Rong Tao Add tracepoint:skb:kfree_skb

from __future__ import print_function
from bcc import BPF
Expand Down Expand Up @@ -100,7 +101,7 @@
#define tcp_flag_byte(th) (((u_int8_t *)th)[13])
#endif

int trace_tcp_drop(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb)
static int __trace_tcp_drop(void *ctx, struct sock *sk, struct sk_buff *skb)
{
if (sk == NULL)
return 0;
Expand Down Expand Up @@ -154,6 +155,29 @@

return 0;
}

int trace_tcp_drop(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb)
{
return __trace_tcp_drop(ctx, sk, skb);
}
"""

bpf_kfree_skb_text = """
#include <linux/skbuff.h>

TRACEPOINT_PROBE(skb, kfree_skb) {
struct sk_buff *skb = args->skbaddr;
struct sock *sk = skb->sk;
enum skb_drop_reason reason = args->reason;

// SKB_NOT_DROPPED_YET,
// SKB_DROP_REASON_NOT_SPECIFIED,
if (reason > SKB_DROP_REASON_NOT_SPECIFIED) {
return __trace_tcp_drop(args, sk, skb);
}

return 0;
}
"""

if debug or args.ebpf:
Expand Down Expand Up @@ -194,13 +218,22 @@ def print_ipv6_event(cpu, data, size):
print("\t%s" % sym)
print("")

if BPF.tracepoint_exists("skb", "kfree_skb"):
if BPF.kernel_struct_has_field("trace_event_raw_kfree_skb", "reason") == 1:
bpf_text += bpf_kfree_skb_text

# initialize BPF
b = BPF(text=bpf_text)

if b.get_kprobe_functions(b"tcp_drop"):
b.attach_kprobe(event="tcp_drop", fn_name="trace_tcp_drop")
elif b.tracepoint_exists("skb", "kfree_skb"):
print("WARNING: tcp_drop() kernel function not found or traceable. "
"Use tracpoint:skb:kfree_skb instead.")
else:
print("ERROR: tcp_drop() kernel function not found or traceable. "
"The kernel might be too old or the the function has been inlined.")
print("ERROR: tcp_drop() kernel function and tracpoint:skb:kfree_skb"
" not found or traceable. "
"The kernel might be too old or the the function has been inlined.")
exit()
stack_traces = b.get_table("stack_traces")

Expand Down