Skip to content

Commit 3d22502

Browse files
ioworker0chenhengqi
authored andcommitted
tcpdrop: fix unexpected exit if tcp_drop() missing
This commit fixes an issue where tcpdrop would unexpectedly exit when the tcp_drop() function is not found, even if the 'skb:kfree_skb' tracepoint is traceable. Now, tcpdrop will continue running with a warning message in that case. Fixes: b93c0a9 ("tcp_drop() not findable is an error.") Signed-off-by: Mingzhe Yang <[email protected]> Signed-off-by: Lance Yang <[email protected]>
1 parent 84551e7 commit 3d22502

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tools/tcpdrop.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,23 @@ def print_ipv6_event(cpu, data, size):
238238
print("\t%s" % sym)
239239
print("")
240240

241+
kfree_skb_traceable = False
242+
241243
if BPF.tracepoint_exists("skb", "kfree_skb"):
242244
if BPF.kernel_struct_has_field("trace_event_raw_kfree_skb", "reason") == 1:
243245
bpf_text += bpf_kfree_skb_text
246+
kfree_skb_traceable = True
244247

245248
# initialize BPF
246249
b = BPF(text=bpf_text)
247250

248251
if b.get_kprobe_functions(b"tcp_drop"):
249252
b.attach_kprobe(event="tcp_drop", fn_name="trace_tcp_drop")
250-
elif b.tracepoint_exists("skb", "kfree_skb"):
251-
print("ERROR: tcp_drop() kernel function not found or traceable. "
252-
"(It may have been inlined.) "
253+
elif b.tracepoint_exists("skb", "kfree_skb") and kfree_skb_traceable:
254+
print("WARNING: tcp_drop() kernel function not found or traceable. "
253255
"Use tracepoint:skb:kfree_skb instead.")
254-
exit()
255256
else:
256-
print("ERROR: tcp_drop() kernel function and tracpoint:skb:kfree_skb"
257+
print("ERROR: tcp_drop() kernel function and tracepoint:skb:kfree_skb"
257258
" not found or traceable. "
258259
"The kernel might be too old or the the function has been inlined.")
259260
exit()

0 commit comments

Comments
 (0)