fix: bump MAX_POSTAUTH_FRAME_SIZE 32 KiB -> 4 MiB

Twin and trunk peers were flapping every few minutes after v1.3.6 with
the symptom "Connection closed by remote peer" alternating with
"RX timeout, disconnecting".

Root cause: v1.3.6 extended MsgPeerNodeList (type 121) twice without
bumping the framed-tcp receive cap:
  - a3757ca added a per-client rich-status JSON blob (~1 KB/client)
  - 3d281e1 added a per-client sat_id vector

A reflector with even ~30 clients now produces a NodeList frame > 32 KiB,
which the receiver's Async::FramedTcpConnection::onDataReceived rejects
with DR_PROTOCOL_ERROR (closeConnection + onDisconnected). Both sides
reconnect, hello succeeds, the next NodeList tears the link down again.

Fix: raise the post-auth cap to 4 MiB. Comfortably fits thousands of
clients with rich status while keeping the receive-buffer ceiling
bounded against malicious oversized frames.

Lockstep upgrade: both sides of any twin/trunk pair must run a build
with the bumped constant. Mixed deployments still flap on the
unupgraded side until it's updated too.
This commit is contained in:
Audric committed 2026-04-29 21:03:03 +02:00
1 parent 7ebee2249b
commit d8df8cf70b
1 file changed
+10 -1
+10 -1
View File
@@ -112,7 +112,16 @@ class ReflectorMsg : public Async::Msg
public: public:
static const uint32_t MAX_PREAUTH_FRAME_SIZE = 64; static const uint32_t MAX_PREAUTH_FRAME_SIZE = 64;
static const uint32_t MAX_SSL_SETUP_FRAME_SIZE = 4096; static const uint32_t MAX_SSL_SETUP_FRAME_SIZE = 4096;
static const uint32_t MAX_POSTAUTH_FRAME_SIZE = 32768; // 4 MiB — was 32 KiB but became too tight after MsgPeerNodeList grew a
// per-client rich-status JSON blob (b4b06f9) and a sat_id vector
// (4bb6477) in v1.3.6. A reflector with even a few dozen clients can
// exceed 32 KiB on every snapshot, and the receiver's framed-tcp guard
// (Async::FramedTcpConnection::onDataReceived) closes the connection
// with DR_PROTOCOL_ERROR when m_frame_size > m_max_rx_frame_size —
// visible to the sender as "Connection closed by remote peer" on every
// NodeList send, producing twin/trunk-link flap. 4 MiB comfortably fits
// thousands of clients while keeping the rx-buffer ceiling bounded.
static const uint32_t MAX_POSTAUTH_FRAME_SIZE = 4 * 1024 * 1024;
/** /**
* @brief Constuctor * @brief Constuctor