We want to make the size of the virtio net header opaque to uip. Signed-off-by: Sasha Levin <sasha.levin@xxxxxxxxxx> --- tools/kvm/include/kvm/uip.h | 1 + tools/kvm/net/uip/core.c | 8 ++++---- tools/kvm/net/uip/tcp.c | 2 +- tools/kvm/net/uip/udp.c | 2 +- tools/kvm/virtio/net.c | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/kvm/include/kvm/uip.h b/tools/kvm/include/kvm/uip.h index ac248d2..338582d 100644 --- a/tools/kvm/include/kvm/uip.h +++ b/tools/kvm/include/kvm/uip.h @@ -205,6 +205,7 @@ struct uip_info { u32 dns_ip[UIP_DHCP_MAX_DNS_SERVER_NR]; char *domain_name; u32 buf_nr; + u32 vnet_hdr_len; }; struct uip_buf { diff --git a/tools/kvm/net/uip/core.c b/tools/kvm/net/uip/core.c index 4e5bb82..7a74261 100644 --- a/tools/kvm/net/uip/core.c +++ b/tools/kvm/net/uip/core.c @@ -172,10 +172,10 @@ int uip_init(struct uip_info *info) } list_for_each_entry(buf, buf_head, list) { - buf->vnet = malloc(sizeof(struct virtio_net_hdr)); - buf->vnet_len = sizeof(struct virtio_net_hdr); - buf->eth = malloc(1024*64 + sizeof(struct uip_pseudo_hdr)); - buf->eth_len = 1024*64 + sizeof(struct uip_pseudo_hdr); + buf->vnet_len = info->vnet_hdr_len; + buf->vnet = malloc(buf->vnet_len); + buf->eth_len = 1024*64 + sizeof(struct uip_pseudo_hdr); + buf->eth = malloc(buf->eth_len); memset(buf->vnet, 0, buf->vnet_len); memset(buf->eth, 0, buf->eth_len); diff --git a/tools/kvm/net/uip/tcp.c b/tools/kvm/net/uip/tcp.c index 9044f40..3c30ade 100644 --- a/tools/kvm/net/uip/tcp.c +++ b/tools/kvm/net/uip/tcp.c @@ -153,7 +153,7 @@ static int uip_tcp_payload_send(struct uip_tcp_socket *sk, u8 flag, u16 payload_ /* * virtio_net_hdr */ - buf->vnet_len = sizeof(struct virtio_net_hdr); + buf->vnet_len = info->vnet_hdr_len; memset(buf->vnet, 0, buf->vnet_len); buf->eth_len = ntohs(ip2->len) + uip_eth_hdrlen(&ip2->eth); diff --git a/tools/kvm/net/uip/udp.c b/tools/kvm/net/uip/udp.c index 31c417c..dd288c5 100644 --- a/tools/kvm/net/uip/udp.c +++ b/tools/kvm/net/uip/udp.c @@ -142,7 +142,7 @@ int uip_udp_make_pkg(struct uip_info *info, struct uip_udp_socket *sk, struct ui /* * virtio_net_hdr */ - buf->vnet_len = sizeof(struct virtio_net_hdr); + buf->vnet_len = info->vnet_hdr_len; memset(buf->vnet, 0, buf->vnet_len); buf->eth_len = ntohs(ip2->len) + uip_eth_hdrlen(&ip2->eth); diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c index c0a8f12..2de9222 100644 --- a/tools/kvm/virtio/net.c +++ b/tools/kvm/virtio/net.c @@ -668,6 +668,7 @@ 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); uip_init(&ndev->info); ndev->ops = &uip_ops; } -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html