From 9401ec1190ad1511db684ae8618c2b3486b44d8d Mon Sep 17 00:00:00 2001 From: Lucas Manning Date: Mon, 20 May 2024 12:02:31 -0700 Subject: [PATCH] Fix flaky fragment reassembly. Fragmented packets need to be handled by the same processor goroutine. PiperOrigin-RevId: 635529020 --- pkg/tcpip/link/fdbased/processors.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/tcpip/link/fdbased/processors.go b/pkg/tcpip/link/fdbased/processors.go index 5e634b1b4..f454a294a 100644 --- a/pkg/tcpip/link/fdbased/processors.go +++ b/pkg/tcpip/link/fdbased/processors.go @@ -193,8 +193,12 @@ func tcpipConnectionID(pkt *stack.PacketBuffer) (connectionID, bool) { cid.srcAddr = ipHdr.SourceAddressSlice() cid.dstAddr = ipHdr.DestinationAddressSlice() - cid.srcPort = tcpHdr.SourcePort() - cid.dstPort = tcpHdr.DestinationPort() + // All fragment packets need to be processed by the same goroutine, so + // only record the TCP ports if this is not a fragment packet. + if ipHdr.IsValid(pkt.Data().Size()) && !ipHdr.More() && ipHdr.FragmentOffset() == 0 { + cid.srcPort = tcpHdr.SourcePort() + cid.dstPort = tcpHdr.DestinationPort() + } cid.proto = header.IPv4ProtocolNumber case header.IPv6Version: h, ok = pkt.Data().PullUp(header.IPv6FixedHeaderSize + tcpSrcDstPortLen)