mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
Kernel: Handle listening socket disappearing during incoming handshake
This commit is contained in:
parent
feb6d1afe0
commit
3f1c3a341b
Notes:
sideshowbarker
2024-07-19 12:11:34 +09:00
Author: https://github.com/deoxxa Commit: https://github.com/SerenityOS/serenity/commit/3f1c3a341b3 Pull-request: https://github.com/SerenityOS/serenity/pull/530 Reviewed-by: https://github.com/awesomekling
@ -453,11 +453,32 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
|
||||
switch (tcp_packet.flags()) {
|
||||
case TCPFlags::ACK:
|
||||
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
|
||||
socket->set_state(TCPSocket::State::Established);
|
||||
socket->set_setup_state(Socket::SetupState::Completed);
|
||||
if (socket->direction() == TCPSocket::Direction::Outgoing)
|
||||
|
||||
switch (socket->direction()) {
|
||||
case TCPSocket::Direction::Incoming:
|
||||
if (!socket->has_originator()) {
|
||||
kprintf("handle_tcp: connection doesn't have an originating socket; maybe it went away?\n");
|
||||
socket->send_tcp_packet(TCPFlags::RST);
|
||||
socket->set_state(TCPSocket::State::Closed);
|
||||
return;
|
||||
}
|
||||
|
||||
socket->set_state(TCPSocket::State::Established);
|
||||
socket->set_setup_state(Socket::SetupState::Completed);
|
||||
socket->release_to_originator();
|
||||
return;
|
||||
case TCPSocket::Direction::Outgoing:
|
||||
socket->set_state(TCPSocket::State::Established);
|
||||
socket->set_setup_state(Socket::SetupState::Completed);
|
||||
socket->set_connected(true);
|
||||
socket->release_to_originator();
|
||||
return;
|
||||
default:
|
||||
kprintf("handle_tcp: got ACK in SynReceived state but direction is invalid (%s)\n", TCPSocket::to_string(socket->direction()));
|
||||
socket->send_tcp_packet(TCPFlags::RST);
|
||||
socket->set_state(TCPSocket::State::Closed);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
default:
|
||||
kprintf("handle_tcp: unexpected flags in SynReceived state\n");
|
||||
|
Loading…
Reference in New Issue
Block a user