Re: [PATCH v2 02/23] bpf: initial support for attaching struct ops to cgroups

From: Roman Gushchin

Date: Wed Oct 29 2025 - 16:27:09 EST


Song Liu <song@xxxxxxxxxx> writes:

> On Mon, Oct 27, 2025 at 4:17 PM Roman Gushchin <roman.gushchin@xxxxxxxxx> wrote:
> [...]
>> struct bpf_struct_ops_value {
>> struct bpf_struct_ops_common_value common;
>> @@ -1359,6 +1360,18 @@ int bpf_struct_ops_link_create(union bpf_attr *attr)
>> }
>> bpf_link_init(&link->link, BPF_LINK_TYPE_STRUCT_OPS, &bpf_struct_ops_map_lops, NULL,
>> attr->link_create.attach_type);
>> +#ifdef CONFIG_CGROUPS
>> + if (attr->link_create.cgroup.relative_fd) {
>> + struct cgroup *cgrp;
>> +
>> + cgrp = cgroup_get_from_fd(attr->link_create.cgroup.relative_fd);
>
> We should use "target_fd" here, not relative_fd.

Ok, thanks!

>
> Also, 0 is a valid fd, so we cannot use target_fd == 0 to attach to
> global memcg.

Yep, switching to using root_memcg's fd instead.

Thanks!