On Sun, Mar 29, 2026 at 03:31:30PM -0700, Jakub Kicinski wrote:
> On Thu, 26 Mar 2026 16:52:31 -0700 Joe Damato wrote:
> > Add a simple test for USO. Can be used with netdevsim or real hardware.
> > Tests both ipv4 and ipv6 with several full segments and a partial
> > segment.
>
>
> > +def _test_uso(cfg, ipver, mss, total_payload):
> > + cfg.require_ipver(ipver)
> > +
> > + try:
> > + ethtool(f"-K {cfg.ifname} tx-udp-segmentation on")
> > + except Exception as exc:
> > + raise KsftSkipEx(
> > + "Device does not support tx-udp-segmentation") from exc
> > + defer(ethtool, f"-K {cfg.ifname} tx-udp-segmentation off")
>
> If may have been on already when we started, no?
Right, yea. I'll fix it. Is there a helper that does this generically for any
features, by any chance?
> > + expected_segs = (total_payload + mss - 1) // mss
> > +
> > + rx_before = _get_rx_packets(cfg)
>
> Let's run a little program on the remote that receives the packets
> and validates they were correct? Maybe socat can do?
Sure, I can do that in the v7.
> > + port = rand_port(stype=socket.SOCK_DGRAM)
> > + _send_uso(cfg, ipver, mss, total_payload, port)
> > +
> > + time.sleep(0.5)
>
> What's this? Did you mean to wait for stats to settle?
> cfg.wait_hw_stats_settle()
Yea. cfg.wait_hw_stats_settle is clearly better, thanks.
> > + rx_after = _get_rx_packets(cfg)
> > + rx_delta = rx_after - rx_before
>
> Instead of checking Rx (which is probably fine) we may want to check Tx
> has the right number of frames. Sender may have mis-counted the whole
> USO as one packet if it's buggy?
Sure.
> > + ksft_ge(rx_delta, expected_segs,
> > + comment=f"Expected >= {expected_segs} rx packets, got
> > {rx_delta}")
> > +
> > +
> > +def test_uso_v4(cfg):
> > + """USO IPv4: 11 segments (10 full + 1 partial)."""
> > + _test_uso(cfg, "4", 1400, 1400 * 10 + 500)
> > +
> > +
> > +def test_uso_v6(cfg):
> > + """USO IPv6: 11 segments (10 full + 1 partial)."""
> > + _test_uso(cfg, "6", 1400, 1400 * 10 + 500)
> > +
> > +
> > +def test_uso_v4_exact(cfg):
> > + """USO IPv4: exact multiple of MSS (5 full segments)."""
> > + _test_uso(cfg, "4", 1400, 1400 * 5)
>
> Variants are probably a good fit here.
Is the right way to do this by using test_builder?