diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2024-02-16 13:51:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 13:51:49 +0000 |
commit | 23e9e990bad6e988801898514b8c0f295dedb885 (patch) | |
tree | 6de3f8a1d468b79102866416f71de4d95f0052b8 /src/collectors/ebpf.plugin/ebpf.c | |
parent | 9f08cd92e69afc3b5fcd8a9667b356908aef299e (diff) |
eBPF - Network Viewer (Move code) (#17018)
Diffstat (limited to 'src/collectors/ebpf.plugin/ebpf.c')
-rw-r--r-- | src/collectors/ebpf.plugin/ebpf.c | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf.c b/src/collectors/ebpf.plugin/ebpf.c index c46688895f..5c2036394e 100644 --- a/src/collectors/ebpf.plugin/ebpf.c +++ b/src/collectors/ebpf.plugin/ebpf.c @@ -3051,48 +3051,6 @@ static inline void ebpf_load_thread_config() } /** - * Check Conditions - * - * This function checks kernel that plugin is running and permissions. - * - * @return It returns 0 on success and -1 otherwise - */ -int ebpf_check_conditions() -{ - if (!has_condition_to_run(running_on_kernel)) { - netdata_log_error("The current collector cannot run on this kernel."); - return -1; - } - - if (!am_i_running_as_root()) { - netdata_log_error( - "ebpf.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities..", - (unsigned int)getuid(), (unsigned int)geteuid()); - return -1; - } - - return 0; -} - -/** - * Adjust memory - * - * Adjust memory values to load eBPF programs. - * - * @return It returns 0 on success and -1 otherwise - */ -int ebpf_adjust_memory_limit() -{ - struct rlimit r = { RLIM_INFINITY, RLIM_INFINITY }; - if (setrlimit(RLIMIT_MEMLOCK, &r)) { - netdata_log_error("Setrlimit(RLIMIT_MEMLOCK)"); - return -1; - } - - return 0; -} - -/** * Parse arguments given from user. * * @param argc the number of arguments @@ -3324,7 +3282,7 @@ static void ebpf_parse_args(int argc, char **argv) case EBPF_OPTION_UNITTEST: { // if we cannot run until the end, we will cancel the unittest int exit_code = ECANCELED; - if (ebpf_check_conditions()) + if (ebpf_can_plugin_load_code(running_on_kernel, NETDATA_EBPF_PLUGIN_NAME)) goto unittest; if (ebpf_adjust_memory_limit()) @@ -4009,7 +3967,7 @@ static void ebpf_manage_pid(pid_t pid) int main(int argc, char **argv) { clocks_init(); - nd_log_initialize_for_external_plugins("ebpf.plugin"); + nd_log_initialize_for_external_plugins(NETDATA_EBPF_PLUGIN_NAME); main_thread_id = gettid(); @@ -4017,7 +3975,7 @@ int main(int argc, char **argv) ebpf_parse_args(argc, argv); ebpf_manage_pid(getpid()); - if (ebpf_check_conditions()) + if (ebpf_can_plugin_load_code(running_on_kernel, NETDATA_EBPF_PLUGIN_NAME)) return 2; if (ebpf_adjust_memory_limit()) |