net: tcp: Fix SYN handling after connection is established

According to RFC 793, ch 3.9 Event Processing, receving SYN flag after
the connection has been established is an error codition:

    If the SYN is in the window it is an error, send a reset, any
    outstanding RECEIVEs and SEND should receive "reset" responses,
    all segment queues should be flushed, the user should also
    receive an unsolicited general "connection reset" signal, enter
    the CLOSED state, delete the TCB, and return."

Currently TCP stack ignored such event, causing interoperability test
failures. Fix this, by verifying if the SYN flag is set in a packet in
any state other than TCP_LISTEN and TCP_SYN_SENT.

Signed-off-by: Robert Lubos <>
1 file changed