From 8282a629e5df5161105f155d878c854063e3fe6f Mon Sep 17 00:00:00 2001 From: JackDoan Date: Wed, 29 Apr 2026 12:50:02 -0500 Subject: [PATCH] robot fixes --- overlay/batch/tcp_coalesce_test.go | 21 +++++++++++++++------ overlay/tio/tio_gso_linux.go | 2 +- overlay/tio/tun_linux_offload_test.go | 2 -- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/overlay/batch/tcp_coalesce_test.go b/overlay/batch/tcp_coalesce_test.go index ddcf6770..8bf47900 100644 --- a/overlay/batch/tcp_coalesce_test.go +++ b/overlay/batch/tcp_coalesce_test.go @@ -6,14 +6,17 @@ import ( ) // fakeTunWriter records plain Writes and WriteGSO calls without touching a -// real TUN fd. WriteGSO preserves the split between hdr and borrowed pays -// so tests can inspect each independently. +// real TUN fd. WriteGSO records the IP header, transport header, and +// borrowed payload fragments separately so tests can inspect each. type fakeTunWriter struct { gsoEnabled bool writes [][]byte gsoWrites []fakeGSOWrite } +// fakeGSOWrite captures one WriteGSO call. hdr is the concatenation of the +// IP and transport headers (in that order), gsoSize / isV6 / csumStart are +// derived from the call so existing assertions keep working unchanged. type fakeGSOWrite struct { hdr []byte pays [][]byte @@ -47,21 +50,27 @@ func (w *fakeTunWriter) Write(p []byte) (int, error) { return len(p), nil } -func (w *fakeTunWriter) WriteGSO(hdr []byte, pays [][]byte, gsoSize uint16, isV6 bool, csumStart uint16) error { - hcopy := make([]byte, len(hdr)) +func (w *fakeTunWriter) WriteGSO(hdr []byte, transportHdr []byte, pays [][]byte) error { + hcopy := make([]byte, len(hdr)+len(transportHdr)) copy(hcopy, hdr) + copy(hcopy[len(hdr):], transportHdr) paysCopy := make([][]byte, len(pays)) for i, p := range pays { pc := make([]byte, len(p)) copy(pc, p) paysCopy[i] = pc } + var gsoSize uint16 + if len(pays) > 1 { + gsoSize = uint16(len(pays[0])) + } + isV6 := len(hdr) > 0 && hdr[0]>>4 == 6 w.gsoWrites = append(w.gsoWrites, fakeGSOWrite{ hdr: hcopy, pays: paysCopy, gsoSize: gsoSize, isV6: isV6, - csumStart: csumStart, + csumStart: uint16(len(hdr)), }) return nil } @@ -502,7 +511,7 @@ func (w *orderedFakeWriter) Write(p []byte) (int, error) { return len(p), nil } -func (w *orderedFakeWriter) WriteGSO(hdr []byte, pays [][]byte, gsoSize uint16, isV6 bool, csumStart uint16) error { +func (w *orderedFakeWriter) WriteGSO(hdr []byte, transportHdr []byte, pays [][]byte) error { w.events = append(w.events, "gso") return nil } diff --git a/overlay/tio/tio_gso_linux.go b/overlay/tio/tio_gso_linux.go index fcc1f231..1a2780c7 100644 --- a/overlay/tio/tio_gso_linux.go +++ b/overlay/tio/tio_gso_linux.go @@ -34,7 +34,7 @@ const gsoInitialPayIovs = 66 // validVnetHdr is the 10-byte virtio_net_hdr we prepend to every non-GSO TUN // write. Only flag set is VIRTIO_NET_HDR_F_DATA_VALID, which marks the skb -// CHECKSUM_UNNECESSARY so the receiving network stack skips L4 checksum +// CHECKSUM_UNNECESSARY so the receiving network stack skips L4 checks // verification. All packets that reach the plain Write / WriteFromSelf paths // already carry a valid L4 checksum (either supplied by a remote peer whose // ciphertext we AEAD-authenticated, or produced by finishChecksum during TSO diff --git a/overlay/tio/tun_linux_offload_test.go b/overlay/tio/tun_linux_offload_test.go index 20ca9cd9..a5ae1856 100644 --- a/overlay/tio/tun_linux_offload_test.go +++ b/overlay/tio/tun_linux_offload_test.go @@ -310,8 +310,6 @@ func TestTunFileWriteVnetHdrNoAlloc(t *testing.T) { t.Cleanup(func() { _ = unix.Close(fd) }) tf := &Offload{fd: fd} - tf.writeIovs[0].Base = &validVnetHdr[0] - tf.writeIovs[0].SetLen(virtioNetHdrLen) payload := make([]byte, 1400) // Warm up (first call may trigger one-time internal allocations elsewhere).