Fix oracle linux (eBPF plugin) (#13935)
thiagoftsm committed
Nov 3, 2022 at 19:45 UTC
42dd28526197175abe035e237e31deaa3fc3385c
3 files changed
+21
-8
collectors/ebpf.plugin/ebpf.c
+1
-1
@@ -1690,7 +1690,7 @@ static inline void ebpf_load_thread_config()
1690
{
1691
int i;
1692
for (i = 0; ebpf_modules[i].thread_name; i++) {
1693
- ebpf_update_module(&ebpf_modules[i], default_btf);
1693
+ ebpf_update_module(&ebpf_modules[i], default_btf, running_on_kernel, isrh);
1694
}
1695
}
1696
libnetdata/ebpf/ebpf.c
+17
-6
@@ -301,6 +301,8 @@ static int ebpf_select_max_index(int is_rhf, uint32_t kver)
301
if (is_rhf > 0) { // Is Red Hat family
302
if (kver >= NETDATA_EBPF_KERNEL_5_14)
303
return NETDATA_IDX_V5_14;
304
+ else if (kver >= NETDATA_EBPF_KERNEL_5_4 && kver < NETDATA_EBPF_KERNEL_5_5) // For Oracle Linux
305
+ return NETDATA_IDX_V5_4;
306
else if (kver >= NETDATA_EBPF_KERNEL_4_11)
307
return NETDATA_IDX_V4_18;
308
} else { // Kernels from kernel.org
@@ -1031,14 +1033,19 @@ static void ebpf_update_target_with_conf(ebpf_module_t *em, netdata_ebpf_program
1033
*
1034
* @param btf_file a pointer to the loaded btf file.
1035
* @parma load current value.
1036
+ * @param btf_file a pointer to the loaded btf file.
1037
+ * @param is_rhf is Red Hat family?
1038
*
1039
* @return it returns the new load mode.
1040
*/
1037
-static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file, netdata_ebpf_load_mode_t load)
1041
+static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file, netdata_ebpf_load_mode_t load,
1042
+ int kver, int is_rh)
1043
{
1044
#ifdef LIBBPF_MAJOR_VERSION
1045
if ((load & EBPF_LOAD_CORE) || (load & EBPF_LOAD_PLAY_DICE)) {
1041
- load = (!btf_file) ? EBPF_LOAD_LEGACY : EBPF_LOAD_CORE;
1046
+ // Quick fix for Oracle linux 8.x
1047
+ load = (!btf_file || (is_rh && (kver >= NETDATA_EBPF_KERNEL_5_4 && kver < NETDATA_EBPF_KERNEL_5_5))) ?
1048
+ EBPF_LOAD_LEGACY : EBPF_LOAD_CORE;
1049
}
1050
#else
1051
load = EBPF_LOAD_LEGACY;
@@ -1055,8 +1062,10 @@ static netdata_ebpf_load_mode_t ebpf_select_load_mode(struct btf *btf_file, netd
1062
* @param modules structure that will be updated
1063
* @oaram origin specify the configuration file loaded
1064
* @param btf_file a pointer to the loaded btf file.
1065
+ * @param is_rhf is Red Hat family?
1066
*/
1059
-void ebpf_update_module_using_config(ebpf_module_t *modules, netdata_ebpf_load_mode_t origin, struct btf *btf_file)
1067
+void ebpf_update_module_using_config(ebpf_module_t *modules, netdata_ebpf_load_mode_t origin, struct btf *btf_file,
1068
+ int kver, int is_rh)
1069
{
1070
char default_value[EBPF_MAX_MODE_LENGTH + 1];
1071
ebpf_select_mode_string(default_value, EBPF_MAX_MODE_LENGTH, modules->mode);
@@ -1078,7 +1087,7 @@ void ebpf_update_module_using_config(ebpf_module_t *modules, netdata_ebpf_load_m
1087
value = ebpf_convert_load_mode_to_string(modules->load & NETDATA_EBPF_LOAD_METHODS);
1088
value = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_TYPE_FORMAT, value);
1089
netdata_ebpf_load_mode_t load = epbf_convert_string_to_load_mode(value);
1081
- load = ebpf_select_load_mode(btf_file, load);
1090
+ load = ebpf_select_load_mode(btf_file, load, kver, is_rh);
1091
modules->load = origin | load;
1092
1093
value = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_CORE_ATTACH, EBPF_CFG_ATTACH_TRAMPOLINE);
@@ -1100,8 +1109,10 @@ void ebpf_update_module_using_config(ebpf_module_t *modules, netdata_ebpf_load_m
1109
*
1110
* @param em the module structure
1111
* @param btf_file a pointer to the loaded btf file.
1112
+ * @param is_rhf is Red Hat family?
1113
+ * @param kver the kernel version
1114
*/
1104
-void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file)
1115
+void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file, int kver, int is_rh)
1116
{
1117
char filename[FILENAME_MAX+1];
1118
netdata_ebpf_load_mode_t origin;
@@ -1119,7 +1130,7 @@ void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file)
1130
} else
1131
origin = EBPF_LOADED_FROM_USER;
1132
1122
- ebpf_update_module_using_config(em, origin, btf_file);
1133
+ ebpf_update_module_using_config(em, origin, btf_file, kver, is_rh);
1134
}
1135
1136
/**
libnetdata/ebpf/ebpf.h
+3
-1
@@ -81,6 +81,8 @@ enum netdata_ebpf_kernel_versions {
81
NETDATA_EBPF_KERNEL_4_15 = 265984, // 265984 = 4 * 65536 + 15 * 256
82
NETDATA_EBPF_KERNEL_4_17 = 266496, // 266496 = 4 * 65536 + 17 * 256
83
NETDATA_EBPF_KERNEL_5_0 = 327680, // 327680 = 5 * 65536 + 0 * 256
84
+ NETDATA_EBPF_KERNEL_5_4 = 328704, // 327680 = 5 * 65536 + 4 * 256
85
+ NETDATA_EBPF_KERNEL_5_5 = 328960, // 327680 = 5 * 65536 + 5 * 256
86
NETDATA_EBPF_KERNEL_5_10 = 330240, // 330240 = 5 * 65536 + 10 * 256
87
NETDATA_EBPF_KERNEL_5_11 = 330496, // 330240 = 5 * 65536 + 11 * 256
88
NETDATA_EBPF_KERNEL_5_14 = 331264, // 331264 = 5 * 65536 + 14 * 256
@@ -279,7 +281,7 @@ struct bpf_link **ebpf_load_program(char *plugins_dir, ebpf_module_t *em, int kv
281
282
void ebpf_mount_config_name(char *filename, size_t length, char *path, const char *config);
283
int ebpf_load_config(struct config *config, char *filename);
282
-void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file);
284
+void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file, int kver, int is_rh);
285
void ebpf_update_names(ebpf_specify_name_t *opt, ebpf_module_t *em);
286
void ebpf_adjust_apps_cgroup(ebpf_module_t *em, netdata_ebpf_program_loaded_t mode);
287
char *ebpf_find_symbol(char *search);