Re: [PATCH bpf-next 1/4] xdp: Support specifying expected existing program when attaching XDP

Toke Høiland-Jørgensen
2020-03-20T18:17:53Z

Jakub Kicinski <kuba@kernel.org> writes:

>> > If we do please run this thru checkpatch, set .strict_start_type,
>>
>> Will do.
>>
>> > and make the expected fd unsigned. A negative expected fd makes no
>> > sense.
>>
>> A negative expected_fd corresponds to setting the UPDATE_IF_NOEXIST
>> flag. I guess you could argue that since we have that flag, setting a
>> negative expected_fd is not strictly needed. However, I thought it was
>> weird to have a "this is what I expect" API that did not support
>> expressing "I expect no program to be attached".
>
> I see it now, not entirely unreasonable.
>
> Why did you choose to use the FD rather than passing prog id directly?
> Is the application unlikely to have program ID?

For consistency with other APIs. Seems the pattern is generally that
userspace supplies program FDs, and the kernel returns IDs, no?

-Toke