soypat / seqs

seqs: the hottest, most idiomatic userspace TCP/IP implementation on the internet. lwip in go basically
BSD 3-Clause "New" or "Revised" License
46 stars 5 forks source link

TCPListener Conn leak on RST receive #25

Open soypat opened 5 months ago

soypat commented 5 months ago

As title suggests, a TCPListener connection resource is lost on a correct RST receive due to how initiating SYN packets are handled. This bug yields the following characteristic log messages (if your log level is not low enough you may only see the last message)

time=1970-01-01T00:18:54.865Z level=DEBUG msg=rcv:RST state=SynRcvd
time=1970-01-01T00:18:54.866Z level=DEBUG-2 msg=tcb:rcv.reject state=Listen rcv.nxt=203488617 rcv.wnd=2030 challenge=false
time=1970-01-01T00:18:54.899Z level=DEBUG-2 msg=tcb:rcv.reject seg.seq=3076528933 seg.ack=0 seg.wnd=0 seg.flags=[RST] seg.data=0
time=1970-01-01T00:18:54.900Z level=ERROR msg=tcb:rcv.reject err="drop segment"

followed by many msg=TCPConn.recv:start and no detailed prints on what is being received via TCP on that connection.

soypat commented 1 month ago

This issue can be circumvented by using a TCPConn directly to receive data instead of a TCPListener. See https://github.com/soypat/cyw43439/blob/main/examples/tcpserver/main.go