Subject: Re: [PATCH v6 net-next 3/3] selftests:net: Implement ptp4l sync test using netdevsim

From: Jakub Kicinski <[email-masked]>
Date: Mon, 18 May 2026 17:42:09 -0700

On Wed, 13 May 2026 11:45:20 +0200 Maciek Machnikowski wrote:
> Add PTP synchronization test using ptp4l and netdevsim.
> 
> The test creates two netdevsim adapters, links them together
> and runs the ptp4l leader and ptp4l follower on two ends
> of the netdevsim link and waits for the follower to report the
> synchronized state (s2) in its output log.
> 
> This implementation runs the test runs over IPv4 link.

> @@ -135,3 +135,4 @@ CONFIG_VLAN_8021Q=y
>  CONFIG_VXLAN=m
>  CONFIG_XFRM_INTERFACE=m
>  CONFIG_XFRM_USER=m
> +CONFIG_PTP_1588_CLOCK_MOCK=y

config needs to be sorted too

> diff --git a/tools/testing/selftests/net/ptp.py b/tools/testing/selftests/net/ptp.py
> new file mode 100755
> index 000000000000..dd6f12cf3d91
> --- /dev/null
> +++ b/tools/testing/selftests/net/ptp.py
> @@ -0,0 +1,184 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# By Maciek Machnikowski <[email-masked]> (c) 2026,
> +#
> +# Self-tests for HW timestamping and 1588 synchronization
> +#
> +# This test runs a ptp4l leader/follower pair and waits for follower sync
> +# state (s2), using one common execution path.
> +#
> +# By default, it:
> +# - Creates two netdevsim instances in separate namespaces
> +# - Assigns IPv4 addresses and links them together
> +# - Uses those interfaces as leader/follower endpoints for ptp4l
> +# Optional: --leader and --follower override endpoints with existing
> +# interfaces. Each argument can be either "ifname" (initial netns) or
> +# "netns:ifname". Both options must be provided together.

Please use the existing DrvEpEnv infra!?

> +import os
> +import shutil
> +import subprocess

And existing helpers from net/lib/py

There's a bunch of legit-looking pylint warnings, too.
The expectation is that the warnings levels higher than R should be
addressed, but the Rs here also seem legit