diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2021-08-19 21:06:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-19 21:06:35 +0000 |
commit | 19d9a7075a3c67828daa602c60bb50efc3fdcadb (patch) | |
tree | 9637c5fa41f50e527da3c2084beac89a9ac3a326 /libnetdata/ebpf | |
parent | 1e415e4a04efa1e8317403d4d9aa7125b31a3e39 (diff) |
Update ebpf socket (#11441)
Diffstat (limited to 'libnetdata/ebpf')
-rw-r--r-- | libnetdata/ebpf/ebpf.c | 25 | ||||
-rw-r--r-- | libnetdata/ebpf/ebpf.h | 1 |
2 files changed, 16 insertions, 10 deletions
diff --git a/libnetdata/ebpf/ebpf.c b/libnetdata/ebpf/ebpf.c index 7a873b3f4d..2f54081a4c 100644 --- a/libnetdata/ebpf/ebpf.c +++ b/libnetdata/ebpf/ebpf.c @@ -533,7 +533,7 @@ int ebpf_load_config(struct config *config, char *filename) static netdata_run_mode_t ebpf_select_mode(char *mode) { - if (!strcasecmp(mode, "return")) + if (!strcasecmp(mode,EBPF_CFG_LOAD_MODE_RETURN )) return MODE_RETURN; else if (!strcasecmp(mode, "dev")) return MODE_DEVMODE; @@ -541,16 +541,23 @@ static netdata_run_mode_t ebpf_select_mode(char *mode) return MODE_ENTRY; } +static void ebpf_select_mode_string(char *output, size_t len, netdata_run_mode_t sel) +{ + if (sel == MODE_RETURN) + strncpyz(output, EBPF_CFG_LOAD_MODE_RETURN, len); + else + strncpyz(output, EBPF_CFG_LOAD_MODE_DEFAULT, len); +} + /** * @param modules structure that will be updated - * @param user_cfg is this an user configuration? */ -void ebpf_update_module_using_config(ebpf_module_t *modules, int user_cfg) +void ebpf_update_module_using_config(ebpf_module_t *modules) { - if (user_cfg) { - char *mode = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, EBPF_CFG_LOAD_MODE_DEFAULT); - modules->mode = ebpf_select_mode(mode); - } + char default_value[EBPF_MAX_MODE_LENGTH + 1]; + ebpf_select_mode_string(default_value, EBPF_MAX_MODE_LENGTH, modules->mode); + char *mode = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, default_value); + modules->mode = ebpf_select_mode(mode); modules->update_time = (int)appconfig_get_number(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_UPDATE_EVERY, modules->update_time); @@ -577,17 +584,15 @@ void ebpf_update_module(ebpf_module_t *em) { char filename[FILENAME_MAX+1]; ebpf_mount_config_name(filename, FILENAME_MAX, ebpf_user_config_dir, em->config_file); - int from_user = 1; if (!ebpf_load_config(em->cfg, filename)) { ebpf_mount_config_name(filename, FILENAME_MAX, ebpf_stock_config_dir, em->config_file); - from_user = 0; 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, from_user); + ebpf_update_module_using_config(em); } //---------------------------------------------------------------------------------------------------------------------- diff --git a/libnetdata/ebpf/ebpf.h b/libnetdata/ebpf/ebpf.h index d72465bf61..d0dbf32c33 100644 --- a/libnetdata/ebpf/ebpf.h +++ b/libnetdata/ebpf/ebpf.h @@ -15,6 +15,7 @@ #define EBPF_CFG_LOAD_MODE "ebpf load mode" #define EBPF_CFG_LOAD_MODE_DEFAULT "entry" #define EBPF_CFG_LOAD_MODE_RETURN "return" +#define EBPF_MAX_MODE_LENGTH 6 #define EBPF_CFG_UPDATE_EVERY "update every" #define EBPF_CFG_PID_SIZE "pid table size" |