vnet header size depends on whether we use mergable rx buffers.

Signed-off-by: Sasha Levin <sasha.le...@oracle.com>
---
 tools/kvm/virtio/net.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index 2dbca09..15dbde3 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -243,7 +243,9 @@ static bool virtio_net__tap_init(struct net_dev *ndev)
                goto fail;
        }
 
-       hdr_len = sizeof(struct virtio_net_hdr);
+       hdr_len = (ndev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ?
+                       sizeof(struct virtio_net_hdr_mrg_rxbuf) :
+                       sizeof(struct virtio_net_hdr);
        if (ioctl(ndev->tap_fd, TUNSETVNETHDRSZ, &hdr_len) < 0)
                pr_warning("Config tap device TUNSETVNETHDRSZ error");
 
@@ -679,7 +681,6 @@ static int virtio_net__init_one(struct virtio_net_params 
*params)
                ndev->info.guest_ip             = 
ntohl(inet_addr(params->guest_ip));
                ndev->info.guest_netmask        = 
ntohl(inet_addr("255.255.255.0"));
                ndev->info.buf_nr               = 20,
-               ndev->info.vnet_hdr_len         = sizeof(struct virtio_net_hdr);
                ndev->ops = &uip_ops;
        }
 
@@ -710,6 +711,9 @@ static void notify_status(struct kvm *kvm, void *dev, u8 
status)
                if (!virtio_net__tap_init(ndev))
                        die_perror("You have requested a TAP device, but 
creation of one has failed because");
        } else {
+               ndev->info.vnet_hdr_len = (ndev->features & (1 << 
VIRTIO_NET_F_MRG_RXBUF)) ?
+                                               sizeof(struct 
virtio_net_hdr_mrg_rxbuf) :
+                                               sizeof(struct virtio_net_hdr);
                uip_init(&ndev->info);
        }
 }
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to