diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-05-18 13:40:55 +0100 |
---|---|---|
committer | Mark McLoughlin <markmc@redhat.com> | 2009-06-09 11:38:49 +0100 |
commit | 4f1c942b7fb29864ad86cb3af9076da38f38f74e (patch) | |
tree | 2f51a121e715476c3986c0ae0b4513be555d8ee8 /hw/virtio-net.c | |
parent | e3f5ec2b5e92706e3b807059f79b1fb5d936e567 (diff) |
net: add return value to packet receive handler
This allows us to handle queue full conditions rather than dropping
the packet on the floor.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'hw/virtio-net.c')
-rw-r--r-- | hw/virtio-net.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 1ffebac222..6b34c5afc1 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -361,17 +361,17 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) return 0; } -static void virtio_net_receive(VLANClientState *vc, const uint8_t *buf, size_t size) +static ssize_t virtio_net_receive(VLANClientState *vc, const uint8_t *buf, size_t size) { VirtIONet *n = vc->opaque; struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL; size_t hdr_len, offset, i; if (!do_virtio_net_can_receive(n, size)) - return; + return -1; if (!receive_filter(n, buf, size)) - return; + return size; /* hdr_len refers to the header we supply to the guest */ hdr_len = n->mergeable_rx_bufs ? @@ -389,7 +389,7 @@ static void virtio_net_receive(VLANClientState *vc, const uint8_t *buf, size_t s if ((i != 0 && !n->mergeable_rx_bufs) || virtqueue_pop(n->rx_vq, &elem) == 0) { if (i == 0) - return; + return -1; fprintf(stderr, "virtio-net truncating packet\n"); exit(1); } @@ -431,6 +431,8 @@ static void virtio_net_receive(VLANClientState *vc, const uint8_t *buf, size_t s virtqueue_flush(n->rx_vq, i); virtio_notify(&n->vdev, n->rx_vq); + + return size; } /* TX */ |