Subject: Re: [PATCH net-next v3] selftests/net: convert so_txtime to drv-net

From: Jakub Kicinski <[email-masked]>
Date: Thu, 9 Apr 2026 18:50:07 -0700

On Thu, 09 Apr 2026 11:01:49 -0400 Willem de Bruijn wrote:
> > Alternatively could record the root qdisc at the start of the test and
> > restore that.  
> 
> This should work:
> 
>     def main() -> None:
>         """Boilerplate ksft main."""
>         with NetDrvEpEnv(__file__) as cfg:
>     +        # Record original root qdisc
>     +        cmd_obj = cmd((f"tc -j qdisc show dev {cfg.ifname} root"))
>     +        qdisc_root = json.loads(cmd_obj.stdout)[0].get("kind", None)

I don't like doing setup in main() TBH. It can well fail and no KTAP
will be produced. Breaking all the tracking and stability-based
filtering. Not sure if it's still the case but for a very long time
not all tc qdiscs supported JSON for example.

>     	ksft_run([test_so_txtime_mono, test_so_txtime_etf], args=(cfg,))
>     +
>     +        # Restore original root qdisc. If mq, populate with default_qdisc nodes
>     +        if (qdisc_root):
>     +            cmd(f"tc qdisc replace dev {cfg.ifname} root {qdisc_root}")
>         ksft_exit()
> 
> 
> Do we want to add a tc command similar to ip, bpftool, etc.

Yes, we can wrap it if it outputs json.