summaryrefslogtreecommitdiffstats
path: root/libnetdata/ebpf
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
commitd079b656b4719739b2247dcd9d46e9bec793095a (patch)
treed2c950c70a776bcf697c963151c5bd959f8a9f03 /libnetdata/ebpf
parentReleasing debian version 1.37.1-2. (diff)
downloadnetdata-d079b656b4719739b2247dcd9d46e9bec793095a.tar.xz
netdata-d079b656b4719739b2247dcd9d46e9bec793095a.zip
Merging upstream version 1.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/ebpf')
-rw-r--r--libnetdata/ebpf/README.md8
-rw-r--r--libnetdata/ebpf/ebpf.c27
-rw-r--r--libnetdata/ebpf/ebpf.h2
3 files changed, 25 insertions, 12 deletions
diff --git a/libnetdata/ebpf/README.md b/libnetdata/ebpf/README.md
index 534867f31..c2dabe102 100644
--- a/libnetdata/ebpf/README.md
+++ b/libnetdata/ebpf/README.md
@@ -1,5 +1,13 @@
<!--
+title "eBPF"
custom_edit_url: https://github.com/netdata/netdata/edit/master/libnetdata/ebpf/README.md
+sidebar_label: "eBPF"
+learn_status: "Published"
+learn_topic_type: "Tasks"
+learn_rel_path: "Developers/libnetdata libraries"
-->
+# eBPF library
+
+Netdata's eBPF library supports the [eBPF collector](https://github.com/netdata/netdata/blob/master/collectors/ebpf.plugin/README.md).
diff --git a/libnetdata/ebpf/ebpf.c b/libnetdata/ebpf/ebpf.c
index 382485e5f..7cad59785 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;
}
}
diff --git a/libnetdata/ebpf/ebpf.h b/libnetdata/ebpf/ebpf.h
index 5cff5134f..cf3fa7ccd 100644
--- a/libnetdata/ebpf/ebpf.h
+++ b/libnetdata/ebpf/ebpf.h
@@ -206,7 +206,7 @@ typedef struct ebpf_specify_name {
typedef enum netdata_ebpf_load_mode {
EBPF_LOAD_LEGACY = 1<<0, // Select legacy mode, this means we will load binaries
- EBPF_LOAD_CORE = 1<<1, // When CO-RE is used, it is necessary to use the souce code
+ EBPF_LOAD_CORE = 1<<1, // When CO-RE is used, it is necessary to use the source code
EBPF_LOAD_PLAY_DICE = 1<<2, // Take a look on environment and choose the best option
EBPF_LOADED_FROM_STOCK = 1<<3, // Configuration loaded from Stock file
EBPF_LOADED_FROM_USER = 1<<4 // Configuration loaded from user