diff mbox series

[RFC,bpf-next,v6,3/3] selftests/bpf: Handle forwarding of UDP CLOCK_TAI packets

Message ID 20240504031331.2737365-4-quic_abchauha@quicinc.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series Replace mono_delivery_time with tstamp_type | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_maps, false, 360) / test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-42 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17 and -O2 optimization
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 fail Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 fail Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-31 fail Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-32 fail Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-38 fail Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-39 fail Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-40 fail Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-7 fail Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 fail Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for bpf-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 2 this patch: 1
netdev/cc_maintainers warning 14 maintainers not CCed: kpsingh@kernel.org john.fastabend@gmail.com andrii@kernel.org shuah@kernel.org jolsa@kernel.org eddyz87@gmail.com yonghong.song@linux.dev song@kernel.org houtao1@huawei.com linux-kselftest@vger.kernel.org mykolal@fb.com ast@kernel.org haoluo@google.com sdf@google.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Abhishek Chauhan (ABC) May 4, 2024, 3:13 a.m. UTC
With changes in the design to forward CLOCK_TAI in the skbuff
framework,  existing selftest framework needs modification
to handle forwarding of UDP packets with CLOCK_TAI as clockid.

Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
---
 tools/include/uapi/linux/bpf.h                | 15 ++++---
 .../selftests/bpf/prog_tests/ctx_rewrite.c    | 10 +++--
 .../selftests/bpf/prog_tests/tc_redirect.c    |  3 --
 .../selftests/bpf/progs/test_tc_dtime.c       | 39 +++++++++----------
 4 files changed, 34 insertions(+), 33 deletions(-)

Comments

Willem de Bruijn May 6, 2024, 7:04 p.m. UTC | #1
Abhishek Chauhan wrote:
> With changes in the design to forward CLOCK_TAI in the skbuff
> framework,  existing selftest framework needs modification
> to handle forwarding of UDP packets with CLOCK_TAI as clockid.
> 
> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
> Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
> ---
>  tools/include/uapi/linux/bpf.h                | 15 ++++---
>  .../selftests/bpf/prog_tests/ctx_rewrite.c    | 10 +++--
>  .../selftests/bpf/prog_tests/tc_redirect.c    |  3 --
>  .../selftests/bpf/progs/test_tc_dtime.c       | 39 +++++++++----------
>  4 files changed, 34 insertions(+), 33 deletions(-)
> 
> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> index 90706a47f6ff..25ea393cf084 100644
> --- a/tools/include/uapi/linux/bpf.h
> +++ b/tools/include/uapi/linux/bpf.h
> @@ -6207,12 +6207,17 @@ union {					\
>  	__u64 :64;			\
>  } __attribute__((aligned(8)))
>  
> +/* The enum used in skb->tstamp_type. It specifies the clock type
> + * of the time stored in the skb->tstamp.
> + */
>  enum {
> -	BPF_SKB_TSTAMP_UNSPEC,
> -	BPF_SKB_TSTAMP_DELIVERY_MONO,	/* tstamp has mono delivery time */
> -	/* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
> -	 * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
> -	 * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
> +	BPF_SKB_TSTAMP_UNSPEC = 0,		/* DEPRECATED */
> +	BPF_SKB_TSTAMP_DELIVERY_MONO = 1,	/* DEPRECATED */
> +	BPF_SKB_CLOCK_REALTIME = 0,
> +	BPF_SKB_CLOCK_MONOTONIC = 1,
> +	BPF_SKB_CLOCK_TAI = 2,
> +	/* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
> +	 * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
>  	 */
>  };
>  
> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
> index 3b7c57fe55a5..71940f4ef0fb 100644
> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = {
>  	{
>  		N(SCHED_CLS, struct __sk_buff, tstamp),
>  		.read  = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
> -			 "w11 &= 3;"
> -			 "if w11 != 0x3 goto pc+2;"
> +			 "if w11 == 0x4 goto pc+1;"
> +			 "goto pc+4;"
> +			 "if w11 == 0x3 goto pc+1;"
> +			 "goto pc+2;"

Not an expert on this code, and I see that the existing code already
has this below, but: isn't it odd and unnecessary to jump to an
unconditional jump statement?

>  			 "$dst = 0;"
>  			 "goto pc+1;"
>  			 "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
>  		.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
> -			 "if w11 & 0x2 goto pc+1;"
> +			 "if w11 & 0x4 goto pc+1;"
>  			 "goto pc+2;"
> -			 "w11 &= -2;"
> +			 "w11 &= -3;"
>  			 "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
>  			 "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
>  	},
Abhishek Chauhan (ABC) May 6, 2024, 8:50 p.m. UTC | #2
On 5/6/2024 12:04 PM, Willem de Bruijn wrote:
> Abhishek Chauhan wrote:
>> With changes in the design to forward CLOCK_TAI in the skbuff
>> framework,  existing selftest framework needs modification
>> to handle forwarding of UDP packets with CLOCK_TAI as clockid.
>>
>> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
>> Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
>> ---
>>  tools/include/uapi/linux/bpf.h                | 15 ++++---
>>  .../selftests/bpf/prog_tests/ctx_rewrite.c    | 10 +++--
>>  .../selftests/bpf/prog_tests/tc_redirect.c    |  3 --
>>  .../selftests/bpf/progs/test_tc_dtime.c       | 39 +++++++++----------
>>  4 files changed, 34 insertions(+), 33 deletions(-)
>>
>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>> index 90706a47f6ff..25ea393cf084 100644
>> --- a/tools/include/uapi/linux/bpf.h
>> +++ b/tools/include/uapi/linux/bpf.h
>> @@ -6207,12 +6207,17 @@ union {					\
>>  	__u64 :64;			\
>>  } __attribute__((aligned(8)))
>>  
>> +/* The enum used in skb->tstamp_type. It specifies the clock type
>> + * of the time stored in the skb->tstamp.
>> + */
>>  enum {
>> -	BPF_SKB_TSTAMP_UNSPEC,
>> -	BPF_SKB_TSTAMP_DELIVERY_MONO,	/* tstamp has mono delivery time */
>> -	/* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
>> -	 * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
>> -	 * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
>> +	BPF_SKB_TSTAMP_UNSPEC = 0,		/* DEPRECATED */
>> +	BPF_SKB_TSTAMP_DELIVERY_MONO = 1,	/* DEPRECATED */
>> +	BPF_SKB_CLOCK_REALTIME = 0,
>> +	BPF_SKB_CLOCK_MONOTONIC = 1,
>> +	BPF_SKB_CLOCK_TAI = 2,
>> +	/* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
>> +	 * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
>>  	 */
>>  };
>>  
>> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>> index 3b7c57fe55a5..71940f4ef0fb 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = {
>>  	{
>>  		N(SCHED_CLS, struct __sk_buff, tstamp),
>>  		.read  = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>> -			 "w11 &= 3;"
>> -			 "if w11 != 0x3 goto pc+2;"
>> +			 "if w11 == 0x4 goto pc+1;"
>> +			 "goto pc+4;"
>> +			 "if w11 == 0x3 goto pc+1;"
>> +			 "goto pc+2;"
> 
> Not an expert on this code, and I see that the existing code already
> has this below, but: isn't it odd and unnecessary to jump to an
> unconditional jump statement?
> 
I am closely looking into your comment and i will evalute it(Martin can correct me 
if the jumps are correct or not as i am new to BPF as well) but i found out that 
JSET = "&" and not "==". So the above two ins has to change from -   

"if w11 == 0x4 goto pc+1;" ==>(needs to be corrected to) "if w11 & 0x4 goto pc+1;" 
 "if w11 == 0x3 goto pc+1;" ==> (needs to be correct to) "if w11 & 0x3 goto pc+1;"


>>  			 "$dst = 0;"
>>  			 "goto pc+1;"
>>  			 "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
>>  		.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>> -			 "if w11 & 0x2 goto pc+1;"
>> +			 "if w11 & 0x4 goto pc+1;"
>>  			 "goto pc+2;"
>> -			 "w11 &= -2;"
>> +			 "w11 &= -3;"
Martin, 
Also i am not sure why the the dissembly complains because the value of SKB_TSTAMP_TYPE_MASK = 3 and we are 
negating it ~3 = -3. 

  Can't match disassembly(left) with pattern(right):
  r11 = *(u8 *)(r1 +129)  ;  r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset)
  if w11 & 0x4 goto pc+1  ;  if w11 & 0x4 goto pc+1
  goto pc+2               ;  goto pc+2
  w11 &= -4               ;  w11 &= -3

>>  			 "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
>>  			 "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
>>  	},
Abhishek Chauhan (ABC) May 6, 2024, 8:54 p.m. UTC | #3
On 5/6/2024 1:50 PM, Abhishek Chauhan (ABC) wrote:
> 
> 
> On 5/6/2024 12:04 PM, Willem de Bruijn wrote:
>> Abhishek Chauhan wrote:
>>> With changes in the design to forward CLOCK_TAI in the skbuff
>>> framework,  existing selftest framework needs modification
>>> to handle forwarding of UDP packets with CLOCK_TAI as clockid.
>>>
>>> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
>>> Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
>>> ---
>>>  tools/include/uapi/linux/bpf.h                | 15 ++++---
>>>  .../selftests/bpf/prog_tests/ctx_rewrite.c    | 10 +++--
>>>  .../selftests/bpf/prog_tests/tc_redirect.c    |  3 --
>>>  .../selftests/bpf/progs/test_tc_dtime.c       | 39 +++++++++----------
>>>  4 files changed, 34 insertions(+), 33 deletions(-)
>>>
>>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>>> index 90706a47f6ff..25ea393cf084 100644
>>> --- a/tools/include/uapi/linux/bpf.h
>>> +++ b/tools/include/uapi/linux/bpf.h
>>> @@ -6207,12 +6207,17 @@ union {					\
>>>  	__u64 :64;			\
>>>  } __attribute__((aligned(8)))
>>>  
>>> +/* The enum used in skb->tstamp_type. It specifies the clock type
>>> + * of the time stored in the skb->tstamp.
>>> + */
>>>  enum {
>>> -	BPF_SKB_TSTAMP_UNSPEC,
>>> -	BPF_SKB_TSTAMP_DELIVERY_MONO,	/* tstamp has mono delivery time */
>>> -	/* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
>>> -	 * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
>>> -	 * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
>>> +	BPF_SKB_TSTAMP_UNSPEC = 0,		/* DEPRECATED */
>>> +	BPF_SKB_TSTAMP_DELIVERY_MONO = 1,	/* DEPRECATED */
>>> +	BPF_SKB_CLOCK_REALTIME = 0,
>>> +	BPF_SKB_CLOCK_MONOTONIC = 1,
>>> +	BPF_SKB_CLOCK_TAI = 2,
>>> +	/* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
>>> +	 * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
>>>  	 */
>>>  };
>>>  
>>> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>> index 3b7c57fe55a5..71940f4ef0fb 100644
>>> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = {
>>>  	{
>>>  		N(SCHED_CLS, struct __sk_buff, tstamp),
>>>  		.read  = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>> -			 "w11 &= 3;"
>>> -			 "if w11 != 0x3 goto pc+2;"
>>> +			 "if w11 == 0x4 goto pc+1;"
>>> +			 "goto pc+4;"
>>> +			 "if w11 == 0x3 goto pc+1;"
>>> +			 "goto pc+2;"
>>
>> Not an expert on this code, and I see that the existing code already
>> has this below, but: isn't it odd and unnecessary to jump to an
>> unconditional jump statement?
>>
> I am closely looking into your comment and i will evalute it(Martin can correct me 
> if the jumps are correct or not as i am new to BPF as well) but i found out that 
> JSET = "&" and not "==". So the above two ins has to change from -   
> 
> "if w11 == 0x4 goto pc+1;" ==>(needs to be corrected to) "if w11 & 0x4 goto pc+1;" 
>  "if w11 == 0x3 goto pc+1;" ==> (needs to be correct to) "if w11 & 0x3 goto pc+1;"
> 
> 
>>>  			 "$dst = 0;"
>>>  			 "goto pc+1;"
>>>  			 "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
>>>  		.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>> -			 "if w11 & 0x2 goto pc+1;"
>>> +			 "if w11 & 0x4 goto pc+1;"
>>>  			 "goto pc+2;"
>>> -			 "w11 &= -2;"
>>> +			 "w11 &= -3;"
> Martin, 
> Also i am not sure why the the dissembly complains because the value of SKB_TSTAMP_TYPE_MASK = 3 and we are 
> negating it ~3 = -3. 
> 
>   Can't match disassembly(left) with pattern(right):
>   r11 = *(u8 *)(r1 +129)  ;  r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset)
>   if w11 & 0x4 goto pc+1  ;  if w11 & 0x4 goto pc+1
>   goto pc+2               ;  goto pc+2
>   w11 &= -4               ;  w11 &= -3
> 
Martin, 
Please ignore this. It has to -4 and not -3. I figured it out. 

>>>  			 "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
>>>  			 "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
>>>  	},
Abhishek Chauhan (ABC) May 6, 2024, 11:40 p.m. UTC | #4
On 5/6/2024 1:54 PM, Abhishek Chauhan (ABC) wrote:
> 
> 
> On 5/6/2024 1:50 PM, Abhishek Chauhan (ABC) wrote:
>>
>>
>> On 5/6/2024 12:04 PM, Willem de Bruijn wrote:
>>> Abhishek Chauhan wrote:
>>>> With changes in the design to forward CLOCK_TAI in the skbuff
>>>> framework,  existing selftest framework needs modification
>>>> to handle forwarding of UDP packets with CLOCK_TAI as clockid.
>>>>
>>>> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
>>>> Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
>>>> ---
>>>>  tools/include/uapi/linux/bpf.h                | 15 ++++---
>>>>  .../selftests/bpf/prog_tests/ctx_rewrite.c    | 10 +++--
>>>>  .../selftests/bpf/prog_tests/tc_redirect.c    |  3 --
>>>>  .../selftests/bpf/progs/test_tc_dtime.c       | 39 +++++++++----------
>>>>  4 files changed, 34 insertions(+), 33 deletions(-)
>>>>
>>>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>>>> index 90706a47f6ff..25ea393cf084 100644
>>>> --- a/tools/include/uapi/linux/bpf.h
>>>> +++ b/tools/include/uapi/linux/bpf.h
>>>> @@ -6207,12 +6207,17 @@ union {					\
>>>>  	__u64 :64;			\
>>>>  } __attribute__((aligned(8)))
>>>>  
>>>> +/* The enum used in skb->tstamp_type. It specifies the clock type
>>>> + * of the time stored in the skb->tstamp.
>>>> + */
>>>>  enum {
>>>> -	BPF_SKB_TSTAMP_UNSPEC,
>>>> -	BPF_SKB_TSTAMP_DELIVERY_MONO,	/* tstamp has mono delivery time */
>>>> -	/* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
>>>> -	 * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
>>>> -	 * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
>>>> +	BPF_SKB_TSTAMP_UNSPEC = 0,		/* DEPRECATED */
>>>> +	BPF_SKB_TSTAMP_DELIVERY_MONO = 1,	/* DEPRECATED */
>>>> +	BPF_SKB_CLOCK_REALTIME = 0,
>>>> +	BPF_SKB_CLOCK_MONOTONIC = 1,
>>>> +	BPF_SKB_CLOCK_TAI = 2,
>>>> +	/* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
>>>> +	 * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
>>>>  	 */
>>>>  };
>>>>  
>>>> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> index 3b7c57fe55a5..71940f4ef0fb 100644
>>>> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = {
>>>>  	{
>>>>  		N(SCHED_CLS, struct __sk_buff, tstamp),
>>>>  		.read  = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>>> -			 "w11 &= 3;"
>>>> -			 "if w11 != 0x3 goto pc+2;"
>>>> +			 "if w11 == 0x4 goto pc+1;"
>>>> +			 "goto pc+4;"
>>>> +			 "if w11 == 0x3 goto pc+1;"
>>>> +			 "goto pc+2;"
>>>
>>> Not an expert on this code, and I see that the existing code already
>>> has this below, but: isn't it odd and unnecessary to jump to an
>>> unconditional jump statement?
>>>
>> I am closely looking into your comment and i will evalute it(Martin can correct me 
>> if the jumps are correct or not as i am new to BPF as well) but i found out that 
>> JSET = "&" and not "==". So the above two ins has to change from -   
>>
>> "if w11 == 0x4 goto pc+1;" ==>(needs to be corrected to) "if w11 & 0x4 goto pc+1;" 
>>  "if w11 == 0x3 goto pc+1;" ==> (needs to be correct to) "if w11 & 0x3 goto pc+1;"
>>
>>
Willem, I looked at the jumps in the above code. They look correct to me. 
Martin can check too if i am doing anything wrong here other than the JSET "&".

Ideally pc(program counter) points to the next instruction. 

			 "if w11 & 0x4 goto pc+1;"
			 "goto pc+4;" 
		[pc+0]	 "if w11 & 0x3 goto pc+1;" <== PC is going to be here 
		[pc+1]	 "goto pc+2;"
		[pc+2]	 "$dst = 0;"
		[pc+3]	 "goto pc+1;"
		[pc+4]	 "$dst = *(u64 *)($ctx + sk_buff::tstamp);", <== This is where the code is intended to jump to for "goto pc+4;"



>>>>  			 "$dst = 0;"
>>>>  			 "goto pc+1;"
>>>>  			 "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
>>>>  		.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>>> -			 "if w11 & 0x2 goto pc+1;"
>>>> +			 "if w11 & 0x4 goto pc+1;"
>>>>  			 "goto pc+2;"
>>>> -			 "w11 &= -2;"
>>>> +			 "w11 &= -3;"
Martin KaFai Lau May 7, 2024, 12:54 a.m. UTC | #5
On 5/6/24 1:50 PM, Abhishek Chauhan (ABC) wrote:
> 
> 
> On 5/6/2024 12:04 PM, Willem de Bruijn wrote:
>> Abhishek Chauhan wrote:
>>> With changes in the design to forward CLOCK_TAI in the skbuff
>>> framework,  existing selftest framework needs modification
>>> to handle forwarding of UDP packets with CLOCK_TAI as clockid.
>>>
>>> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
>>> Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
>>> ---
>>>   tools/include/uapi/linux/bpf.h                | 15 ++++---
>>>   .../selftests/bpf/prog_tests/ctx_rewrite.c    | 10 +++--
>>>   .../selftests/bpf/prog_tests/tc_redirect.c    |  3 --
>>>   .../selftests/bpf/progs/test_tc_dtime.c       | 39 +++++++++----------
>>>   4 files changed, 34 insertions(+), 33 deletions(-)
>>>
>>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>>> index 90706a47f6ff..25ea393cf084 100644
>>> --- a/tools/include/uapi/linux/bpf.h
>>> +++ b/tools/include/uapi/linux/bpf.h
>>> @@ -6207,12 +6207,17 @@ union {					\
>>>   	__u64 :64;			\
>>>   } __attribute__((aligned(8)))
>>>   
>>> +/* The enum used in skb->tstamp_type. It specifies the clock type
>>> + * of the time stored in the skb->tstamp.
>>> + */
>>>   enum {
>>> -	BPF_SKB_TSTAMP_UNSPEC,
>>> -	BPF_SKB_TSTAMP_DELIVERY_MONO,	/* tstamp has mono delivery time */
>>> -	/* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
>>> -	 * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
>>> -	 * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
>>> +	BPF_SKB_TSTAMP_UNSPEC = 0,		/* DEPRECATED */
>>> +	BPF_SKB_TSTAMP_DELIVERY_MONO = 1,	/* DEPRECATED */
>>> +	BPF_SKB_CLOCK_REALTIME = 0,
>>> +	BPF_SKB_CLOCK_MONOTONIC = 1,
>>> +	BPF_SKB_CLOCK_TAI = 2,
>>> +	/* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
>>> +	 * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
>>>   	 */
>>>   };
>>>   
>>> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>> index 3b7c57fe55a5..71940f4ef0fb 100644
>>> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = {
>>>   	{
>>>   		N(SCHED_CLS, struct __sk_buff, tstamp),
>>>   		.read  = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>> -			 "w11 &= 3;"
>>> -			 "if w11 != 0x3 goto pc+2;"
>>> +			 "if w11 == 0x4 goto pc+1;"
>>> +			 "goto pc+4;"
>>> +			 "if w11 == 0x3 goto pc+1;"
>>> +			 "goto pc+2;"
>>
>> Not an expert on this code, and I see that the existing code already
>> has this below, but: isn't it odd and unnecessary to jump to an
>> unconditional jump statement?
>>
> I am closely looking into your comment and i will evalute it(Martin can correct me
> if the jumps are correct or not as i am new to BPF as well) but i found out that
> JSET = "&" and not "==". So the above two ins has to change from -

Yes, this should be bitwise "&" instead of "==".

The bpf CI did report this: 
https://github.com/kernel-patches/bpf/actions/runs/8947652196/job/24579927178

Please monitor the bpf CI test result.

Do you have issue running the test locally?

> 
> "if w11 == 0x4 goto pc+1;" ==>(needs to be corrected to) "if w11 & 0x4 goto pc+1;"
>   "if w11 == 0x3 goto pc+1;" ==> (needs to be correct to) "if w11 & 0x3 goto pc+1;"
> 
> 
>>>   			 "$dst = 0;"
>>>   			 "goto pc+1;"
>>>   			 "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
>>>   		.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>> -			 "if w11 & 0x2 goto pc+1;"
>>> +			 "if w11 & 0x4 goto pc+1;"
>>>   			 "goto pc+2;"
>>> -			 "w11 &= -2;"
>>> +			 "w11 &= -3;"
> Martin,
> Also i am not sure why the the dissembly complains because the value of SKB_TSTAMP_TYPE_MASK = 3 and we are
> negating it ~3 = -3.
> 
>    Can't match disassembly(left) with pattern(right):
>    r11 = *(u8 *)(r1 +129)  ;  r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset)
>    if w11 & 0x4 goto pc+1  ;  if w11 & 0x4 goto pc+1
>    goto pc+2               ;  goto pc+2
>    w11 &= -4               ;  w11 &= -3
> 
>>>   			 "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
>>>   			 "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
>>>   	},
Abhishek Chauhan (ABC) May 7, 2024, 7:15 p.m. UTC | #6
On 5/6/2024 5:54 PM, Martin KaFai Lau wrote:
> On 5/6/24 1:50 PM, Abhishek Chauhan (ABC) wrote:
>>
>>
>> On 5/6/2024 12:04 PM, Willem de Bruijn wrote:
>>> Abhishek Chauhan wrote:
>>>> With changes in the design to forward CLOCK_TAI in the skbuff
>>>> framework,  existing selftest framework needs modification
>>>> to handle forwarding of UDP packets with CLOCK_TAI as clockid.
>>>>
>>>> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
>>>> Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
>>>> ---
>>>>   tools/include/uapi/linux/bpf.h                | 15 ++++---
>>>>   .../selftests/bpf/prog_tests/ctx_rewrite.c    | 10 +++--
>>>>   .../selftests/bpf/prog_tests/tc_redirect.c    |  3 --
>>>>   .../selftests/bpf/progs/test_tc_dtime.c       | 39 +++++++++----------
>>>>   4 files changed, 34 insertions(+), 33 deletions(-)
>>>>
>>>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>>>> index 90706a47f6ff..25ea393cf084 100644
>>>> --- a/tools/include/uapi/linux/bpf.h
>>>> +++ b/tools/include/uapi/linux/bpf.h
>>>> @@ -6207,12 +6207,17 @@ union {                    \
>>>>       __u64 :64;            \
>>>>   } __attribute__((aligned(8)))
>>>>   +/* The enum used in skb->tstamp_type. It specifies the clock type
>>>> + * of the time stored in the skb->tstamp.
>>>> + */
>>>>   enum {
>>>> -    BPF_SKB_TSTAMP_UNSPEC,
>>>> -    BPF_SKB_TSTAMP_DELIVERY_MONO,    /* tstamp has mono delivery time */
>>>> -    /* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
>>>> -     * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
>>>> -     * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
>>>> +    BPF_SKB_TSTAMP_UNSPEC = 0,        /* DEPRECATED */
>>>> +    BPF_SKB_TSTAMP_DELIVERY_MONO = 1,    /* DEPRECATED */
>>>> +    BPF_SKB_CLOCK_REALTIME = 0,
>>>> +    BPF_SKB_CLOCK_MONOTONIC = 1,
>>>> +    BPF_SKB_CLOCK_TAI = 2,
>>>> +    /* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
>>>> +     * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
>>>>        */
>>>>   };
>>>>   diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> index 3b7c57fe55a5..71940f4ef0fb 100644
>>>> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = {
>>>>       {
>>>>           N(SCHED_CLS, struct __sk_buff, tstamp),
>>>>           .read  = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>>> -             "w11 &= 3;"
>>>> -             "if w11 != 0x3 goto pc+2;"
>>>> +             "if w11 == 0x4 goto pc+1;"
>>>> +             "goto pc+4;"
>>>> +             "if w11 == 0x3 goto pc+1;"
>>>> +             "goto pc+2;"
>>>
>>> Not an expert on this code, and I see that the existing code already
>>> has this below, but: isn't it odd and unnecessary to jump to an
>>> unconditional jump statement?
>>>
>> I am closely looking into your comment and i will evalute it(Martin can correct me
>> if the jumps are correct or not as i am new to BPF as well) but i found out that
>> JSET = "&" and not "==". So the above two ins has to change from -
> 
> Yes, this should be bitwise "&" instead of "==".
> 
> The bpf CI did report this: https://github.com/kernel-patches/bpf/actions/runs/8947652196/job/24579927178
> 
> Please monitor the bpf CI test result.
> 
> Do you have issue running the test locally?
> 
Yes, To be honest. I am facing compilation issues when i follow the documentation to Make BPF on latest kernel. 

This is slowing down my development with this patch. 

Very similar to the problem described here :- https://github.com/jsitnicki/ebpf-summit-2020/issues/1

local/mnt/workspace/kernel_master/linux-next/tools/testing/selftests/bpf/tools/build/bpftool/bootstrap/libbpf/include/bpf/bpf_core_read.h:379:26: note: expanded from macro '___arrow2'
#define ___arrow2(a, b) a->b
                        ~^
skeleton/pid_iter.bpf.c:19:9: note: forward declaration of 'struct bpf_link'
        struct bpf_link link;
               ^
skeleton/pid_iter.bpf.c:105:7: error: incomplete definition of type 'struct bpf_link'
                if (BPF_CORE_READ(link, type) == bpf_core_enum_value(enum bpf_link_type___local,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~

>>
>> "if w11 == 0x4 goto pc+1;" ==>(needs to be corrected to) "if w11 & 0x4 goto pc+1;"
>>   "if w11 == 0x3 goto pc+1;" ==> (needs to be correct to) "if w11 & 0x3 goto pc+1;"
>>
>>
>>>>                "$dst = 0;"
>>>>                "goto pc+1;"
>>>>                "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
>>>>           .write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>>> -             "if w11 & 0x2 goto pc+1;"
>>>> +             "if w11 & 0x4 goto pc+1;"
>>>>                "goto pc+2;"
>>>> -             "w11 &= -2;"
>>>> +             "w11 &= -3;"
>> Martin,
>> Also i am not sure why the the dissembly complains because the value of SKB_TSTAMP_TYPE_MASK = 3 and we are
>> negating it ~3 = -3.
>>
>>    Can't match disassembly(left) with pattern(right):
>>    r11 = *(u8 *)(r1 +129)  ;  r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset)
>>    if w11 & 0x4 goto pc+1  ;  if w11 & 0x4 goto pc+1
>>    goto pc+2               ;  goto pc+2
>>    w11 &= -4               ;  w11 &= -3
>>
>>>>                "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
>>>>                "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
>>>>       },
>
diff mbox series

Patch

diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 90706a47f6ff..25ea393cf084 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -6207,12 +6207,17 @@  union {					\
 	__u64 :64;			\
 } __attribute__((aligned(8)))
 
+/* The enum used in skb->tstamp_type. It specifies the clock type
+ * of the time stored in the skb->tstamp.
+ */
 enum {
-	BPF_SKB_TSTAMP_UNSPEC,
-	BPF_SKB_TSTAMP_DELIVERY_MONO,	/* tstamp has mono delivery time */
-	/* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
-	 * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
-	 * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
+	BPF_SKB_TSTAMP_UNSPEC = 0,		/* DEPRECATED */
+	BPF_SKB_TSTAMP_DELIVERY_MONO = 1,	/* DEPRECATED */
+	BPF_SKB_CLOCK_REALTIME = 0,
+	BPF_SKB_CLOCK_MONOTONIC = 1,
+	BPF_SKB_CLOCK_TAI = 2,
+	/* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
+	 * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
 	 */
 };
 
diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
index 3b7c57fe55a5..71940f4ef0fb 100644
--- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
+++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
@@ -69,15 +69,17 @@  static struct test_case test_cases[] = {
 	{
 		N(SCHED_CLS, struct __sk_buff, tstamp),
 		.read  = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
-			 "w11 &= 3;"
-			 "if w11 != 0x3 goto pc+2;"
+			 "if w11 == 0x4 goto pc+1;"
+			 "goto pc+4;"
+			 "if w11 == 0x3 goto pc+1;"
+			 "goto pc+2;"
 			 "$dst = 0;"
 			 "goto pc+1;"
 			 "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
 		.write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
-			 "if w11 & 0x2 goto pc+1;"
+			 "if w11 & 0x4 goto pc+1;"
 			 "goto pc+2;"
-			 "w11 &= -2;"
+			 "w11 &= -3;"
 			 "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
 			 "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
 	},
diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
index b1073d36d77a..327d51f59142 100644
--- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
+++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
@@ -890,9 +890,6 @@  static void test_udp_dtime(struct test_tc_dtime *skel, int family, bool bpf_fwd)
 
 	ASSERT_EQ(dtimes[INGRESS_FWDNS_P100], 0,
 		  dtime_cnt_str(t, INGRESS_FWDNS_P100));
-	/* non mono delivery time is not forwarded */
-	ASSERT_EQ(dtimes[INGRESS_FWDNS_P101], 0,
-		  dtime_cnt_str(t, INGRESS_FWDNS_P101));
 	for (i = EGRESS_FWDNS_P100; i < SET_DTIME; i++)
 		ASSERT_GT(dtimes[i], 0, dtime_cnt_str(t, i));
 
diff --git a/tools/testing/selftests/bpf/progs/test_tc_dtime.c b/tools/testing/selftests/bpf/progs/test_tc_dtime.c
index 74ec09f040b7..21f5be202e4b 100644
--- a/tools/testing/selftests/bpf/progs/test_tc_dtime.c
+++ b/tools/testing/selftests/bpf/progs/test_tc_dtime.c
@@ -222,13 +222,19 @@  int egress_host(struct __sk_buff *skb)
 		return TC_ACT_OK;
 
 	if (skb_proto(skb_type) == IPPROTO_TCP) {
-		if (skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_MONO &&
+		if (skb->tstamp_type == BPF_SKB_CLOCK_MONOTONIC &&
+		    skb->tstamp)
+			inc_dtimes(EGRESS_ENDHOST);
+		else
+			inc_errs(EGRESS_ENDHOST);
+	} else if (skb_proto(skb_type) == IPPROTO_UDP) {
+		if (skb->tstamp_type == BPF_SKB_CLOCK_TAI &&
 		    skb->tstamp)
 			inc_dtimes(EGRESS_ENDHOST);
 		else
 			inc_errs(EGRESS_ENDHOST);
 	} else {
-		if (skb->tstamp_type == BPF_SKB_TSTAMP_UNSPEC &&
+		if (skb->tstamp_type == BPF_SKB_CLOCK_REALTIME &&
 		    skb->tstamp)
 			inc_dtimes(EGRESS_ENDHOST);
 		else
@@ -252,7 +258,7 @@  int ingress_host(struct __sk_buff *skb)
 	if (!skb_type)
 		return TC_ACT_OK;
 
-	if (skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_MONO &&
+	if (skb->tstamp_type == BPF_SKB_CLOCK_MONOTONIC &&
 	    skb->tstamp == EGRESS_FWDNS_MAGIC)
 		inc_dtimes(INGRESS_ENDHOST);
 	else
@@ -315,7 +321,6 @@  int egress_fwdns_prio100(struct __sk_buff *skb)
 SEC("tc")
 int ingress_fwdns_prio101(struct __sk_buff *skb)
 {
-	__u64 expected_dtime = EGRESS_ENDHOST_MAGIC;
 	int skb_type;
 
 	skb_type = skb_get_type(skb);
@@ -323,29 +328,24 @@  int ingress_fwdns_prio101(struct __sk_buff *skb)
 		/* Should have handled in prio100 */
 		return TC_ACT_SHOT;
 
-	if (skb_proto(skb_type) == IPPROTO_UDP)
-		expected_dtime = 0;
-
 	if (skb->tstamp_type) {
 		if (fwdns_clear_dtime() ||
-		    skb->tstamp_type != BPF_SKB_TSTAMP_DELIVERY_MONO ||
-		    skb->tstamp != expected_dtime)
+		    (skb->tstamp_type != BPF_SKB_CLOCK_MONOTONIC &&
+		    skb->tstamp_type != BPF_SKB_CLOCK_TAI) ||
+		    skb->tstamp != EGRESS_ENDHOST_MAGIC)
 			inc_errs(INGRESS_FWDNS_P101);
 		else
 			inc_dtimes(INGRESS_FWDNS_P101);
 	} else {
-		if (!fwdns_clear_dtime() && expected_dtime)
+		if (!fwdns_clear_dtime())
 			inc_errs(INGRESS_FWDNS_P101);
 	}
 
-	if (skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_MONO) {
+	if (skb->tstamp_type == BPF_SKB_CLOCK_MONOTONIC) {
 		skb->tstamp = INGRESS_FWDNS_MAGIC;
 	} else {
 		if (bpf_skb_set_tstamp(skb, INGRESS_FWDNS_MAGIC,
-				       BPF_SKB_TSTAMP_DELIVERY_MONO))
-			inc_errs(SET_DTIME);
-		if (!bpf_skb_set_tstamp(skb, INGRESS_FWDNS_MAGIC,
-					BPF_SKB_TSTAMP_UNSPEC))
+				       BPF_SKB_CLOCK_MONOTONIC))
 			inc_errs(SET_DTIME);
 	}
 
@@ -370,7 +370,7 @@  int egress_fwdns_prio101(struct __sk_buff *skb)
 
 	if (skb->tstamp_type) {
 		if (fwdns_clear_dtime() ||
-		    skb->tstamp_type != BPF_SKB_TSTAMP_DELIVERY_MONO ||
+		    skb->tstamp_type != BPF_SKB_CLOCK_MONOTONIC ||
 		    skb->tstamp != INGRESS_FWDNS_MAGIC)
 			inc_errs(EGRESS_FWDNS_P101);
 		else
@@ -380,14 +380,11 @@  int egress_fwdns_prio101(struct __sk_buff *skb)
 			inc_errs(EGRESS_FWDNS_P101);
 	}
 
-	if (skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_MONO) {
+	if (skb->tstamp_type == BPF_SKB_CLOCK_MONOTONIC) {
 		skb->tstamp = EGRESS_FWDNS_MAGIC;
 	} else {
 		if (bpf_skb_set_tstamp(skb, EGRESS_FWDNS_MAGIC,
-				       BPF_SKB_TSTAMP_DELIVERY_MONO))
-			inc_errs(SET_DTIME);
-		if (!bpf_skb_set_tstamp(skb, INGRESS_FWDNS_MAGIC,
-					BPF_SKB_TSTAMP_UNSPEC))
+				       BPF_SKB_CLOCK_MONOTONIC))
 			inc_errs(SET_DTIME);
 	}