diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1223,6 +1223,15 @@ } else framesz = sizeof(struct vtnet_rx_header); framesz += sizeof(struct ether_vlan_header) + mtu; +#ifndef __NO_STRICT_ALIGNMENT + /* + * Account for the offsetting we'll do elsewhere so we allocate the + * right size for the mtu. + */ + if (sc->vtnet_hdr_size % 4 == 0) { + framesz += ETHER_ALIGN; + } +#endif if (framesz <= MCLBYTES) return (MCLBYTES); diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -236,6 +236,10 @@ CTASSERT(sizeof(struct virtio_net_hdr_mrg_rxbuf) == sizeof(struct virtio_net_hdr_v1)); +/* We depend on both of these structures being even, and matching std */ +CTASSERT(sizeof(struct virtio_net_hdr_v1) == 12); +CTASSERT(sizeof(struct virtio_net_hdr) == 10); + /* * In legacy VirtIO when mergeable buffers are not negotiated, this structure * is placed at the beginning of the mbuf data. Use 4 bytes of pad to keep