From 05e5233e07857dea256c3d1b0088b368cf9f5243 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 6 Dec 2020 19:46:11 -0800 Subject: [PATCH] net/netcheck: don't send flood of PCP unmap requests to router Updates #810 --- net/netcheck/netcheck.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/net/netcheck/netcheck.go b/net/netcheck/netcheck.go index cdb767bff..ff6f9ddb7 100644 --- a/net/netcheck/netcheck.go +++ b/net/netcheck/netcheck.go @@ -710,6 +710,7 @@ func (rs *reportState) probePortMapServices() { uc.WriteTo(pcpPacket(myIP, tempPort, false), port5351) res := make([]byte, 1500) + sentPCPDelete := false for { n, addr, err := uc.ReadFrom(res) if err != nil { @@ -727,11 +728,14 @@ func (rs *reportState) probePortMapServices() { if n == 60 && res[0] == 0x02 { // right length and version 2 rs.setOptBool(&rs.report.PCP, true) - // And now delete the mapping. - // (PCP is the only protocol of the three that requires - // we cause a side effect to detect whether it's present, - // so we need to redo that side effect now.) - uc.WriteTo(pcpPacket(myIP, tempPort, true), port5351) + if !sentPCPDelete { + sentPCPDelete = true + // And now delete the mapping. + // (PCP is the only protocol of the three that requires + // we cause a side effect to detect whether it's present, + // so we need to redo that side effect now.) + uc.WriteTo(pcpPacket(myIP, tempPort, true), port5351) + } } } }