From: Alan Maguire <alan.maguire@oracle.com>
To: menglong8.dong@gmail.com, andrii@kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
song@kernel.org, yhs@fb.com, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
jolsa@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org,
Menglong Dong <imagedong@tencent.com>
Subject: Re: [PATCH] libbpf: replace '.' with '_' in legacy kprobe event name
Date: Fri, 13 Jan 2023 14:12:41 +0000 [thread overview]
Message-ID: <bdca73eb-07e3-2187-c46f-a3f14a9e50a4@oracle.com> (raw)
In-Reply-To: <20230113093427.1666466-1-imagedong@tencent.com>
On 13/01/2023 09:34, menglong8.dong@gmail.com wrote:
> 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++;
> + }
> }
probably more naturally expressed as a for() loop as is done in
gen_uprobe_legacy_event_name(), but not a big deal.
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
One issue with the legacy kprobe code is that we don't get test coverage
with it on new kernels - I wonder if it would be worth adding a force_legacy
option to bpf_kprobe_opts? A separate issue to this change of course, but
if we had that we could add some legacy kprobe tests that would run
for new kernels as well.
Alan
>
> static int add_kprobe_event_legacy(const char *probe_name, bool retprobe,
>
next prev parent reply other threads:[~2023-01-13 14:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 9:34 menglong8.dong
2023-01-13 14:12 ` Alan Maguire [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bdca73eb-07e3-2187-c46f-a3f14a9e50a4@oracle.com \
--to=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=imagedong@tencent.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=menglong8.dong@gmail.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®