@samitouri / QOSamiQemu / commits / f3a10c1c45

hw/net/rtl8139: Send whole of vlan-tagged packet when doing loopback

In rtl8139_transfer_frame(), if we are transmitting a frame over loopback then we do this by calling qemu_receive_packet(). If we have an iovec rather than a simple buffer (which happens only when we're sending a packet where we are inserting a vlan tag), we have to convert this into a simple buffer first using iov_to_buf(). However, when we do this we forget to also update the 'size' local variable to the size of the new simple buffer, so we will truncate the packet by 4 bytes (the size of the vlan tag). Correct the logic so we don't truncate vlan-tagged packets when sending them over loopback. Cc: qemu-stable@nongnu.org Reported-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Bin Meng <bin.meng@processmission.com> Message-ID: <20260731093618.2961031-3-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>

Peter Maydell committed Jul 31, 2026 at 10:36 UTC f3a10c1c454789ad6bb0633118019f4c6544b4b3
1 file changed +1
hw/net/rtl8139.c
+1
@@ -1765,6 +1765,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, uint8_t *buf, int size,
1765 buf2 = g_malloc(buf2_size);
1766 iov_to_buf(iov, 3, 0, buf2, buf2_size);
1767 buf = buf2;
1768 + size = buf2_size;
1769 }
1770
1771 DPRINTF("+++ transmit loopback mode\n");