Subject: Re: [RFC PATCH] net_tstamp: add SCM_TS_OPT_ID to provide OPT_ID in control message

From: Vadim Fedorenko <[email-masked]>
Date: Thu, 29 Aug 2024 16:00:21 +0100

On 29/08/2024 15:27, Willem de Bruijn wrote:
> Vadim Fedorenko wrote:
>> On 29/08/2024 14:31, Willem de Bruijn wrote:
>>> Vadim Fedorenko wrote:
>>>> SOF_TIMESTAMPING_OPT_ID socket option flag gives a way to correlate TX
>>>> timestamps
>>>
>>> +1 on the feature. Few minor points only.
>>>
>>> Not a hard requirement, but would be nice if there was a test,
>>> e.g., as a tools/testing/../txtimestamp.c extension.
>>
>> Sure, I'll add some tests in the next version.
>>
>>
>>>> and packets sent via socket. Unfortunately, there is no way
>>>> to reliably predict socket timestamp ID value in case of error returned
>>>> by sendmsg [1].
>>>
>>> Might be good to copy more context from the discussion to explain why
>>> reliable OPT_ID is infeasible. For UDP, it is as simple as lockless
>>> transmit. For RAW, things like MSG_MORE come into play.
>>
>> Ok, I'll add it, thanks!
>>
>>>> This patch adds new control message type to give user-space
>>>> software an opportunity to control the mapping between packets and
>>>> values by providing ID with each sendmsg. This works fine for UDP
>>>> sockets only, and explicit check is added to control message parser.
>>>> Also, there is no easy way to use 0 as provided ID, so this is value
>>>> treated as invalid.
>>>
>>> This is because the code branches on non-zero value in the cookie,
>>> else uses ts_key. Please make this explicit. Or perhaps better, add a
>>> bit in the cookie so that the full 32-bit space can be used.
>>
>> Adding a bit in the cookie is not enough, I have to add another flag to
>> inet_cork. And we are running out of space for tx flags,
>> inet_cork::tx_flags is u8 and we have only 1 bit left for SKBTX* enum.
>> Do you think it's OK to use this last bit for OPT_ID feature?
> 
> No, that space is particularly constrained in skb_shinfo.
> 
> Either a separate bit in inet_cork, or just keep as is.

Ok, got it. I'll add IPCORK_TS_OPT_ID flag then. Thanks!