[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a3dd325c-a9f8-4146-8cfe-12e506cbf225@quicinc.com>
Date: Fri, 3 May 2024 15:14:57 -0700
From: "Abhishek Chauhan (ABC)" <quic_abchauha@...cinc.com>
To: Martin KaFai Lau <martin.lau@...ux.dev>
CC: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni
<pabeni@...hat.com>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, Andrew Halaney <ahalaney@...hat.com>,
"Willem
de Bruijn" <willemdebruijn.kernel@...il.com>,
Martin KaFai Lau
<martin.lau@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, bpf
<bpf@...r.kernel.org>,
<kernel@...cinc.com>
Subject: Re: [RFC PATCH bpf-next v5 2/2] net: Add additional bit to support
clockid_t timestamp type
On 5/3/2024 2:41 PM, Martin KaFai Lau wrote:
> On 5/3/24 2:33 PM, Abhishek Chauhan (ABC) wrote:
>>
>>> BPF_CALL_3(bpf_skb_set_tstamp, struct sk_buff *, skb,
>>> u64, tstamp, u32, tstamp_type)
>>> {
>>> /* ... */
>>> case BPF_SKB_CLOCK_TAI:
>>> if (!tstamp)
>>> return -EINVAL;
>>> skb->tstamp = tstamp;
>>> skb->tstamp_type = SKB_CLOCK_TAI;
>>> break;
>>> case BPF_SKB_CLOCK_REALTIME:
>>> skb->tstamp = tstamp;
>>> skb->tstamp_type = SKB_CLOCK_REALTIME;
>>> break;
>>>
>>> /* ... */
>>> }
>>>
>>>> return -EINVAL;
>>>
>>>> @@ -9388,17 +9394,17 @@ static struct bpf_insn *bpf_convert_tstamp_type_read(const struct bpf_insn *si,
>>>> {
>>>> __u8 value_reg = si->dst_reg;
>>>> __u8 skb_reg = si->src_reg;
>>>> - /* AX is needed because src_reg and dst_reg could be the same */
>>>> - __u8 tmp_reg = BPF_REG_AX;
>>>> -
>>>> - *insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg,
>>>> - SKB_BF_MONO_TC_OFFSET);
>>>> - *insn++ = BPF_JMP32_IMM(BPF_JSET, tmp_reg,
>>>> - SKB_MONO_DELIVERY_TIME_MASK, 2);
>>>> - *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_UNSPEC);
>>>> - *insn++ = BPF_JMP_A(1);
>>>> - *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_DELIVERY_MONO);
>>>> -
>>>> + BUILD_BUG_ON(__SKB_CLOCK_MAX != BPF_SKB_TSTAMP_DELIVERY_TAI);
>>>
>>> Add these also:
>>>
>>> BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME);
>>> BUILD_BUG_ON(SKB_CLOCK_MONOTONIC != BPF_SKB_CLOCK_MONOTONIC);
>>> BUILD_BUG_ON(SKB_CLOCK_TAI != BPF_SKB_CLOCK_TAI);
>>>
>>
>> Martin, The above suggestion of adding BUILD_BUG_ON always gives me a warning stating the following.
>>
>> Some systems considers warning as error if compiler flags are enabled. I believe this requires your suggestion before i raise RFC v6 patchset to either keep the
>> BUILD_BUG_ON or remove it completely.
>
> cast it?
>
Thanks Martin. Will do the same. Casting worked for me!.
>>
>> /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9395:34: warning: comparison between ‘enum skb_tstamp_type’ and ‘enum <anonymous>’ [-Wenum-compare]
>> 9395 | BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME);
>> | ^~
>> /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:451:9: note: in definition of macro ‘__compiletime_assert’
>> 451 | if (!(condition)) \
>> | ^~~~~~~~~
>> /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:471:2: note: in expansion of macro ‘_compiletime_assert’
>> 471 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> | ^~~~~~~~~~~~~~~~~~~
>> /local/mnt/workspace/kernel_master/linux-next/include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
>> 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>> | ^~~~~~~~~~~~~~~~~~
>> /local/mnt/workspace/kernel_master/linux-next/include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
>> 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>> | ^~~~~~~~~~~~~~~~
>> /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9395:2: note: in expansion of macro ‘BUILD_BUG_ON’
>> 9395 | BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME);
>> | ^~~~~~~~~~~~
>> /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9396:35: warning: comparison between ‘enum skb_tstamp_type’ and ‘enum <anonymous>’ [-Wenum-compare]
>> 9396 | BUILD_BUG_ON(SKB_CLOCK_MONOTONIC != BPF_SKB_CLOCK_MONOTONIC);
>> | ^~
>> /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:451:9: note: in definition of macro ‘__compiletime_assert’
>> 451 | if (!(condition)) \
>> | ^~~~~~~~~
>>
>> | ^~
>>
>>
>>
>
Powered by blists - more mailing lists