From 414df2de115d43374e73ef0bc522e0abd65aa20c Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Thu, 8 Aug 2024 16:19:17 -0700 Subject: [PATCH] Add a panic that prints information about the sender before calling splitSeg. It helps to know why splitSeg panics with a negative value. PiperOrigin-RevId: 661021651 --- pkg/tcpip/transport/tcp/snd.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/tcpip/transport/tcp/snd.go b/pkg/tcpip/transport/tcp/snd.go index 1e20ac2c3..eb5beea04 100644 --- a/pkg/tcpip/transport/tcp/snd.go +++ b/pkg/tcpip/transport/tcp/snd.go @@ -905,6 +905,11 @@ func (s *sender) maybeSendSegment(seg *segment, limit int, end seqnum.Value) (se if seg.payloadSize() > available { // A negative value causes splitSeg to panic anyways, so just panic // earlier to get more information about the cause. + // TOOD(b/357457079): Remove this panic once the cause of negative values + // of "available" is understood. + if available < 0 { + panic(fmt.Sprintf("got available=%d, want available>=0. limit %d, s.MaxPayloadSize %d, seg.payloadSize() %d, gso.MaxSize %d, gso.MSS %d", available, limit, s.MaxPayloadSize, seg.payloadSize(), s.ep.gso.MaxSize, s.ep.gso.MSS)) + } s.splitSeg(seg, available) }