Browse Source

fix: INIT padding cap computed from actual link MTU, not hardcoded 1472

Hardcoded 1472-46 cap exceeded link MTU=1460, causing 'packet too long'
error on INIT handshake. Use link->mtu - UDP_HDR_SIZE - offset - 19
instead of fixed 1472.
etcp-inflight-fix
Evgeny 4 months ago
parent
commit
cb764a1143
  1. 6
      src/etcp_connections.c

6
src/etcp_connections.c

@ -133,9 +133,9 @@ static void etcp_link_send_init(struct ETCP_LINK* link, uint8_t reset) {
// padding // padding
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize; int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize;
if (s > link->mtu - dgram->noencrypt_len) s = link->mtu - dgram->noencrypt_len; int s_max = (int)(link->mtu - UDP_HDR_SIZE) - (int)offset - 19; // 19=3hdr+16tag-72unenc
// Cap s: final encrypted = s + 46 for REQUEST (noencrypt=72) if (s > s_max) s = s_max;
if (s > 1472 - 46) s = 1472 - 46; // s ≤ 1426 if (s < 0) s = 0;
int to_add=s-offset-UDP_HDR_SIZE - UDP_SC_HDR_SIZE; int to_add=s-offset-UDP_HDR_SIZE - UDP_SC_HDR_SIZE;
if (to_add<0) to_add=0; if (to_add<0) to_add=0;

Loading…
Cancel
Save