Re: [PATCH bpf-next v3] bpf: bpf_{g,s}etsockopt for struct bpf_sock_addr
From: Martin KaFai Lau <hidden>
Date: 2020-05-01 05:55:16
Also in:
bpf
From: Martin KaFai Lau <hidden>
Date: 2020-05-01 05:55:16
Also in:
bpf
On Thu, Apr 30, 2020 at 04:31:52PM -0700, Stanislav Fomichev wrote:
Currently, bpf_getsockopt and bpf_setsockopt helpers operate on the
'struct bpf_sock_ops' context in BPF_PROG_TYPE_SOCK_OPS program.
Let's generalize them and make them available for 'struct bpf_sock_addr'.
That way, in the future, we can allow those helpers in more places.
As an example, let's expose those 'struct bpf_sock_addr' based helpers to
BPF_CGROUP_INET{4,6}_CONNECT hooks. That way we can override CC before the
connection is made.
v3:
* Expose custom helpers for bpf_sock_addr context instead of doing
generic bpf_sock argument (as suggested by Daniel). Even with
try_socket_lock that doesn't sleep we have a problem where context sk
is already locked and socket lock is non-nestable.Acked-by: Martin KaFai Lau <redacted>