summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/ebpf
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:33:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:34:10 +0000
commit83ba6762cc43d9db581b979bb5e3445669e46cc2 (patch)
tree2e69833b43f791ed253a7a20318b767ebe56cdb8 /src/libnetdata/ebpf
parentReleasing debian version 1.47.5-1. (diff)
downloadnetdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.tar.xz
netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.zip
Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libnetdata/ebpf')
-rw-r--r--src/libnetdata/ebpf/README.md9
-rw-r--r--src/libnetdata/ebpf/ebpf.c18
-rw-r--r--src/libnetdata/ebpf/ebpf.h15
3 files changed, 21 insertions, 21 deletions
diff --git a/src/libnetdata/ebpf/README.md b/src/libnetdata/ebpf/README.md
index 8d9edb076..17fc13046 100644
--- a/src/libnetdata/ebpf/README.md
+++ b/src/libnetdata/ebpf/README.md
@@ -1,12 +1,3 @@
-<!--
-title: "eBPF"
-custom_edit_url: https://github.com/netdata/netdata/edit/master/src/libnetdata/ebpf/README.md
-sidebar_label: "eBPF"
-learn_status: "Published"
-learn_topic_type: "Tasks"
-learn_rel_path: "Developers/libnetdata"
--->
-
# eBPF library
Netdata's eBPF library supports the [eBPF collector](/src/collectors/ebpf.plugin/README.md).
diff --git a/src/libnetdata/ebpf/ebpf.c b/src/libnetdata/ebpf/ebpf.c
index 4e7c85943..27042a794 100644
--- a/src/libnetdata/ebpf/ebpf.c
+++ b/src/libnetdata/ebpf/ebpf.c
@@ -1014,7 +1014,7 @@ int ebpf_load_config(struct config *config, char *filename)
}
-static netdata_run_mode_t ebpf_select_mode(char *mode)
+static netdata_run_mode_t ebpf_select_mode(const char *mode)
{
if (!strcasecmp(mode,EBPF_CFG_LOAD_MODE_RETURN ))
return MODE_RETURN;
@@ -1041,7 +1041,7 @@ static void ebpf_select_mode_string(char *output, size_t len, netdata_run_mode_t
*
* @return It returns the value to be used.
*/
-netdata_ebpf_load_mode_t epbf_convert_string_to_load_mode(char *str)
+netdata_ebpf_load_mode_t epbf_convert_string_to_load_mode(const char *str)
{
if (!strcasecmp(str, EBPF_CFG_CORE_PROGRAM))
return EBPF_LOAD_CORE;
@@ -1094,7 +1094,7 @@ static char *ebpf_convert_collect_pid_to_string(netdata_apps_level_t level)
*
* @return it returns the level associated to the string or default when it is a wrong value
*/
-netdata_apps_level_t ebpf_convert_string_to_apps_level(char *str)
+netdata_apps_level_t ebpf_convert_string_to_apps_level(const char *str)
{
if (!strcasecmp(str, EBPF_CFG_PID_REAL_PARENT))
return NETDATA_APPS_LEVEL_REAL_PARENT;
@@ -1114,7 +1114,7 @@ netdata_apps_level_t ebpf_convert_string_to_apps_level(char *str)
* @param str value read from configuration file.
* @param lmode load mode used by collector.
*/
-netdata_ebpf_program_loaded_t ebpf_convert_core_type(char *str, netdata_run_mode_t lmode)
+netdata_ebpf_program_loaded_t ebpf_convert_core_type(const char *str, netdata_run_mode_t lmode)
{
if (!strcasecmp(str, EBPF_CFG_ATTACH_TRACEPOINT))
return EBPF_LOAD_TRACEPOINT;
@@ -1174,7 +1174,7 @@ struct btf *ebpf_parse_btf_file(const char *filename)
* @param path is the fullpath
* @param filename is the file inside BTF path.
*/
-struct btf *ebpf_load_btf_file(char *path, char *filename)
+struct btf *ebpf_load_btf_file(const char *path, const char *filename)
{
char fullpath[PATH_MAX + 1];
snprintfz(fullpath, PATH_MAX, "%s/%s", path, filename);
@@ -1299,7 +1299,7 @@ void ebpf_update_module_using_config(ebpf_module_t *modules, netdata_ebpf_load_m
{
char default_value[EBPF_MAX_MODE_LENGTH + 1];
ebpf_select_mode_string(default_value, EBPF_MAX_MODE_LENGTH, modules->mode);
- char *load_mode = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, default_value);
+ const char *load_mode = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, default_value);
modules->mode = ebpf_select_mode(load_mode);
modules->update_every = (int)appconfig_get_number(modules->cfg, EBPF_GLOBAL_SECTION,
@@ -1318,17 +1318,17 @@ void ebpf_update_module_using_config(ebpf_module_t *modules, netdata_ebpf_load_m
EBPF_CFG_LIFETIME, EBPF_DEFAULT_LIFETIME);
char *value = ebpf_convert_load_mode_to_string(modules->load & NETDATA_EBPF_LOAD_METHODS);
- char *type_format = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_TYPE_FORMAT, value);
+ const char *type_format = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_TYPE_FORMAT, value);
netdata_ebpf_load_mode_t load = epbf_convert_string_to_load_mode(type_format);
load = ebpf_select_load_mode(btf_file, load, kver, is_rh);
modules->load = origin | load;
- char *core_attach = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_CORE_ATTACH, EBPF_CFG_ATTACH_TRAMPOLINE);
+ const char *core_attach = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_CORE_ATTACH, EBPF_CFG_ATTACH_TRAMPOLINE);
netdata_ebpf_program_loaded_t fill_lm = ebpf_convert_core_type(core_attach, modules->mode);
ebpf_update_target_with_conf(modules, fill_lm);
value = ebpf_convert_collect_pid_to_string(modules->apps_level);
- char *collect_pid = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_COLLECT_PID, value);
+ const char *collect_pid = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_COLLECT_PID, value);
modules->apps_level = ebpf_convert_string_to_apps_level(collect_pid);
modules->maps_per_core = appconfig_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_MAPS_PER_CORE,
diff --git a/src/libnetdata/ebpf/ebpf.h b/src/libnetdata/ebpf/ebpf.h
index 1c612ad32..d65dc2205 100644
--- a/src/libnetdata/ebpf/ebpf.h
+++ b/src/libnetdata/ebpf/ebpf.h
@@ -470,13 +470,13 @@ int ebpf_disable_tracing_values(char *subsys, char *eventname);
// BTF helpers
#define NETDATA_EBPF_MAX_SYSCALL_LENGTH 255
-netdata_ebpf_load_mode_t epbf_convert_string_to_load_mode(char *str);
-netdata_ebpf_program_loaded_t ebpf_convert_core_type(char *str, netdata_run_mode_t lmode);
+netdata_ebpf_load_mode_t epbf_convert_string_to_load_mode(const char *str);
+netdata_ebpf_program_loaded_t ebpf_convert_core_type(const char *str, netdata_run_mode_t lmode);
void ebpf_select_host_prefix(char *output, size_t length, char *syscall, int kver);
#ifdef LIBBPF_MAJOR_VERSION
void ebpf_adjust_thread_load(ebpf_module_t *mod, struct btf *file);
struct btf *ebpf_parse_btf_file(const char *filename);
-struct btf *ebpf_load_btf_file(char *path, char *filename);
+struct btf *ebpf_load_btf_file(const char *path, const char *filename);
int ebpf_is_function_inside_btf(struct btf *file, char *function);
void ebpf_update_map_type(struct bpf_map *map, ebpf_local_maps_t *w);
void ebpf_define_map_type(ebpf_local_maps_t *maps, int maps_per_core, int kver);
@@ -492,4 +492,13 @@ void ebpf_send_data_aral_chart(ARAL *memory, ebpf_module_t *em);
int ebpf_can_plugin_load_code(int kver, char *plugin_name);
int ebpf_adjust_memory_limit();
+#ifdef LIBBPF_MAJOR_VERSION
+static inline int netdata_silent_libbpf_vfprintf(enum libbpf_print_level level __maybe_unused,
+ const char *format __maybe_unused,
+ va_list args __maybe_unused)
+{
+ return 0;
+}
+#endif
+
#endif /* NETDATA_EBPF_H */