1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-01 11:12:07 +00:00

Kernel: Avoid allocations when handling network packets

This commit is contained in:
Gunnar Beutner 2021-05-15 22:45:22 +02:00 committed by Andreas Kling
parent 53d0150827
commit 006f11f23d
5 changed files with 8 additions and 6 deletions

View file

@ -186,7 +186,7 @@ KResult TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload,
const size_t options_size = has_mss_option ? sizeof(TCPOptionMSS) : 0;
const size_t header_size = sizeof(TCPPacket) + options_size;
const size_t buffer_size = header_size + payload_size;
auto buffer = ByteBuffer::create_zeroed(buffer_size);
auto buffer = NetworkByteBuffer::create_zeroed(buffer_size);
auto& tcp_packet = *(TCPPacket*)(buffer.data());
VERIFY(local_port());
tcp_packet.set_source_port(local_port());