From 35227fb84fd0d9a35ece6d43834ce3099d3944fc Mon Sep 17 00:00:00 2001 From: Lucas Manning Date: Thu, 16 Jun 2022 13:33:01 -0700 Subject: [PATCH] Add a panic that prints information about the sender before calling splitSeg. Calling splitSeg with a negative value panics anyway, we need to know why. PiperOrigin-RevId: 455455562 --- pkg/tcpip/transport/tcp/snd.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/tcpip/transport/tcp/snd.go b/pkg/tcpip/transport/tcp/snd.go index e429a7209..99700c2ca 100644 --- a/pkg/tcpip/transport/tcp/snd.go +++ b/pkg/tcpip/transport/tcp/snd.go @@ -859,6 +859,13 @@ 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/236090764): 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) }