From 576b099a5f0cfc011ea6829fc625ebaca05676d6 Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Sun, 14 Jun 2020 22:39:34 +0000 Subject: [PATCH] vtnet: Fix regression introduced in r361944 For legacy devices that don't support MrgRxBuf (such as bhyve pre-r358180), r361944 failed to update the receive handler to account for the additional padding introduced by the unused num_buffers field that is now always present in struct vtnet_rx_header. Thus, calculate the padding dynamically based on vtnet_hdr_size. PR: 247242 Reported by: thj Tested by: thj --- sys/dev/virtio/network/if_vtnet.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 3ef8d90d5fa9..95a30c52a563 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1819,9 +1819,10 @@ vtnet_rxq_eof(struct vtnet_rxq *rxq) adjsz = sizeof(struct vtnet_rx_header); /* * Account for our pad inserted between the header - * and the actual start of the frame. + * and the actual start of the frame. This includes + * the unused num_buffers when using a legacy device. */ - len += VTNET_RX_HEADER_PAD; + len += adjsz - sc->vtnet_hdr_size; } else { mhdr = mtod(m, struct virtio_net_hdr_mrg_rxbuf *); nbufs = mhdr->num_buffers;