From: Gang Yan <yangang@kylinos.cn>
To: Matthieu Baerts <matttbe@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH 1/2] BCC: Python: Support 'fmod_ret' method for eBPF
Date: Tue, 8 Apr 2025 09:56:49 +0800 [thread overview]
Message-ID: <20250408015649.GA21239@yangang-pc> (raw)
In-Reply-To: <851297ad-5e66-4374-9914-cd48868c4c7b@kernel.org>
On Mon, Apr 07, 2025 at 11:07:41AM +0200, Matthieu Baerts wrote:
Hi Matt,
> Hi Gang,
>
> On 07/04/2025 04:37, Gang Yan wrote:
> > In kernel, there exists a lot of 'fmod_ret' functions, such as
> > 'update_socket_protocol'. But it cannot be attached in BCC-python
> > directly, so this patch provides an interface for Python to use
> > 'fmod_ret' attaching method.
> >
> > Signed-off-by: Gang Yan <yangang@kylinos.cn>
> > ---
> > src/python/bcc/__init__.py | 43 ++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 43 insertions(+)
> >
> > diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
> > index 8bc85516..96de3d40 100644
> > --- a/src/python/bcc/__init__.py
> > +++ b/src/python/bcc/__init__.py
> > @@ -461,6 +461,7 @@ class BPF(object):
> > self.raw_tracepoint_fds = {}
> > self.kfunc_entry_fds = {}
> > self.kfunc_exit_fds = {}
> > + self.fmod_ret_fds = {}
> > self.lsm_fds = {}
> > self.perf_buffers = {}
> > self.open_perf_events = {}
> > @@ -1157,6 +1158,21 @@ class BPF(object):
> > return True
> > return False
> >
> > + @staticmethod
> > + def support_fmod_ret():
> > + if not BPF.support_kfunc():
> > + return False
> > +
> > + kernel_version = platform.release()
> > + major, minor, _ = kernel_version.split(".")
> > +
> > + if int(major) > 5:
> > + return True
> > + elif int(major) ==5 and int(minor) >= 6:
>
> Was it not introduced in v5.7 instead of v5.6?
>
> return int(major) > 5 or (int(major) == 5 and int(minor) >= 7)
>
I think v5.7 is right, the 5.6 is from the bcc repo:
bcc/example/cpp/KModRetExample.cc:
* Kfunc modify_ret support is only available at kernel version 5.6 and later.
Maybe this is also need to be fixed later?
>
> https://lore.kernel.org/20200304191853.1529-1-kpsingh@chromium.org
>
>
> But also, it feels wrong to look at the kernel version, in case of
> backports, etc. Can you not look at something else? e.g. kallsyms?
>
Do you think we can do this after making a PR first?
> Cheers,
> Matt
> --
> Sponsored by the NGI0 Core fund.
>
>
next prev parent reply other threads:[~2025-04-08 1:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 2:37 [PATCH 0/2] BCC: python: support fmod_ret Gang Yan
2025-04-07 2:37 ` [PATCH 1/2] BCC: Python: Support 'fmod_ret' method for eBPF Gang Yan
2025-04-07 9:07 ` Matthieu Baerts
2025-04-08 1:56 ` Gang Yan [this message]
2025-04-08 10:02 ` Matthieu Baerts
2025-04-07 2:37 ` [PATCH 2/2] BCC: python: add a useful tool for mptcp Gang Yan
2025-04-07 9:09 ` Matthieu Baerts
2025-04-08 2:00 ` Gang Yan
2025-04-07 9:07 ` [PATCH 0/2] BCC: python: support fmod_ret Matthieu Baerts
2025-04-08 2:02 ` Gang Yan
2025-04-08 10:04 ` Matthieu Baerts
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=20250408015649.GA21239@yangang-pc \
--to=yangang@kylinos.cn \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.