Subsystems (3)
Date: Wed, 29 Apr 2020 09:53:39 -0700
From: Stanislav Fomichev <[email protected]>
To: Martin KaFai Lau <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected]
Subject: Re: [PATCH bpf-next] bpf: bpf_{g,s}etsockopt for struct bpf_sock
Message-ID: <[email protected]>
References: <[email protected]>
<20200429164550.xmlklvypzlcjagvw@kafai-mbp>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20200429164550.xmlklvypzlcjagvw@kafai-mbp>
Quoted 11 lines · Martin KaFai Lau
Quoted 4 lines · Stanislav Fomichev
Currently,
bpf_getsocktopandbpf_setsockopthelpers operate on the 'structbpf_sock_ops' context inBPF_PROG_TYPE_CGROUP_SOCKOPTprogram. Let's generalize them and make the first argument be 'structbpf_sock'. That way, in the future, we can allow those helpers in more places.s/BPF_PROG_TYPE_CGROUP_SOCKOPT/BPF_PROG_TYPE_SOCK_OPS/
Same for the other uses in the commit message and also the document comment in the uapi (and tools)
bpf.h.Others LGTM.
Oops, good catch, will follow up with a v2, thanks!
Quoted 11 lines
Quoted 11 lines
BPF_PROG_TYPE_CGROUP_SOCKOPTstill has the existing helpers that operate on 'structbpf_sock_ops', but we add new bpf_{g,s}etsockopt that work on 'structbpf_sock'. [Alternatively, forBPF_PROG_TYPE_CGROUP_SOCKOPT, we can enable them both and teach verifier to pick the right one based on the context (bpf_sock_opsvsbpf_sock).]As an example, let's allow those 'struct
bpf_sock' based helpers to be called from the BPF_CGROUP_INET{4,6}_CONNECT hooks. That way we can override CC before the connection is made.Signed-off-by Stanislav Fomichev <[email protected]>