net: Quiet down logging when router doesn't support natpmp/pcp
What changed, and why it matters
This commit simply changes two log messages from 'warning' level to 'debug' level in the network code that handles NAT-PMP/PCP router discovery. When a router does not support these protocols, the software was printing warnings that could flood logs; now those messages only appear in debug logging. There is no security vulnerability being fixed here.
No security action required; this is a routine logging/UX improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies src/common/pcp.cpp in the PCPSendRecv function, lowering the log severity of send/recv network errors from BCLog::Level::Warning to BCLog::Level::Debug. The behavior of the function is unchanged: it still returns std::nullopt on failure. Only the verbosity of the emitted log line changes, to avoid log spam when routers respond with ICMP ‘connection refused’ to UDP probes.
Changed components
src/common/pcp.cppNAT-PMP/PCP discovery loggingInspect captured patch +2 / −2
diff --git a/src/common/pcp.cpp b/src/common/pcp.cpp
index 8ababab3..6733cb79 100644
--- a/src/common/pcp.cpp
+++ b/src/common/pcp.cpp
@@ -230,7 +230,7 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
}
// Dispatch packet to gateway.
if (sock.Send(request.data(), request.size(), 0) != static_cast<ssize_t>(request.size())) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "%s: Could not send request: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
+ LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Could not send request: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
return std::nullopt; // Network-level error, probably no use retrying.
}
@@ -251,7 +251,7 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
// Receive response.
recvsz = sock.Recv(response, sizeof(response), MSG_DONTWAIT);
if (recvsz < 0) {
- LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "%s: Could not receive response: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
+ LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Could not receive response: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
return std::nullopt; // Network-level error, probably no use retrying.
}
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Received response of %d bytes: %s\n", protocol, recvsz, HexStr(std::span(response, recvsz)));
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.