virtio-net: correctly drop truncated packets
commit0cf33fb6b49a19de32859e2cdc6021334f448fb3
authorJason Wang <jasowang@redhat.com>
Fri, 25 Sep 2015 05:21:30 +0000 (25 13:21 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 1 Oct 2015 13:16:52 +0000 (1 16:16 +0300)
tree56554140568dd3c15161a5a8bce6e95b3ee8229f
parent29b9f5efd78ae0f9cc02dd169b6e80d2c404bade
virtio-net: correctly drop truncated packets

When packet is truncated during receiving, we drop the packets but
neither discard the descriptor nor add and signal used
descriptor. This will lead several issues:

- sg mappings are leaked
- rx will be stalled if a lots of packets were truncated

In order to be consistent with vhost, fix by discarding the descriptor
in this case.

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/net/virtio-net.c