mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 05:54:58 +00:00
Kernel/Net: Send RST packet when socket receives in closed state
RFC9293 states that a closed socket should reply to all non-RST packets with an RST. This change implements this behaviour as specified in section 3.5.2 in bullet point 1.
This commit is contained in:
parent
29ef508b4e
commit
a7db718ffb
1 changed files with 6 additions and 1 deletions
|
@ -447,7 +447,12 @@ void handle_tcp(IPv4Packet const& ipv4_packet, UnixDateTime const& packet_timest
|
|||
switch (socket->state()) {
|
||||
case TCPSocket::State::Closed:
|
||||
dbgln("handle_tcp: unexpected flags in Closed state ({:x}) for socket with tuple {}", tcp_packet.flags(), tuple.to_string());
|
||||
// TODO: we may want to send an RST here, maybe as a configurable option
|
||||
if (tcp_packet.has_rst()) {
|
||||
return;
|
||||
}
|
||||
socket->set_sequence_number(tcp_packet.has_ack() ? tcp_packet.ack_number() : 0);
|
||||
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
|
||||
(void)socket->send_tcp_packet(TCPFlags::RST | TCPFlags::ACK);
|
||||
return;
|
||||
case TCPSocket::State::TimeWait:
|
||||
dbgln("handle_tcp: unexpected flags in TimeWait state ({:x}) for socket with tuple {}", tcp_packet.flags(), tuple.to_string());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue