public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libbpf: replace '.' with '_' in legacy kprobe event name
@ 2023-01-13  9:34 menglong8.dong
  2023-01-13 14:12 ` Alan Maguire
  2023-01-13 22:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 7+ messages in thread
From: menglong8.dong @ 2023-01-13  9:34 UTC (permalink / raw)
  To: andrii
  Cc: ast, daniel, martin.lau, song, yhs, john.fastabend, kpsingh, sdf,
	haoluo, jolsa, bpf, linux-kernel, Menglong Dong

From: Menglong Dong <imagedong@tencent.com>

'.' 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>
---
 tools/lib/bpf/libbpf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index fdfb1ca34ced..5d6f6675c2f2 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9994,9 +9994,16 @@ static void gen_kprobe_legacy_event_name(char *buf, size_t buf_sz,
 					 const char *kfunc_name, size_t offset)
 {
 	static int index = 0;
+	int i = 0;
 
 	snprintf(buf, buf_sz, "libbpf_%u_%s_0x%zx_%d", getpid(), kfunc_name, offset,
 		 __sync_fetch_and_add(&index, 1));
+
+	while (buf[i] != '\0') {
+		if (buf[i] == '.')
+			buf[i] = '_';
+		i++;
+	}
 }
 
 static int add_kprobe_event_legacy(const char *probe_name, bool retprobe,
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-17  2:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-13  9:34 [PATCH] libbpf: replace '.' with '_' in legacy kprobe event name menglong8.dong
2023-01-13 14:12 ` Alan Maguire
2023-01-13 22:07   ` Andrii Nakryiko
2023-01-16  2:27     ` Menglong Dong
2023-01-16 10:27       ` Alan Maguire
2023-01-17  2:38         ` Menglong Dong
2023-01-13 22:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox