@@ -31,6 +31,7 @@
#define ETH_ALEN 6
#define ETH_HLEN 14
+#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
struct eth_header {
uint8_t h_dest[ETH_ALEN]; /* destination eth addr */
@@ -621,6 +621,7 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
const uint8_t *buf, int size,
NetPacketSent *sent_cb)
{
+ static const uint8_t null_buf[ETH_ZLEN] = { };
NetQueue *queue;
int ret;
int iovcnt = 1;
@@ -629,6 +630,10 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
.iov_base = (void *)buf,
.iov_len = size,
},
+ [1] = {
+ .iov_base = (void *)null_buf,
+ .iov_len = ETH_ZLEN,
+ },
};
#ifdef DEBUG_NET
@@ -640,6 +645,12 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
return size;
}
+ /* Pad to minimum Ethernet frame length */
+ if (size < ETH_ZLEN) {
+ iov[1].iov_len = ETH_ZLEN - size;
+ iovcnt = 2;
+ }
+
/* Let filters handle the packet first */
ret = filter_receive_iov(sender, NET_FILTER_DIRECTION_TX,
sender, flags, iov, iovcnt, sent_cb);