[PATCH net] selftests: forwarding: local_termination: fix PTP UDP cksums

Daniel Golle posted 1 patch 1 week, 6 days ago
.../selftests/net/forwarding/local_termination.sh    | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[PATCH net] selftests: forwarding: local_termination: fix PTP UDP cksums
Posted by Daniel Golle 1 week, 6 days ago
All six PTP-over-IP test frames (3x IPv4 + 3x IPv6) contain incorrect
UDP checksums. The stored values are the ones-complement sums of just
the pseudo-headers, not the complete UDP checksums over pseudo-header +
UDP header + payload. This is characteristic of frames captured on the
sender before TX checksum offload completion.

For example, the IPv4 Sync and Follow-Up frames both store checksum
0xa3c8 despite having different UDP payloads and port numbers - 0xa3c8
is their shared pseudo-header sum (same src/dst IP, same protocol and
UDP length).

While most L2 switches forward frames without verifying transport
checksums, hardware that performs deep packet inspection or has PTP
awareness may validate UDP checksums and drop frames that fail
verification. This causes the 1588v2 over IPv4/IPv6 tests to fail on
such hardware even though L2 PTP (which has no UDP checksum) passes
fine.

Replace all six pseudo-header partial sums with the correctly computed
full UDP checksums:

  IPv4 Sync:           0xa3c8 -> 0x9f41
  IPv4 Follow-Up:      0xa3c8 -> 0xeb8a
  IPv4 Peer Delay Req: 0xa2bc -> 0x9ab9
  IPv6 Sync:           0x2e92 -> 0x1476
  IPv6 Follow-Up:      0x2e92 -> 0xf047
  IPv6 Peer Delay Req: 0xb454 -> 0x891f

Fixes: 2379795042649 ("selftests: net: local_termination: add PTP frames to the mix")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 .../selftests/net/forwarding/local_termination.sh    | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh
index 9bc9d25e71368..15b1a1255a41f 100755
--- a/tools/testing/selftests/net/forwarding/local_termination.sh
+++ b/tools/testing/selftests/net/forwarding/local_termination.sh
@@ -57,21 +57,21 @@ PTP_1588_L2_PDELAY_REQ=" \
 PTP_1588_IPV4_SYNC=" \
 01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
 00 48 0a 9a 40 00 01 11 cb 88 c0 00 02 01 e0 00 \
-01 81 01 3f 01 3f 00 34 a3 c8 00 02 00 2c 00 00 \
+01 81 01 3f 01 3f 00 34 9f 41 00 02 00 2c 00 00 \
 02 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
 63 ff fe cf 17 0e 00 01 00 00 00 00 00 00 00 00 \
 00 00 00 00 00 00"
 PTP_1588_IPV4_FOLLOW_UP="
 01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
 00 48 0a 9b 40 00 01 11 cb 87 c0 00 02 01 e0 00 \
-01 81 01 40 01 40 00 34 a3 c8 08 02 00 2c 00 00 \
+01 81 01 40 01 40 00 34 eb 8a 08 02 00 2c 00 00 \
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
 63 ff fe cf 17 0e 00 01 00 00 02 00 00 00 66 83 \
 c6 0f 1d 9a 61 87"
 PTP_1588_IPV4_PDELAY_REQ=" \
 01:00:5e:00:00:6b 00:00:de:ad:be:ef 08:00 45 00 \
 00 52 35 a9 40 00 01 11 a1 85 c0 00 02 01 e0 00 \
-00 6b 01 3f 01 3f 00 3e a2 bc 02 02 00 36 00 00 \
+00 6b 01 3f 01 3f 00 3e 9a b9 02 02 00 36 00 00 \
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
 63 ff fe cf 17 0e 00 01 00 01 05 7f 00 00 00 00 \
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
@@ -79,7 +79,7 @@ PTP_1588_IPV6_SYNC=" \
 33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 06 \
 7c 2f 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
 00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
-00 00 00 00 01 81 01 3f 01 3f 00 36 2e 92 00 02 \
+00 00 00 00 01 81 01 3f 01 3f 00 36 14 76 00 02 \
 00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \
 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \
 00 00 00 00 00 00 00 00 00 00 00 00"
@@ -87,7 +87,7 @@ PTP_1588_IPV6_FOLLOW_UP=" \
 33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 0a \
 00 bc 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
 00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
-00 00 00 00 01 81 01 40 01 40 00 36 2e 92 08 02 \
+00 00 00 00 01 81 01 40 01 40 00 36 f0 47 08 02 \
 00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \
 00 00 66 83 c6 2a 32 09 bd 74 00 00"
@@ -95,7 +95,7 @@ PTP_1588_IPV6_PDELAY_REQ=" \
 33:33:00:00:00:6b 00:00:de:ad:be:ef 86:dd 60 0c \
 5c fd 00 40 11 01 fe 80 00 00 00 00 00 00 3c 37 \
 63 ff fe cf 17 0e ff 02 00 00 00 00 00 00 00 00 \
-00 00 00 00 00 6b 01 3f 01 3f 00 40 b4 54 02 02 \
+00 00 00 00 00 6b 01 3f 01 3f 00 40 89 1f 02 02 \
 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 01 05 7f \
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
-- 
2.53.0
Re: [PATCH net] selftests: forwarding: local_termination: fix PTP UDP cksums
Posted by Alexander Sverdlin 1 week, 6 days ago
Hi Daniel,

On Sat, 2026-03-21 at 04:26 +0000, Daniel Golle wrote:
> All six PTP-over-IP test frames (3x IPv4 + 3x IPv6) contain incorrect
> UDP checksums. The stored values are the ones-complement sums of just
> the pseudo-headers, not the complete UDP checksums over pseudo-header +
> UDP header + payload. This is characteristic of frames captured on the
> sender before TX checksum offload completion.
> 
> For example, the IPv4 Sync and Follow-Up frames both store checksum
> 0xa3c8 despite having different UDP payloads and port numbers - 0xa3c8
> is their shared pseudo-header sum (same src/dst IP, same protocol and
> UDP length).
> 
> While most L2 switches forward frames without verifying transport
> checksums, hardware that performs deep packet inspection or has PTP
> awareness may validate UDP checksums and drop frames that fail
> verification. This causes the 1588v2 over IPv4/IPv6 tests to fail on
> such hardware even though L2 PTP (which has no UDP checksum) passes
> fine.
> 
> Replace all six pseudo-header partial sums with the correctly computed
> full UDP checksums:
> 
>   IPv4 Sync:           0xa3c8 -> 0x9f41
>   IPv4 Follow-Up:      0xa3c8 -> 0xeb8a
>   IPv4 Peer Delay Req: 0xa2bc -> 0x9ab9
>   IPv6 Sync:           0x2e92 -> 0x1476
>   IPv6 Follow-Up:      0x2e92 -> 0xf047
>   IPv6 Peer Delay Req: 0xb454 -> 0x891f
> 
> Fixes: 2379795042649 ("selftests: net: local_termination: add PTP frames to the mix")
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

wireshark agrees,

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>

> ---
>  .../selftests/net/forwarding/local_termination.sh    | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh
> index 9bc9d25e71368..15b1a1255a41f 100755
> --- a/tools/testing/selftests/net/forwarding/local_termination.sh
> +++ b/tools/testing/selftests/net/forwarding/local_termination.sh
> @@ -57,21 +57,21 @@ PTP_1588_L2_PDELAY_REQ=" \
>  PTP_1588_IPV4_SYNC=" \
>  01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
>  00 48 0a 9a 40 00 01 11 cb 88 c0 00 02 01 e0 00 \
> -01 81 01 3f 01 3f 00 34 a3 c8 00 02 00 2c 00 00 \
> +01 81 01 3f 01 3f 00 34 9f 41 00 02 00 2c 00 00 \
>  02 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
>  63 ff fe cf 17 0e 00 01 00 00 00 00 00 00 00 00 \
>  00 00 00 00 00 00"
>  PTP_1588_IPV4_FOLLOW_UP="
>  01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
>  00 48 0a 9b 40 00 01 11 cb 87 c0 00 02 01 e0 00 \
> -01 81 01 40 01 40 00 34 a3 c8 08 02 00 2c 00 00 \
> +01 81 01 40 01 40 00 34 eb 8a 08 02 00 2c 00 00 \
>  00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
>  63 ff fe cf 17 0e 00 01 00 00 02 00 00 00 66 83 \
>  c6 0f 1d 9a 61 87"
>  PTP_1588_IPV4_PDELAY_REQ=" \
>  01:00:5e:00:00:6b 00:00:de:ad:be:ef 08:00 45 00 \
>  00 52 35 a9 40 00 01 11 a1 85 c0 00 02 01 e0 00 \
> -00 6b 01 3f 01 3f 00 3e a2 bc 02 02 00 36 00 00 \
> +00 6b 01 3f 01 3f 00 3e 9a b9 02 02 00 36 00 00 \
>  00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
>  63 ff fe cf 17 0e 00 01 00 01 05 7f 00 00 00 00 \
>  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
> @@ -79,7 +79,7 @@ PTP_1588_IPV6_SYNC=" \
>  33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 06 \
>  7c 2f 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
>  00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
> -00 00 00 00 01 81 01 3f 01 3f 00 36 2e 92 00 02 \
> +00 00 00 00 01 81 01 3f 01 3f 00 36 14 76 00 02 \
>  00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \
>  00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \
>  00 00 00 00 00 00 00 00 00 00 00 00"
> @@ -87,7 +87,7 @@ PTP_1588_IPV6_FOLLOW_UP=" \
>  33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 0a \
>  00 bc 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
>  00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
> -00 00 00 00 01 81 01 40 01 40 00 36 2e 92 08 02 \
> +00 00 00 00 01 81 01 40 01 40 00 36 f0 47 08 02 \
>  00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
>  00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \
>  00 00 66 83 c6 2a 32 09 bd 74 00 00"
> @@ -95,7 +95,7 @@ PTP_1588_IPV6_PDELAY_REQ=" \
>  33:33:00:00:00:6b 00:00:de:ad:be:ef 86:dd 60 0c \
>  5c fd 00 40 11 01 fe 80 00 00 00 00 00 00 3c 37 \
>  63 ff fe cf 17 0e ff 02 00 00 00 00 00 00 00 00 \
> -00 00 00 00 00 6b 01 3f 01 3f 00 40 b4 54 02 02 \
> +00 00 00 00 00 6b 01 3f 01 3f 00 40 89 1f 02 02 \
>  00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
>  00 00 3e 37 63 ff fe cf 17 0e 00 01 00 01 05 7f \
>  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \

-- 
Alexander Sverdlin.