* [PATCH] ipv4, bpf: Introduced to support the ULP to modify sockets during setopt
@ 2025-01-21 8:05 zhangmingyi
2025-01-23 21:14 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: zhangmingyi @ 2025-01-21 8:05 UTC (permalink / raw)
To: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, sdf, haoluo, jolsa
Cc: bpf, linux-kernel, yanan, wuchangye, xiesongyang, liuxin350,
liwei883, tianmuyang, zhangmingyi5
Note that tcp_getsockopt and tcp_setsockopt support TCP_ULP, while
bpf_getsockopt and bpf_setsockopt do not support TCP_ULP.
I think we can add the handling of this case.
Signed-off-by: zhangmingyi <zhangmingyi5@huawei.com>
---
net/core/filter.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index 713d6f454df3..f23d3f87e690 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5383,6 +5383,10 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
if (*optlen < 1)
return -EINVAL;
break;
+ case TCP_ULP:
+ if (getopt)
+ return -EINVAL;
+ break;
case TCP_BPF_SOCK_OPS_CB_FLAGS:
if (*optlen != sizeof(int))
return -EINVAL;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ipv4, bpf: Introduced to support the ULP to modify sockets during setopt
2025-01-21 8:05 [PATCH] ipv4, bpf: Introduced to support the ULP to modify sockets during setopt zhangmingyi
@ 2025-01-23 21:14 ` Daniel Borkmann
2025-01-26 3:36 ` zhangmingyi
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2025-01-23 21:14 UTC (permalink / raw)
To: zhangmingyi, ast, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, sdf, haoluo, jolsa
Cc: bpf, linux-kernel, yanan, wuchangye, xiesongyang, liuxin350,
liwei883, tianmuyang
On 1/21/25 9:05 AM, zhangmingyi wrote:
> Note that tcp_getsockopt and tcp_setsockopt support TCP_ULP, while
> bpf_getsockopt and bpf_setsockopt do not support TCP_ULP.
> I think we can add the handling of this case.
Please elaborate on the use case you're trying to solve, and also a
BPF selftest is needed to back this use case up. Your latter sentence
does not sound overly sure which makes me wonder if you've tested this
code at all?
> Signed-off-by: zhangmingyi <zhangmingyi5@huawei.com>
> ---
> net/core/filter.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 713d6f454df3..f23d3f87e690 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -5383,6 +5383,10 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
> if (*optlen < 1)
> return -EINVAL;
> break;
> + case TCP_ULP:
> + if (getopt)
> + return -EINVAL;
> + break;
> case TCP_BPF_SOCK_OPS_CB_FLAGS:
> if (*optlen != sizeof(int))
> return -EINVAL;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ipv4, bpf: Introduced to support the ULP to modify sockets during setopt
2025-01-23 21:14 ` Daniel Borkmann
@ 2025-01-26 3:36 ` zhangmingyi
0 siblings, 0 replies; 3+ messages in thread
From: zhangmingyi @ 2025-01-26 3:36 UTC (permalink / raw)
To: daniel
Cc: ast, andrii, martin.lau, song, yhs, john.fastabend, kpsingh, sdf,
haoluo, jolsa, bpf, linux-kernel, yanan, wuchangye, xiesongyang,
liuxin350, liwei883, tianmuyang, zhangmingyi5
We want to call `bpf_setsockopt` to replace the kernel module in the TCP_ULP case. The purpose is to customize the behavior in `connect` and `sendmsg`. We have an open-source community project kmesh (kmesh.net). Based on this, we refer to some processes of TCP Fast Open to implement delayed connect and perform HTTP DNAT when `sendmsg`.
I'll send a patch with a full description and test cases later.
> > Signed-off-by: zhangmingyi <zhangmingyi5@huawei.com>
> > ---
> > net/core/filter.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index 713d6f454df3..f23d3f87e690 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -5383,6 +5383,10 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
> > if (*optlen < 1)
> > return -EINVAL;
> > break;
> > + case TCP_ULP:
> > + if (getopt)
> > + return -EINVAL;
> > + break;
> > case TCP_BPF_SOCK_OPS_CB_FLAGS:
> > if (*optlen != sizeof(int))
> > return -EINVAL;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-26 3:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-21 8:05 [PATCH] ipv4, bpf: Introduced to support the ULP to modify sockets during setopt zhangmingyi
2025-01-23 21:14 ` Daniel Borkmann
2025-01-26 3:36 ` zhangmingyi
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®