Re: [PATCH bpf-next v4 2/4] bpf: Improve error reporting for freplace attachment failure

Leon Hwang
2025-02-26T14:17:55Z

On 2025/2/26 11:17, Alexei Starovoitov wrote:
> On Tue, Feb 25, 2025 at 9:19 AM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
>>
>>> But, how can we achieve it?
>>
>> There is no *elegant* way to do this, but I think we could retrofit
>> this as extra common bpf_attrs into existing bpf() syscall. Something
>> along the lines of:
>>
>> struct bpf_common_attr {
>> __u64 log_buf;
>> __u32 log_size;
>
> other than missing log_level I like this approach.
>
>> }
>>
>> #define BPF_COMMON_ATTRS 0x80000000
>
> negative enum/int is a bit meh, can we use 64 instead?
> In token we have:
> BUILD_BUG_ON(__MAX_BPF_CMD >= 64);
> and delegate_cmds mount option too.
>
> Currently __MAX_BPF_CMD = 37
> so we have some room.
> BPF_COMMON_ATTRS (1 << 16) is fine too.
> Just not the sign bit.
>

Let me try this approach with BPF_COMMON_ATTRS (1 << 16).

Thanks,
Leon