From a3468dc993198d12aa2943e71a58c816e54b0c38 Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Tue, 3 Sep 2019 23:16:24 +1000 Subject: [PATCH] Kernel: Pad packets out to 64 bytes in rtl8139 driver --- Kernel/Net/RTL8139NetworkAdapter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Kernel/Net/RTL8139NetworkAdapter.cpp b/Kernel/Net/RTL8139NetworkAdapter.cpp index e414a8cccb..84a1a286b8 100644 --- a/Kernel/Net/RTL8139NetworkAdapter.cpp +++ b/Kernel/Net/RTL8139NetworkAdapter.cpp @@ -302,6 +302,17 @@ void RTL8139NetworkAdapter::send_raw(const u8* data, int length) memcpy((void*)(m_tx_buffer_addr[hw_buffer]), data, length); memset((void*)(m_tx_buffer_addr[hw_buffer] + length), 0, TX_BUFFER_SIZE - length); + // the rtl8139 will not actually emit packets onto the network if they're + // smaller than 64 bytes. the rtl8139 adds a checksum to the end of each + // packet, and that checksum is four bytes long, so we pad the packet to + // 60 bytes if necessary to make sure the whole thing is large enough. + if (length < 60) { +#ifdef RTL8139_DEBUG + kprintf("RTL8139NetworkAdapter: adjusting payload size from %d to 60\n", length); +#endif + length = 60; + } + out32(REG_TXSTATUS0 + (hw_buffer * 4), length); }