Commit 14fc71522a for qemu.org
commit 14fc71522a8d94bc96f232eb66b451885a2830c3
Author: Peter Maydell <peter.maydell@linaro.org>
Date: Tue Nov 10 18:06:55 2026 +0000
net: Remove padding code from net backends
We can remove the short-frame padding code from the net backends that
were previously doing it, because the qemu_send_packet and
qemu_sendv_packet calls they use now do the padding for them.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20261110180655.2072265-4-peter.maydell@linaro.org
diff --git a/net/slirp.c b/net/slirp.c
index 451c0fd1ba..eea12e7981 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -120,15 +120,6 @@ static ssize_t net_slirp_send_packet(const void *pkt, size_t pkt_len,
void *opaque)
{
SlirpState *s = opaque;
- uint8_t min_pkt[ETH_ZLEN];
- size_t min_pktsz = sizeof(min_pkt);
-
- if (net_peer_needs_padding(&s->nc)) {
- if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pkt_len)) {
- pkt = min_pkt;
- pkt_len = min_pktsz;
- }
- }
return qemu_send_packet(&s->nc, pkt, pkt_len);
}
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 38baf90e0b..2fccfdbaac 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -682,25 +682,14 @@ static ssize_t tap_receive(NetClientState *nc, const uint8_t *buf, size_t size)
static void tap_win32_send(void *opaque)
{
TAPState *s = opaque;
- uint8_t *buf, *orig_buf;
+ uint8_t *buf;
int max_size = 4096;
int size;
- uint8_t min_pkt[ETH_ZLEN];
- size_t min_pktsz = sizeof(min_pkt);
size = tap_win32_read(s->handle, &buf, max_size);
if (size > 0) {
- orig_buf = buf;
-
- if (net_peer_needs_padding(&s->nc)) {
- if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) {
- buf = min_pkt;
- size = min_pktsz;
- }
- }
-
qemu_send_packet(&s->nc, buf, size);
- tap_win32_free_buffer(s->handle, orig_buf);
+ tap_win32_free_buffer(s->handle, buf);
}
}
diff --git a/net/tap.c b/net/tap.c
index ee6430d34a..9f3d0b08ab 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -261,8 +261,6 @@ static void tap_send(void *opaque)
while (true) {
uint8_t *buf = s->buf;
- uint8_t min_pkt[ETH_ZLEN];
- size_t min_pktsz = sizeof(min_pkt);
size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
if (size <= 0) {
@@ -279,13 +277,6 @@ static void tap_send(void *opaque)
size -= s->host_vnet_hdr_len;
}
- if (net_peer_needs_padding(&s->nc)) {
- if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) {
- buf = min_pkt;
- size = min_pktsz;
- }
- }
-
size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed);
if (size == 0) {
tap_read_poll(s, false);
diff --git a/net/vmnet-common.m b/net/vmnet-common.m
index ab33ce2b0c..4dfc8abbc1 100644
--- a/net/vmnet-common.m
+++ b/net/vmnet-common.m
@@ -150,23 +150,12 @@ static void vmnet_write_packets_to_qemu(VmnetState *s)
{
uint8_t *pkt;
size_t pktsz;
- uint8_t min_pkt[ETH_ZLEN];
- size_t min_pktsz;
ssize_t size;
while (s->packets_send_current_pos < s->packets_send_end_pos) {
pkt = s->iov_buf[s->packets_send_current_pos].iov_base;
pktsz = s->packets_buf[s->packets_send_current_pos].vm_pkt_size;
- if (net_peer_needs_padding(&s->nc)) {
- min_pktsz = sizeof(min_pkt);
-
- if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pktsz)) {
- pkt = min_pkt;
- pktsz = min_pktsz;
- }
- }
-
size = qemu_send_packet_async(&s->nc, pkt, pktsz,
vmnet_send_completed);