-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
daemon: add running uprobe program support (#52)
* runtime: add comments * move to user * daemon: improve config * add driver defines * add minimal * fix bpftime tool open * remove use of global open type * serialize and run the bpftim tool * fix tracer error * implement driver * add daemon test * fxi unit test * fix uprobe path config * daemon: impl trace and insert * daemon: add info * fix seg fault * fix handle event * fix export module name * fix ci --------- Co-authored-by: Littlefisher619 <i@littlefisher.me>
- Loading branch information
1 parent
451397a
commit e5b1081
Showing
53 changed files
with
1,518 additions
and
315 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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ package.yaml | |
ecli | ||
bootstrap | ||
.output | ||
bpf-mocker | ||
bpf_tracer | ||
victim | ||
victim2 | ||
test.txt | ||
|
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,14 +1,46 @@ | ||
# Create a target that builds the ebpf program | ||
add_ebpf_program_target(bpftime_daemon_ebpf_target ${CMAKE_CURRENT_SOURCE_DIR}/bpf-mocker.bpf.c ${CMAKE_CURRENT_BINARY_DIR}/bpf-mocker.bpf.o) | ||
add_ebpf_program_target(bpftime_daemon_ebpf_target ${CMAKE_CURRENT_SOURCE_DIR}/kernel/bpf_tracer.bpf.c ${CMAKE_CURRENT_BINARY_DIR}/bpf_tracer.bpf.o) | ||
|
||
# Create a target that generated the bpf skeleton | ||
add_bpf_skel_generating_target(bpftime_daemon_ebpf_skel ${CMAKE_CURRENT_BINARY_DIR}/bpf-mocker.bpf.o ${CMAKE_CURRENT_BINARY_DIR}/bpf-mocker.skel.h) | ||
add_bpf_skel_generating_target(bpftime_daemon_ebpf_skel ${CMAKE_CURRENT_BINARY_DIR}/bpf_tracer.bpf.o ${CMAKE_CURRENT_BINARY_DIR}/bpf_tracer.skel.h) | ||
|
||
add_dependencies(bpftime_daemon_ebpf_skel bpftime_daemon_ebpf_target) | ||
|
||
add_executable(bpftime_daemon main.cpp bpf-mocker.cpp handle_bpf_event.cpp) | ||
add_dependencies(bpftime_daemon bpftime_daemon_ebpf_skel libbpf spdlog::spdlog) | ||
add_library(libbpftime_daemon STATIC | ||
user/bpf_tracer.cpp | ||
user/handle_bpf_event.cpp | ||
user/bpftime_driver.cpp | ||
) | ||
|
||
target_include_directories(bpftime_daemon PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${LIBBPF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) | ||
target_link_libraries(bpftime_daemon PRIVATE ${LIBBPF_LIBRARIES} elf z spdlog::spdlog) | ||
set_property(TARGET bpftime_daemon PROPERTY CXX_STANDARD 20) | ||
add_executable(bpftime_daemon | ||
user/main.cpp | ||
) | ||
|
||
add_dependencies(libbpftime_daemon | ||
bpftime_daemon_ebpf_skel | ||
libbpf | ||
spdlog::spdlog | ||
runtime | ||
) | ||
|
||
target_include_directories(libbpftime_daemon PRIVATE | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${LIBBPF_INCLUDE_DIRS}/uapi | ||
${LIBBPF_INCLUDE_DIRS} | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/../vm/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../runtime/include | ||
) | ||
target_link_libraries(libbpftime_daemon PRIVATE | ||
${LIBBPF_LIBRARIES} | ||
elf | ||
z | ||
spdlog::spdlog | ||
runtime | ||
) | ||
set_property(TARGET libbpftime_daemon PROPERTY CXX_STANDARD 20) | ||
|
||
add_dependencies(bpftime_daemon libbpftime_daemon) | ||
target_link_libraries(bpftime_daemon PRIVATE libbpftime_daemon) | ||
|
||
add_subdirectory(test) |
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,4 @@ | ||
# bpf-mocker | ||
# bpftime daemon: trace and replay eBPF related events | ||
|
||
The bpftime daemon is a tool to trace and replay eBPF related events. | ||
It's similar to our syscall server but run together with kernel eBPF. |
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 was deleted.
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,36 @@ | ||
#ifndef BPFTIME_KERNEL_CONFIG_H | ||
#define BPFTIME_KERNEL_CONFIG_H | ||
|
||
#include <vmlinux.h> | ||
|
||
#define PATH_LENTH 255 | ||
|
||
// filter bpf program pid | ||
const volatile int target_pid = 0; | ||
// current bpf program pid, avoid breaking current process | ||
const volatile int current_pid = 0; | ||
// enable modify bpf program | ||
const volatile bool enable_replace_prog = 0; | ||
// enable modify uprobe | ||
const volatile bool enable_replace_uprobe = 0; | ||
const char new_uprobe_path[PATH_LENTH] = "\0"; | ||
|
||
const volatile int uprobe_perf_type = 0; | ||
const volatile int kprobe_perf_type = 0; | ||
|
||
|
||
static __always_inline bool filter_target(void) | ||
{ | ||
u64 pid = bpf_get_current_pid_tgid() >> 32; | ||
if (target_pid && pid != target_pid) { | ||
// filter target pid | ||
return false; | ||
} | ||
if (current_pid && pid == current_pid) { | ||
// avoid breaking current process | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
#endif // BPFTIME_KERNEL_CONFIG_H |
Oops, something went wrong.