* [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol
@ 2024-08-22 6:08 Gang Yan
2024-08-22 15:29 ` Jakub Kicinski
0 siblings, 1 reply; 7+ messages in thread
From: Gang Yan @ 2024-08-22 6:08 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Gang Yan, netdev, bpf, Geliang Tang
From: Gang Yan <yangang@kylinos.cn>
The "update_socket_protocol" interface is designed to empower user space
with the capability to customize and modify socket protocols leveraging
BPF methods. Currently, it has only granted the fmod_ret permission,
allowing for modifications to return values. We are extending the
permissions further by 'ALLOW_ERROR_INJECTION', thereby facilitating
the development of user-space programs with enhanced flexibility and
convenience.
When we attempt to modify the return value of "update_socket_protocol"
to "IPPROTO_MPTCP" using the below code based on the BCC tool:
'''
int kprobe__update_socket_protocol(void* ctx)
{
...
bpf_override_return(ctx, IPPROTO_MPTCP);
...
}
'''
But an error occurs:
'''
ioctl(PERF_EVENT_IOC_SET_BPF): Invalid argument
Traceback (most recent call last):
File "/media/yangang/work/Code/BCC/test.py", line 27, in <module>
b = BPF(text=prog)
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 487, \
in __init__ self._trace_autoload()
File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 1466, \
in _trace_autoload self.attach_kprobe(
File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 855,\
in attach_kprobe
raise Exception("Failed to attach BPF program %s to kprobe %s"
Exception: Failed to attach BPF program b'kprobe__update_socket_protocol' \
to kprobe b'update_socket_protocol', it's not traceable \
(either non-existing, inlined, or marked as "notrace")
'''
This patch can fix the issue.
Suggested-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
net/socket.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/socket.c b/net/socket.c
index fcbdd5bc47ac..63ce1caf75eb 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1695,6 +1695,7 @@ __weak noinline int update_socket_protocol(int family, int type, int protocol)
{
return protocol;
}
+ALLOW_ERROR_INJECTION(update_socket_protocol, ERRNO);
__bpf_hook_end();
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol
2024-08-22 6:08 Gang Yan
@ 2024-08-22 15:29 ` Jakub Kicinski
2024-08-22 18:43 ` Alexei Starovoitov
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2024-08-22 15:29 UTC (permalink / raw)
To: Gang Yan
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Gang Yan, netdev, bpf,
Geliang Tang
On Thu, 22 Aug 2024 14:08:57 +0800 Gang Yan wrote:
> diff --git a/net/socket.c b/net/socket.c
> index fcbdd5bc47ac..63ce1caf75eb 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1695,6 +1695,7 @@ __weak noinline int update_socket_protocol(int family, int type, int protocol)
> {
> return protocol;
> }
> +ALLOW_ERROR_INJECTION(update_socket_protocol, ERRNO);
IDK if this falls under BPF or directly net, but could you explain
what test will use this? I'd prefer not to add test hooks into the
kernel unless they are exercised by in-tree tests.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol
2024-08-22 15:29 ` Jakub Kicinski
@ 2024-08-22 18:43 ` Alexei Starovoitov
0 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2024-08-22 18:43 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Gang Yan, David S. Miller, Eric Dumazet, Paolo Abeni, Gang Yan,
Network Development, bpf, Geliang Tang
On Thu, Aug 22, 2024 at 8:33 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 22 Aug 2024 14:08:57 +0800 Gang Yan wrote:
> > diff --git a/net/socket.c b/net/socket.c
> > index fcbdd5bc47ac..63ce1caf75eb 100644
> > --- a/net/socket.c
> > +++ b/net/socket.c
> > @@ -1695,6 +1695,7 @@ __weak noinline int update_socket_protocol(int family, int type, int protocol)
> > {
> > return protocol;
> > }
> > +ALLOW_ERROR_INJECTION(update_socket_protocol, ERRNO);
>
> IDK if this falls under BPF or directly net, but could you explain
> what test will use this? I'd prefer not to add test hooks into the
> kernel unless they are exercised by in-tree tests.
This looks unnecessary.
update_socket_protocol is already registered as fmodret.
There is even selftest that excises this feature:
tools/testing/selftests/bpf/progs/mptcpify.c
It doesn't need to be part of the error-inject.
pw-bot: cr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol
[not found] <tmcxv429u9-tmgrokbfbm@nsmail7.0.0--kylin--1>
@ 2024-08-26 3:29 ` Gang Yan
2024-08-26 4:05 ` Yonghong Song
0 siblings, 1 reply; 7+ messages in thread
From: Gang Yan @ 2024-08-26 3:29 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: netdev, bpf
Hi Alexei:
It's my honor to recieve your reply. The response to your concerns is attached below
for your review.
On Mon, Aug 26, 2024 at 10:57:12AM +0800, Gang Yan wrote:
> On Thu, Aug 22, 2024 at 8:33 AM Jakub Kicinski wrote:
> >
> > On Thu, 22 Aug 2024 14:08:57 +0800 Gang Yan wrote:
> > > diff --git a/net/socket.c b/net/socket.c
> > > index fcbdd5bc47ac..63ce1caf75eb 100644
> > > --- a/net/socket.c
> > > +++ b/net/socket.c
> > > @@ -1695,6 +1695,7 @@ __weak noinline int update_socket_protocol(int family, int type, int protocol)
> > > {
> > > return protocol;
> > > }
> > > +ALLOW_ERROR_INJECTION(update_socket_protocol, ERRNO);
> >
> > IDK if this falls under BPF or directly net, but could you explain
> > what test will use this? I'd prefer not to add test hooks into the
> > kernel unless they are exercised by in-tree tests.
> This looks unnecessary.
> update_socket_protocol is already registered as fmodret.
> There is even selftest that excises this feature:
> tools/testing/selftests/bpf/progs/mptcpify.c
>
> It doesn't need to be part of the error-inject.
The 'update_socket_protocol' is a BPF interface designed primarily to
fix the socket protocol from TCP protocol to MPTCP protocol without
requiring modifications to user-space application codes. However,
when attempting to achieve this using the BCC tool in user-space,
the BCC tool doesn't support 'fmod_ret'. Therefore, this patch aims to
further expand capabilities, enabling the 'kprobe' method can overriding
the update_socket_protocol interface.
As a Python developer, the BCC tool is a commonly utilized instrument for
interacting with the kernel. If the kernel could permit the use of an
error-inject method to modify the `update_socket_protocol`, it would significantly
benefit the subsequent promotion and development of MPTCP applications.
Thank you for considering this enhancement.
Best wishes!
Gang Yan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol
2024-08-26 3:29 ` Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol Gang Yan
@ 2024-08-26 4:05 ` Yonghong Song
2025-04-09 9:17 ` Geliang Tang
0 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2024-08-26 4:05 UTC (permalink / raw)
To: Gang Yan, Alexei Starovoitov; +Cc: netdev, bpf
On 8/25/24 8:29 PM, Gang Yan wrote:
> Hi Alexei:
> It's my honor to recieve your reply. The response to your concerns is attached below
> for your review.
> On Mon, Aug 26, 2024 at 10:57:12AM +0800, Gang Yan wrote:
>> On Thu, Aug 22, 2024 at 8:33 AM Jakub Kicinski wrote:
>>> On Thu, 22 Aug 2024 14:08:57 +0800 Gang Yan wrote:
>>>> diff --git a/net/socket.c b/net/socket.c
>>>> index fcbdd5bc47ac..63ce1caf75eb 100644
>>>> --- a/net/socket.c
>>>> +++ b/net/socket.c
>>>> @@ -1695,6 +1695,7 @@ __weak noinline int update_socket_protocol(int family, int type, int protocol)
>>>> {
>>>> return protocol;
>>>> }
>>>> +ALLOW_ERROR_INJECTION(update_socket_protocol, ERRNO);
>>> IDK if this falls under BPF or directly net, but could you explain
>>> what test will use this? I'd prefer not to add test hooks into the
>>> kernel unless they are exercised by in-tree tests.
>> This looks unnecessary.
>> update_socket_protocol is already registered as fmodret.
>> There is even selftest that excises this feature:
>> tools/testing/selftests/bpf/progs/mptcpify.c
>>
>> It doesn't need to be part of the error-inject.
> The 'update_socket_protocol' is a BPF interface designed primarily to
> fix the socket protocol from TCP protocol to MPTCP protocol without
> requiring modifications to user-space application codes. However,
> when attempting to achieve this using the BCC tool in user-space,
> the BCC tool doesn't support 'fmod_ret'. Therefore, this patch aims to
> further expand capabilities, enabling the 'kprobe' method can overriding
> the update_socket_protocol interface.
Gang Yan, could you explore to add fmod_ret support in bcc? It should be
similar to kfunc/kretfunc support. I am happy to review your patches.
Thanks,
Yonghong
>
> As a Python developer, the BCC tool is a commonly utilized instrument for
> interacting with the kernel. If the kernel could permit the use of an
> error-inject method to modify the `update_socket_protocol`, it would significantly
> benefit the subsequent promotion and development of MPTCP applications.
> Thank you for considering this enhancement.
>
> Best wishes!
> Gang Yan
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol
2024-08-26 4:05 ` Yonghong Song
@ 2025-04-09 9:17 ` Geliang Tang
2025-04-11 18:06 ` Yonghong Song
0 siblings, 1 reply; 7+ messages in thread
From: Geliang Tang @ 2025-04-09 9:17 UTC (permalink / raw)
To: Yonghong Song, Gang Yan, Alexei Starovoitov; +Cc: netdev, bpf, mptcp
Hi Yonghong,
On Sun, 2024-08-25 at 21:05 -0700, Yonghong Song wrote:
>
> On 8/25/24 8:29 PM, Gang Yan wrote:
> > Hi Alexei:
> > It's my honor to recieve your reply. The response to your concerns
> > is attached below
> > for your review.
> > On Mon, Aug 26, 2024 at 10:57:12AM +0800, Gang Yan wrote:
> > > On Thu, Aug 22, 2024 at 8:33 AM Jakub Kicinski wrote:
> > > > On Thu, 22 Aug 2024 14:08:57 +0800 Gang Yan wrote:
> > > > > diff --git a/net/socket.c b/net/socket.c
> > > > > index fcbdd5bc47ac..63ce1caf75eb 100644
> > > > > --- a/net/socket.c
> > > > > +++ b/net/socket.c
> > > > > @@ -1695,6 +1695,7 @@ __weak noinline int
> > > > > update_socket_protocol(int family, int type, int protocol)
> > > > > {
> > > > > return protocol;
> > > > > }
> > > > > +ALLOW_ERROR_INJECTION(update_socket_protocol, ERRNO);
> > > > IDK if this falls under BPF or directly net, but could you
> > > > explain
> > > > what test will use this? I'd prefer not to add test hooks into
> > > > the
> > > > kernel unless they are exercised by in-tree tests.
> > > This looks unnecessary.
> > > update_socket_protocol is already registered as fmodret.
> > > There is even selftest that excises this feature:
> > > tools/testing/selftests/bpf/progs/mptcpify.c
> > >
> > > It doesn't need to be part of the error-inject.
> > The 'update_socket_protocol' is a BPF interface designed primarily
> > to
> > fix the socket protocol from TCP protocol to MPTCP protocol without
> > requiring modifications to user-space application codes. However,
> > when attempting to achieve this using the BCC tool in user-space,
> > the BCC tool doesn't support 'fmod_ret'. Therefore, this patch aims
> > to
> > further expand capabilities, enabling the 'kprobe' method can
> > overriding
> > the update_socket_protocol interface.
>
> Gang Yan, could you explore to add fmod_ret support in bcc? It should
> be
> similar to kfunc/kretfunc support. I am happy to review your patches.
It took us some time to add this support in bcc, and we have recently
completed it in [1]. We would be grateful if you could help review
these patches.
Thanks,
-Geliang
[1]
https://github.com/iovisor/bcc/pull/5274
>
> Thanks,
> Yonghong
>
> >
> > As a Python developer, the BCC tool is a commonly utilized
> > instrument for
> > interacting with the kernel. If the kernel could permit the use of
> > an
> > error-inject method to modify the `update_socket_protocol`, it
> > would significantly
> > benefit the subsequent promotion and development of MPTCP
> > applications.
> > Thank you for considering this enhancement.
> >
> > Best wishes!
> > Gang Yan
> >
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol
2025-04-09 9:17 ` Geliang Tang
@ 2025-04-11 18:06 ` Yonghong Song
0 siblings, 0 replies; 7+ messages in thread
From: Yonghong Song @ 2025-04-11 18:06 UTC (permalink / raw)
To: Geliang Tang, Gang Yan, Alexei Starovoitov; +Cc: netdev, bpf, mptcp
On 4/9/25 2:17 AM, Geliang Tang wrote:
> Hi Yonghong,
>
> On Sun, 2024-08-25 at 21:05 -0700, Yonghong Song wrote:
>> On 8/25/24 8:29 PM, Gang Yan wrote:
>>> Hi Alexei:
>>> It's my honor to recieve your reply. The response to your concerns
>>> is attached below
>>> for your review.
>>> On Mon, Aug 26, 2024 at 10:57:12AM +0800, Gang Yan wrote:
>>>> On Thu, Aug 22, 2024 at 8:33 AM Jakub Kicinski wrote:
>>>>> On Thu, 22 Aug 2024 14:08:57 +0800 Gang Yan wrote:
>>>>>> diff --git a/net/socket.c b/net/socket.c
>>>>>> index fcbdd5bc47ac..63ce1caf75eb 100644
>>>>>> --- a/net/socket.c
>>>>>> +++ b/net/socket.c
>>>>>> @@ -1695,6 +1695,7 @@ __weak noinline int
>>>>>> update_socket_protocol(int family, int type, int protocol)
>>>>>> {
>>>>>> return protocol;
>>>>>> }
>>>>>> +ALLOW_ERROR_INJECTION(update_socket_protocol, ERRNO);
>>>>> IDK if this falls under BPF or directly net, but could you
>>>>> explain
>>>>> what test will use this? I'd prefer not to add test hooks into
>>>>> the
>>>>> kernel unless they are exercised by in-tree tests.
>>>> This looks unnecessary.
>>>> update_socket_protocol is already registered as fmodret.
>>>> There is even selftest that excises this feature:
>>>> tools/testing/selftests/bpf/progs/mptcpify.c
>>>>
>>>> It doesn't need to be part of the error-inject.
>>> The 'update_socket_protocol' is a BPF interface designed primarily
>>> to
>>> fix the socket protocol from TCP protocol to MPTCP protocol without
>>> requiring modifications to user-space application codes. However,
>>> when attempting to achieve this using the BCC tool in user-space,
>>> the BCC tool doesn't support 'fmod_ret'. Therefore, this patch aims
>>> to
>>> further expand capabilities, enabling the 'kprobe' method can
>>> overriding
>>> the update_socket_protocol interface.
>> Gang Yan, could you explore to add fmod_ret support in bcc? It should
>> be
>> similar to kfunc/kretfunc support. I am happy to review your patches.
> It took us some time to add this support in bcc, and we have recently
> completed it in [1]. We would be grateful if you could help review
> these patches.
Sounds good. I will take a look.
>
> Thanks,
> -Geliang
>
> [1]
> https://github.com/iovisor/bcc/pull/5274
>
>> Thanks,
>> Yonghong
>>
>>> As a Python developer, the BCC tool is a commonly utilized
>>> instrument for
>>> interacting with the kernel. If the kernel could permit the use of
>>> an
>>> error-inject method to modify the `update_socket_protocol`, it
>>> would significantly
>>> benefit the subsequent promotion and development of MPTCP
>>> applications.
>>> Thank you for considering this enhancement.
>>>
>>> Best wishes!
>>> Gang Yan
>>>
>>>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-11 18:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <tmcxv429u9-tmgrokbfbm@nsmail7.0.0--kylin--1>
2024-08-26 3:29 ` Re: [PATCH bpf-next] bpf: Allow error injection for update_socket_protocol Gang Yan
2024-08-26 4:05 ` Yonghong Song
2025-04-09 9:17 ` Geliang Tang
2025-04-11 18:06 ` Yonghong Song
2024-08-22 6:08 Gang Yan
2024-08-22 15:29 ` Jakub Kicinski
2024-08-22 18:43 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).