diff options
Diffstat (limited to 'libnetdata/ebpf/ebpf.c')
-rw-r--r-- | libnetdata/ebpf/ebpf.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/libnetdata/ebpf/ebpf.c b/libnetdata/ebpf/ebpf.c index 382485e5..7cad5978 100644 --- a/libnetdata/ebpf/ebpf.c +++ b/libnetdata/ebpf/ebpf.c @@ -809,7 +809,7 @@ static void ebpf_select_mode_string(char *output, size_t len, netdata_run_mode_t * * Convert the string given as argument to value present in enum. * - * @param str value read from configuraion file. + * @param str value read from configuration file. * * @return It returns the value to be used. */ @@ -901,7 +901,7 @@ netdata_ebpf_program_loaded_t ebpf_convert_core_type(char *str, netdata_run_mode /** * Adjust Thread Load * - * Adjust thread configuraton according specified load. + * Adjust thread configuration according specified load. * * @param mod the main structure that will be adjusted. * @param file the btf file used with thread. @@ -1060,7 +1060,7 @@ static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file, netd * Update configuration for a specific thread. * * @param modules structure that will be updated - * @oaram origin specify the configuration file loaded + * @param origin specify the configuration file loaded * @param btf_file a pointer to the loaded btf file. * @param is_rhf is Red Hat family? */ @@ -1124,7 +1124,7 @@ void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file, int kver, int i error("Cannot load the ebpf configuration file %s", em->config_file); return; } - // If user defined data globaly, we will have here EBPF_LOADED_FROM_USER, we need to consider this, to avoid + // If user defined data globally, we will have here EBPF_LOADED_FROM_USER, we need to consider this, to avoid // forcing users to configure thread by thread. origin = (!(em->load & NETDATA_EBPF_LOAD_SOURCE)) ? EBPF_LOADED_FROM_STOCK : em->load & NETDATA_EBPF_LOAD_SOURCE; } else @@ -1139,7 +1139,7 @@ void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file, int kver, int i * Apps and cgroup has internal cleanup that needs attaching tracers to release_task, to avoid overload the function * we will enable this integration by default, if and only if, we are running with trampolines. * - * @param em a poiter to the main thread structure. + * @param em a pointer to the main thread structure. * @param mode is the mode used with different */ void ebpf_adjust_apps_cgroup(ebpf_module_t *em, netdata_ebpf_program_loaded_t mode) @@ -1160,7 +1160,8 @@ void ebpf_adjust_apps_cgroup(ebpf_module_t *em, netdata_ebpf_program_loaded_t mo * Helper used to get address from /proc/kallsym * * @param fa address structure - * @param fd file descriptor loaded inside kernel. + * @param fd file descriptor loaded inside kernel. If a negative value is given + * the function will load address and it won't update hash table. */ void ebpf_load_addresses(ebpf_addresses_t *fa, int fd) { @@ -1182,11 +1183,15 @@ void ebpf_load_addresses(ebpf_addresses_t *fa, int fd) char *fcnt = procfile_lineword(ff, l, 2); uint32_t hash = simple_hash(fcnt); if (fa->hash == hash && !strcmp(fcnt, fa->function)) { - char addr[128]; - snprintf(addr, 127, "0x%s", procfile_lineword(ff, l, 0)); - fa->addr = (unsigned long) strtoul(addr, NULL, 16); - uint32_t key = 0; - bpf_map_update_elem(fd, &key, &fa->addr, BPF_ANY); + if (fd > 0) { + char addr[128]; + snprintf(addr, 127, "0x%s", procfile_lineword(ff, l, 0)); + fa->addr = (unsigned long) strtoul(addr, NULL, 16); + uint32_t key = 0; + bpf_map_update_elem(fd, &key, &fa->addr, BPF_ANY); + } else + fa->addr = 1; + break; } } |