net/netcheck: don't send flood of PCP unmap requests to router

Updates #810

(cherry picked from commit 05e5233e07)
release-branch/1.2
Brad Fitzpatrick 4 years ago
parent 06daf4bd07
commit f23c9badd9

@ -715,6 +715,7 @@ func (rs *reportState) probePortMapServices() {
uc.WriteTo(pcpPacket(myIP, tempPort, false), port5351) uc.WriteTo(pcpPacket(myIP, tempPort, false), port5351)
res := make([]byte, 1500) res := make([]byte, 1500)
sentPCPDelete := false
for { for {
n, addr, err := uc.ReadFrom(res) n, addr, err := uc.ReadFrom(res)
if err != nil { if err != nil {
@ -732,11 +733,14 @@ func (rs *reportState) probePortMapServices() {
if n == 60 && res[0] == 0x02 { // right length and version 2 if n == 60 && res[0] == 0x02 { // right length and version 2
rs.setOptBool(&rs.report.PCP, true) rs.setOptBool(&rs.report.PCP, true)
// And now delete the mapping. if !sentPCPDelete {
// (PCP is the only protocol of the three that requires sentPCPDelete = true
// we cause a side effect to detect whether it's present, // And now delete the mapping.
// so we need to redo that side effect now.) // (PCP is the only protocol of the three that requires
uc.WriteTo(pcpPacket(myIP, tempPort, true), port5351) // 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)
}
} }
} }
} }

Loading…
Cancel
Save