mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 13:11:46 +03: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
Notes:
sideshowbarker
2024-07-18 08:59:31 +09:00
Author: https://github.com/TomFinet Commit: https://github.com/SerenityOS/serenity/commit/a7db718ffb Pull-request: https://github.com/SerenityOS/serenity/pull/23312 Reviewed-by: https://github.com/ADKaster ✅
@ -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…
Reference in New Issue
Block a user