fix: correct INIT padding — include SC_NONCE_SIZE + SC_CRC32_SIZE in formula
REQUEST: s_max = mtu - SC_NONCE_SIZE - 3 - SC_CRC32_SIZE - SC_TAG_SIZE
- SC_PUBKEY_ENC_SIZE + UDP_SC_HDR_SIZE (= mtu-78, was mtu-61)
RESPONSE: s_max = mtu (noencrypt=0, simple cap)
Removed debug logs.
This commit is contained in:
1 parent
b8da0db1ab
commit
4dfc0ce947
1 file changed
+3
-13
+3
-13
@@ -133,9 +133,8 @@ static void etcp_link_send_init(struct ETCP_LINK* link, uint8_t reset) {
|
||||
|
||||
// padding
|
||||
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize;
|
||||
int s_max = (int)(link->mtu) - 3 - (int)SC_TAG_SIZE + (int)UDP_SC_HDR_SIZE - (int)SC_PUBKEY_ENC_SIZE;
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_REQ: mtu=%d s=%d s_max=%d offset=%zu", (int)link->mtu, s, s_max, offset);
|
||||
if (s > s_max) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_REQ capped s=%d -> %d", s, s_max); s = s_max; }
|
||||
int s_max = (int)(link->mtu) - (int)SC_NONCE_SIZE - 3 - (int)SC_CRC32_SIZE - (int)SC_TAG_SIZE - (int)SC_PUBKEY_ENC_SIZE + (int)UDP_SC_HDR_SIZE;
|
||||
if (s > s_max) s = s_max;
|
||||
if (s < 0) s = 0;
|
||||
|
||||
int to_add=s-offset-UDP_HDR_SIZE - UDP_SC_HDR_SIZE;
|
||||
@@ -162,8 +161,6 @@ static void etcp_link_send_init(struct ETCP_LINK* link, uint8_t reset) {
|
||||
|
||||
|
||||
dgram->data_len = offset;
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_REQ final: offset=%zu s=%d to_add=%d data_len=%d noenc=%d",
|
||||
offset, s, to_add, (int)dgram->data_len, (int)dgram->noencrypt_len);
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "Sending INIT request to link, node_id=%016llx, retry=%d", (unsigned long long)node_id, link->init_retry_count);
|
||||
|
||||
@@ -1534,12 +1531,8 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
int xoffset=sizeof(*ack_repl_hdr);
|
||||
// padding
|
||||
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize;
|
||||
int s_max = (int)(link->mtu) - 3 - (int)SC_TAG_SIZE + (int)UDP_SC_HDR_SIZE;
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_RESP: mtu=%d s=%d s_max=%d xoffset=%d", (int)link->mtu, s, s_max, xoffset);
|
||||
if (s > s_max) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_RESP capped s=%d -> %d", s, s_max); s = s_max; }
|
||||
if (s > (int)(link->mtu)) s = (int)(link->mtu);
|
||||
if (s < 0) s = 0;
|
||||
// Remove old hardcoded caps
|
||||
// if (s > 1472 + 26) s = 1472 + 26;
|
||||
|
||||
int to_add=s - xoffset - UDP_HDR_SIZE - UDP_SC_HDR_SIZE;
|
||||
if (to_add<0) to_add=0;
|
||||
@@ -1548,9 +1541,6 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
for (int i=0; i<to_add; i++) pkt->data[xoffset++]=rand();// fill pad
|
||||
// padding end
|
||||
pkt->data_len=xoffset;
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_RESP final: xoffset=%d s=%d to_add=%d data_len=%d noenc=%d",
|
||||
xoffset, s, to_add, (int)pkt->data_len, (int)pkt->noencrypt_len);
|
||||
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "Sending INIT RESPONSE, link=%p, local_link_id=%d, remote_link_id=%d", link, link->local_link_id, link->remote_link_id);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[ETCP DEBUG] Send INIT RESPONSE");
|
||||
etcp_encrypt_send(pkt);
|
||||
|
||||
Reference in new issue
Block a user