mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-03 15:19:07 +08:00
libbpf: Replace '.' with '_' in legacy kprobe event name
'.' is not allowed in the event name of kprobe. Therefore, we will get a EINVAL if the kernel function name has a '.' in legacy kprobe attach case, such as 'icmp_reply.constprop.0'. In order to adapt this case, we need to replace the '.' with other char in gen_kprobe_legacy_event_name(). And I use '_' for this propose. Signed-off-by: Menglong Dong <imagedong@tencent.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Alan Maguire <alan.maguire@oracle.com> Link: https://lore.kernel.org/bpf/20230113093427.1666466-1-imagedong@tencent.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
ce8d078ac7
commit
49e950dcfa
@@ -9994,9 +9994,16 @@ static void gen_kprobe_legacy_event_name(char *buf, size_t buf_sz,
|
|||||||
const char *kfunc_name, size_t offset)
|
const char *kfunc_name, size_t offset)
|
||||||
{
|
{
|
||||||
static int index = 0;
|
static int index = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
snprintf(buf, buf_sz, "libbpf_%u_%s_0x%zx_%d", getpid(), kfunc_name, offset,
|
snprintf(buf, buf_sz, "libbpf_%u_%s_0x%zx_%d", getpid(), kfunc_name, offset,
|
||||||
__sync_fetch_and_add(&index, 1));
|
__sync_fetch_and_add(&index, 1));
|
||||||
|
|
||||||
|
/* sanitize binary_path in the probe name */
|
||||||
|
for (i = 0; buf[i]; i++) {
|
||||||
|
if (!isalnum(buf[i]))
|
||||||
|
buf[i] = '_';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_kprobe_event_legacy(const char *probe_name, bool retprobe,
|
static int add_kprobe_event_legacy(const char *probe_name, bool retprobe,
|
||||||
|
|||||||
Reference in New Issue
Block a user