kvm tools: pass virtio header size to uip_init

We want to make the size of the virtio net header opaque to
uip.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Sasha Levin
2015-06-01 16:39:54 +01:00
committed by Will Deacon
parent 97e65b5f6f
commit 643f6c0857
5 changed files with 8 additions and 6 deletions
+1
View File
@@ -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 {
+4 -4
View File
@@ -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);
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
+1
View File
@@ -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;
}