Kernel/Net: Don't update TCP socket "last sent ACK" field too early

Defer updating this field until after the last fallible operation has
succeeded.
This commit is contained in:
Andreas Kling 2022-02-11 12:38:10 +01:00
parent 06cf01cd1e
commit c797eaa9f8
Notes: sideshowbarker 2024-07-17 19:01:57 +09:00

View File

@ -237,12 +237,6 @@ ErrorOr<void> TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* pa
tcp_packet.set_data_offset(tcp_header_size / sizeof(u32));
tcp_packet.set_flags(flags);
if (flags & TCPFlags::ACK) {
m_last_ack_number_sent = m_ack_number;
m_last_ack_sent_time = kgettimeofday();
tcp_packet.set_ack_number(m_ack_number);
}
if (payload) {
if (auto result = payload->read(tcp_packet.payload(), payload_size); result.is_error()) {
routing_decision.adapter->release_packet_buffer(*packet);
@ -250,6 +244,12 @@ ErrorOr<void> TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* pa
}
}
if (flags & TCPFlags::ACK) {
m_last_ack_number_sent = m_ack_number;
m_last_ack_sent_time = kgettimeofday();
tcp_packet.set_ack_number(m_ack_number);
}
if (flags & TCPFlags::SYN) {
++m_sequence_number;
} else {