Skip to content

Commit 4f1a4cb

Browse files
committed
net: Quiet down logging when router doesn't support natpmp/pcp
When the router doesn't support natpmp and PCP, one'd normally expect the UDP packet to be ignored, and hit a time out. This logs a warning that is already in the debug category. However, there's also the case in which sending an UDP packet causes a ICMP response. This is returned to user space as "connection refused" (despite UDP having no concept of connections). Move the warnings from `Send` and `Recv` to debug level too, to reduce log spam in that case. Closes #33301.
1 parent e1ce0c5 commit 4f1a4cb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/common/pcp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
230230
}
231231
// Dispatch packet to gateway.
232232
if (sock.Send(request.data(), request.size(), 0) != static_cast<ssize_t>(request.size())) {
233-
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "%s: Could not send request: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
233+
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Could not send request: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
234234
return std::nullopt; // Network-level error, probably no use retrying.
235235
}
236236

@@ -251,7 +251,7 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
251251
// Receive response.
252252
recvsz = sock.Recv(response, sizeof(response), MSG_DONTWAIT);
253253
if (recvsz < 0) {
254-
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "%s: Could not receive response: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
254+
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Could not receive response: %s\n", protocol, NetworkErrorString(WSAGetLastError()));
255255
return std::nullopt; // Network-level error, probably no use retrying.
256256
}
257257
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "%s: Received response of %d bytes: %s\n", protocol, recvsz, HexStr(std::span(response, recvsz)));

0 commit comments

Comments
 (0)