diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2021-05-25 11:54:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-25 11:54:04 +0000 |
commit | 1b47b0411da56f6d143a1ab572541c56743b1475 (patch) | |
tree | aeae8236a1ad9a57d3bb12063434a2e0b84a82c3 /libnetdata | |
parent | a1eecbe15f66c68a75eaed0670a26190199fa432 (diff) |
Move parser from children to main thread (#11152)
Centralize eBPF plugin parser to avoid possible contradictions between user configuration and visualized charts.
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/ebpf/ebpf.c | 28 | ||||
-rw-r--r-- | libnetdata/ebpf/ebpf.h | 15 |
2 files changed, 25 insertions, 18 deletions
diff --git a/libnetdata/ebpf/ebpf.c b/libnetdata/ebpf/ebpf.c index 1f71f6a248..8618a9b2f3 100644 --- a/libnetdata/ebpf/ebpf.c +++ b/libnetdata/ebpf/ebpf.c @@ -462,7 +462,7 @@ void ebpf_update_names(ebpf_specify_name_t *opt, ebpf_module_t *em) //---------------------------------------------------------------------------------------------------------------------- -void ebpf_mount_config_name(char *filename, size_t length, char *path, char *config) +void ebpf_mount_config_name(char *filename, size_t length, char *path, const char *config) { snprintf(filename, length, "%s/ebpf.d/%s", path, config); } @@ -483,17 +483,17 @@ static netdata_run_mode_t ebpf_select_mode(char *mode) return MODE_ENTRY; } -void ebpf_update_module_using_config(ebpf_module_t *modules, struct config *cfg) +void ebpf_update_module_using_config(ebpf_module_t *modules) { - char *mode = appconfig_get(cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, EBPF_CFG_LOAD_MODE_DEFAULT); + char *mode = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, EBPF_CFG_LOAD_MODE_DEFAULT); modules->mode = ebpf_select_mode(mode); - modules->update_time = (int)appconfig_get_number(cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_UPDATE_EVERY, 1); + modules->update_time = (int)appconfig_get_number(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_UPDATE_EVERY, 1); - modules->apps_charts = appconfig_get_boolean(cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_APPLICATION, + modules->apps_charts = appconfig_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_APPLICATION, CONFIG_BOOLEAN_YES); - modules->pid_map_size = (uint32_t)appconfig_get_number(cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_PID_SIZE, + modules->pid_map_size = (uint32_t)appconfig_get_number(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_PID_SIZE, modules->pid_map_size); } @@ -507,20 +507,18 @@ void ebpf_update_module_using_config(ebpf_module_t *modules, struct config *cfg) * update the variables. * * @param em the module structure - * @param cfg the configuration structure - * @param cfg_file the filename to load */ -void ebpf_update_module(ebpf_module_t *em, struct config *cfg, char *cfg_file) +void ebpf_update_module(ebpf_module_t *em) { char filename[FILENAME_MAX+1]; - ebpf_mount_config_name(filename, FILENAME_MAX, ebpf_user_config_dir, cfg_file); - if (!ebpf_load_config(cfg, filename)) { - ebpf_mount_config_name(filename, FILENAME_MAX, ebpf_stock_config_dir, cfg_file); - if (!ebpf_load_config(cfg, filename)) { - error("Cannot load the ebpf configuration file %s", cfg_file); + ebpf_mount_config_name(filename, FILENAME_MAX, ebpf_user_config_dir, em->config_file); + if (!ebpf_load_config(em->cfg, filename)) { + ebpf_mount_config_name(filename, FILENAME_MAX, ebpf_stock_config_dir, em->config_file); + if (!ebpf_load_config(em->cfg, filename)) { + error("Cannot load the ebpf configuration file %s", em->config_file); return; } } - ebpf_update_module_using_config(em, cfg); + ebpf_update_module_using_config(em); } diff --git a/libnetdata/ebpf/ebpf.h b/libnetdata/ebpf/ebpf.h index bc55d95951..814cb94f72 100644 --- a/libnetdata/ebpf/ebpf.h +++ b/libnetdata/ebpf/ebpf.h @@ -57,6 +57,13 @@ #define NETDATA_EBPF_KERNEL_5_10 330240 /** + * Kernel 5.0 + * + * 327680 = 5*65536 +256*0 + */ +#define NETDATA_EBPF_KERNEL_5_0 327680 + +/** * Kernel 4.17 * * 266496 = 4*65536 + 17*256 @@ -127,6 +134,8 @@ typedef struct ebpf_module { ebpf_local_maps_t *maps; ebpf_specify_name_t *names; uint32_t pid_map_size; + struct config *cfg; + const char *config_file; } ebpf_module_t; extern int get_kernel_version(char *out, int size); @@ -140,10 +149,10 @@ extern struct bpf_link **ebpf_load_program(char *plugins_dir, struct bpf_object **obj, int *map_fd); -extern void ebpf_mount_config_name(char *filename, size_t length, char *path, char *config); +extern void ebpf_mount_config_name(char *filename, size_t length, char *path, const char *config); extern int ebpf_load_config(struct config *config, char *filename); -extern void ebpf_update_module_using_config(ebpf_module_t *modules, struct config *cfg); -extern void ebpf_update_module(ebpf_module_t *em, struct config *cfg, char *cfg_file); +extern void ebpf_update_module_using_config(ebpf_module_t *modules); +extern void ebpf_update_module(ebpf_module_t *em); extern void ebpf_update_names(ebpf_specify_name_t *opt, ebpf_module_t *em); #endif /* NETDATA_EBPF_H */ |