From 0389596f663e9bfad3911a85edd4662f9be119ff Mon Sep 17 00:00:00 2001 From: Wade Simmons Date: Mon, 16 Nov 2020 14:03:08 -0500 Subject: [PATCH] don't mark handshake packets as "lost" (#331) Packet 1 is always a stage 1 handshake and packet 2 is always stage 2. Normal packets don't start flowing until the message counter is 3 or higher. Currently we only receive either packet 1 or 2 depending on if we are the initiator or responder for the handshake, so we end up marking one of these as "lost". We should mark these packets as "seen" when we are the one sending them, since we don't expect to see them from the other side. --- handshake_ix.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/handshake_ix.go b/handshake_ix.go index 2daeb5c..f2afb51 100644 --- a/handshake_ix.go +++ b/handshake_ix.go @@ -63,6 +63,10 @@ func ixHandshakeStage0(f *Interface, vpnIp uint32, hostinfo *HostInfo) { return } + // We are sending handshake packet 1, so we don't expect to receive + // handshake packet 1 from the responder + ci.window.Update(1) + hostinfo.HandshakePacket[0] = msg hostinfo.HandshakeReady = true hostinfo.handshakeStart = time.Now() @@ -198,6 +202,10 @@ func ixHandshakeStage1(f *Interface, addr *udpAddr, hostinfo *HostInfo, packet [ hostinfo.HandshakePacket[2] = make([]byte, len(msg)) copy(hostinfo.HandshakePacket[2], msg) + // We are sending handshake packet 2, so we don't expect to receive + // handshake packet 2 from the initiator. + ci.window.Update(2) + f.messageMetrics.Tx(handshake, NebulaMessageSubType(msg[1]), 1) err := f.outside.WriteTo(msg, addr) if err != nil {