We already disconnect on invalid netmagic (which might also be due to a bit-flip), so disconnecting here is probably fine. However, I think for cleaner code, the two seem related enough to be treated in the same way (either both in net_processing or both in net). No strong opinion where, but for example this is the diff if they are kept in net_processing:
0diff --git a/src/net.cpp b/src/net.cpp
1index 9950b9aea4..9e213547fa 100644
2--- a/src/net.cpp
3+++ b/src/net.cpp
4@@ -597,6 +597,11 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
5 vRecvMsg.push_back(std::move(msg));
6
7 complete = true;
8+
9+ if (!msg.m_valid_checksum) {
10+ // return early and notify net processing
11+ return true;
12+ }
13 }
14 }
15
16diff --git a/src/net_processing.cpp b/src/net_processing.cpp
17index 6d85b46831..a5606dfe66 100644
18--- a/src/net_processing.cpp
19+++ b/src/net_processing.cpp
20@@ -3499,6 +3499,13 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
21 }
22 CNetMessage& msg(msgs.front());
23
24+ if (!msg.m_valid_checksum) {
25+ LogPrint(BCLog::NET, "%s(%s, %u bytes): CHECKSUM ERROR peer=%d\n",
26+ __func__, SanitizeString(msg.m_command), msg.m_message_size, pfrom->GetId());
27+ pfrom->fDisconnect = true;
28+ return false;
29+ }
30+
31 msg.SetVersion(pfrom->GetRecvVersion());
32 // Check network magic
33 if (!msg.m_valid_netmagic) {
34@@ -3518,15 +3525,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
35 // Message size
36 unsigned int nMessageSize = msg.m_message_size;
37
38- // Checksum
39 CDataStream& vRecv = msg.m_recv;
40- if (!msg.m_valid_checksum)
41- {
42- LogPrint(BCLog::NET, "%s(%s, %u bytes): CHECKSUM ERROR peer=%d\n", __func__,
43- SanitizeString(msg_type), nMessageSize, pfrom->GetId());
44- return fMoreWork;
45- }
46-
47 // Process message
48 bool fRet = false;
49 try