Answer the question
In order to leave comments, you need to log in
Why isn't a TCP/IP packet sent with the RST flag?
Maybe I'm just dumb, but it always seemed to me that if machine A sends a TCP packet to machine B, which refers to a (no longer) existing TCP connection, then machine B should respond to it with an RST packet (if, of course, there are such left packets are not DROPed by the firewall, etc.). But at the moment I see a slightly different picture, and I can’t understand whether I don’t know something about TCP, or whether these are some bugs in the Linux kernel (to be honest, I traditionally sinned on conntrack, but disabling the firewall did nothing changed).
So, there are two linux servers (let's call them A and B). They are connected to one (unmanaged) switch. The firewall on both servers was initially enabled (and used conntrack - "-m state --state NEW"), but then I reset it (deleted all rules in all tables and set the default to ACCEPT in all chains). Thus, nothing should block/modify packets between these servers.
Now, we start a TCP service on server A, which accepts incoming connections and starts sending data continuously to connected clients. It doesn't try to read anything from clients, and expects to get an EPIPE on write() to a client that has failed.
Next, we launch a TCP client on server B (normal nc - netcat), it connects to server A, starts receiving data from it, and then we disable nc (by Ctrl-C).
After that, the TCP service on server A blocks when calling write () on this already disconnected client, without receiving (even after a couple of minutes) either EPIPE or another error.
I ran tcpdump on both servers and this is what it shows:
Answer the question
In order to leave comments, you need to log in
2.6.39-hardened-r8
Try the latest vanilla kernel from kernel.org
Maybe they screwed something up with hardened.
And in my opinion B should not swear, he is in the FIN_WAIT_2 state and expects only FIN from A
The behavior depends on whether the SO_LINGER option is set on the socket . If the client sets SO_LINGER, then there will be no resets while the packets go within the TCP connection.
Is the server code very secret? Can you publish? Very interesting problem, I want to get to the bottom of it
I also remembered that ru.wikipedia.org/wiki/TCP_hijacking
may be somehow connected
Check out Richard Stevens. TCP/IP protocols.
It can be found or bought online. This issue is discussed in detail there.
The chapter “Detecting half-open connections” clearly states that such an action (write to a half-closed socket) should indeed receive RST.
Look also at the behavior of ARP at this point - does the server that should send RST lose information about where to send it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question