On Thu, 19 Dec 2024 14:38:28 +0800 Yunjian Wang <wangyunj...@huawei.com> wrote:
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index 69901ab3b5..5c40ae7069 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -2914,10 +2914,12 @@ desc_to_mbuf(struct virtio_net *dev, struct > vhost_virtqueue *vq, > * in a contiguous virtual area. > */ > copy_vnet_hdr_from_desc(&tmp_hdr, buf_vec); > - hdr = &tmp_hdr; > } else { > - hdr = (struct virtio_net_hdr > *)((uintptr_t)buf_vec[0].buf_addr); > + rte_memcpy((void *)(uintptr_t)&tmp_hdr, > + (void *)(uintptr_t)buf_vec[0].buf_addr, > + sizeof(struct virtio_net_hdr)); > } > + hdr = &tmp_hdr; Since this if block is just an optimization of the case where vnet header is contiguous why not just always use copy_vnet_hdr_from_desc? and inline it?