Repository navigation
rx_tcp: SYN with ECN flags (ECE+CWR) is rejected with RST instead of being treated as plain SYN #3538
|
Target: STM32F4 Problem When a host initiates a TCP connection with ECN negotiation, the built-in TCP/IP stack sends RST instead of SYN+ACK. This causes a ~1 second reconnect delay: the host falls back to a plain SYN after the RST, which is the normal ECN fallback behaviour. Observed with macOS connecting over USB CDC-NCM (tethered interface). macOS does not reproduce this over standard Ethernet because it uses a different ECN initiation policy per interface type. Root cause In rx_tcp(), the SYN acceptance branch uses strict equality: } else if (pkt->tcp->flags == TH_SYN) {A SYN with ECE+CWR set does not match this, so it falls through to: } else if (pkt->tcp->flags & TH_SYN) { // SYN + something else != ACK
tx_tcp_rst(ifp, pkt, false);...and the stack incorrectly sends RST. RFC 3168 §6.1.1 defines that the correct response to an ECN-setup SYN is a SYN+ACK (plain or with ECE). §6.1.1.1 acknowledges that some middleboxes (firewalls, load balancers) incorrectly respond with RST - and describes this as behavior of faulty equipment. A TCP server stack should not behave the same way as a faulty firewall: it should accept the connection and simply decline ECN by responding with a plain SYN+ACK. Verified with Wireshark:
|
We know our code and we know RFCs, your creative usage is not plain TCP. If you want to be creative with TCP flags, use 7.21 or merge this #3406 , where we allowed room for creativeness