On Tue, Aug 29, 2023 at 3:19 AM Daan De Meyer <daan.j.demeyer@xxxxxxxxx> wrote: > > As prep for adding unix socket support to the cgroup sockaddr hooks, > let's add a kfunc bpf_sock_addr_set() that allows modifying a sockaddr > from bpf. While this is already possible for AF_INET and AF_INET6, we'll > need this kfunc when we add unix socket support since modifying the > address for those requires modifying both the address and the sockaddr > length. > > We also add the necessary hook to make the new kfunc work properly. > > Signed-off-by: Daan De Meyer <daan.j.demeyer@xxxxxxxxx> > --- > kernel/bpf/btf.c | 3 +++ > net/core/filter.c | 42 +++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 44 insertions(+), 1 deletion(-) > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > index 249657c466dd..157342eaa2bb 100644 > --- a/kernel/bpf/btf.c > +++ b/kernel/bpf/btf.c > @@ -217,6 +217,7 @@ enum btf_kfunc_hook { > m, > BTF_KFUNC_HOOK_LWT, > BTF_KFUNC_HOOK_NETFILTER, > + BTF_KFUNC_HOOK_SOCK_ADDR, Do we really need a new kfunc category? Can BTF_KFUNC_HOOK_CGROUP_SKB be reused here? or even BTF_KFUNC_HOOK_COMMON ? struct bpf_sock_addr_kern * type of bpf_sock_addr_set_addr() will prevent any other type being passed in here and bpf_sock_addr_kern type is local to prog run via __cgroup_bpf_run_filter_sock_addr.