Message ID | 20230121025716.3039933-2-kuifeng@meta.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | Enable bpf_setsockopt() on ktls enabled sockets. | expand |
On 1/20/23 6:57 PM, Kui-Feng Lee wrote: > Resolve an issue when calling sol_tcp_sockopt() on a socket with ktls > enabled. Prior to this patch, sol_tcp_sockopt() would only allow calls > if the function pointer of setsockopt of the socket was set to > tcp_setsockopt(). However, any socket with ktls enabled would have its > function pointer set to tls_setsockopt(). To resolve this issue, the > patch adds a check of the protocol of the linux socket and allows > bpf_setsockopt() to be called if ktls is initialized on the linux > socket. This ensures that calls to sol_tcp_sockopt() will succeed on > sockets with ktls enabled. > > Signed-off-by: Kui-Feng Lee <kuifeng@meta.com> > --- > net/core/filter.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/core/filter.c b/net/core/filter.c > index b4547a2c02f4..890384cbdeb2 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -5204,7 +5204,7 @@ static int sol_tcp_sockopt(struct sock *sk, int optname, > char *optval, int *optlen, > bool getopt) > { > - if (sk->sk_prot->setsockopt != tcp_setsockopt) > + if (sk->sk_protocol != IPPROTO_TCP) It is a pretty broad test but I don't see particular issue also. Let see how it goes.
diff --git a/net/core/filter.c b/net/core/filter.c index b4547a2c02f4..890384cbdeb2 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -5204,7 +5204,7 @@ static int sol_tcp_sockopt(struct sock *sk, int optname, char *optval, int *optlen, bool getopt) { - if (sk->sk_prot->setsockopt != tcp_setsockopt) + if (sk->sk_protocol != IPPROTO_TCP) return -EINVAL; switch (optname) {
Resolve an issue when calling sol_tcp_sockopt() on a socket with ktls enabled. Prior to this patch, sol_tcp_sockopt() would only allow calls if the function pointer of setsockopt of the socket was set to tcp_setsockopt(). However, any socket with ktls enabled would have its function pointer set to tls_setsockopt(). To resolve this issue, the patch adds a check of the protocol of the linux socket and allows bpf_setsockopt() to be called if ktls is initialized on the linux socket. This ensures that calls to sol_tcp_sockopt() will succeed on sockets with ktls enabled. Signed-off-by: Kui-Feng Lee <kuifeng@meta.com> --- net/core/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)