On Mon, Aug 25, 2025 at 1:51 PM Stanislav Fomichev <stfomichev@xxxxxxxxx> wrote: > > On 08/25, Kuniyuki Iwashima wrote: > > We will store a flag in sk->sk_memcg by bpf_setsockopt(). > > > > For a new child socket, memcg is not allocated until accept(), > > and the child's sk_memcg is not always the parent's one. > > > > For details, see commit e876ecc67db8 ("cgroup: memcg: net: do not > > associate sock with unrelated cgroup") and commit d752a4986532 > > ("net: memcg: late association of sock to memcg"). > > > > Let's add a new hook for BPF_PROG_TYPE_CGROUP_SOCK in > > __inet_accept(). > > > > This hook does not fail by not supporting bpf_set_retval(). > > > > Signed-off-by: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx> > > And similarly to [0], doing it in sock_ops's BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB > is not an option because you want to run in the process context instead > of softirq? Yes, I considered the hook but ended up adding a new one in accept(), only when we know sk_memcg is the intended one. > > 0: https://lore.kernel.org/netdev/daa73a77-3366-45b4-a770-fde87d4f50d8@xxxxxxxxx/