1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-29 06:45:08 +00:00

IPv4: Remove an unnecessary copy of each outgoing IPv4 payload

There's no need for send_ipv4() to take a ByteBuffer&&, the data is
immediately cooked into a packet and transmitted. Instead, just pass
it the address+length of whatever buffer we've been using locally.

The more we can reduce the pressure on kmalloc the better. :^)
This commit is contained in:
Andreas Kling 2019-08-05 10:37:09 +02:00
parent 6347e3aa51
commit 52cfe9ebae
6 changed files with 9 additions and 9 deletions

View file

@ -228,7 +228,7 @@ void handle_icmp(const EthernetFrameHeader& eth, int frame_size)
if (size_t icmp_payload_size = icmp_packet_size - sizeof(ICMPEchoPacket))
memcpy(response.payload(), request.payload(), icmp_payload_size);
response.header.set_checksum(internet_checksum(&response, icmp_packet_size));
adapter->send_ipv4(eth.source(), ipv4_packet.source(), IPv4Protocol::ICMP, move(buffer));
adapter->send_ipv4(eth.source(), ipv4_packet.source(), IPv4Protocol::ICMP, buffer.data(), buffer.size());
}
}