From 9e82747d62e57ee7498c8f3f54c313917891273a Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Fri, 6 Nov 2020 13:53:21 -0800 Subject: Return early in walkSACK if segment has no SACK blocks. This avoids a needless allocation. Updates #231 PiperOrigin-RevId: 341113160 --- pkg/tcpip/transport/tcp/snd.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkg/tcpip') diff --git a/pkg/tcpip/transport/tcp/snd.go b/pkg/tcpip/transport/tcp/snd.go index 6fa8d63cd..ab5fa4fb7 100644 --- a/pkg/tcpip/transport/tcp/snd.go +++ b/pkg/tcpip/transport/tcp/snd.go @@ -1285,6 +1285,10 @@ func (s *sender) checkDuplicateAck(seg *segment) (rtx bool) { // See: https://tools.ietf.org/html/draft-ietf-tcpm-rack-08#section-7.2 // steps 2 and 3. func (s *sender) walkSACK(rcvdSeg *segment) { + if len(rcvdSeg.parsedOptions.SACKBlocks) == 0 { + return + } + // Sort the SACK blocks. The first block is the most recent unacked // block. The following blocks can be in arbitrary order. sackBlocks := make([]header.SACKBlock, len(rcvdSeg.parsedOptions.SACKBlocks)) -- cgit v1.2.3