Kernel: Don't increment ACK number without SYN, FIN, or data

This commit is contained in:
Conrad Pankoff 2019-09-08 17:02:40 +10:00 committed by Andreas Kling
parent 749719b4d0
commit 706e04d340

View file

@ -437,7 +437,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
socket->set_setup_state(Socket::SetupState::Completed);
return;
case TCPFlags::ACK | TCPFlags::RST:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
socket->send_tcp_packet(TCPFlags::ACK);
socket->set_state(TCPSocket::State::Closed);
socket->set_error(TCPSocket::Error::RSTDuringConnect);
@ -454,7 +454,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
case TCPSocket::State::SynReceived:
switch (tcp_packet.flags()) {
case TCPFlags::ACK:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
socket->set_state(TCPSocket::State::Established);
if (socket->direction() == TCPSocket::Direction::Outgoing) {
socket->set_setup_state(Socket::SetupState::Completed);
@ -478,7 +478,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
case TCPSocket::State::LastAck:
switch (tcp_packet.flags()) {
case TCPFlags::ACK:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
socket->set_state(TCPSocket::State::Closed);
return;
default:
@ -490,7 +490,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
case TCPSocket::State::FinWait1:
switch (tcp_packet.flags()) {
case TCPFlags::ACK:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
socket->set_state(TCPSocket::State::FinWait2);
return;
case TCPFlags::FIN:
@ -518,7 +518,7 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
case TCPSocket::State::Closing:
switch (tcp_packet.flags()) {
case TCPFlags::ACK:
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
socket->set_state(TCPSocket::State::TimeWait);
return;
default: