aboutgitcodebugslistschat
path: root/udp_vu.c
diff options
context:
space:
mode:
Diffstat (limited to 'udp_vu.c')
-rw-r--r--udp_vu.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/udp_vu.c b/udp_vu.c
index 099677f..c30dcf9 100644
--- a/udp_vu.c
+++ b/udp_vu.c
@@ -72,8 +72,8 @@ static int udp_vu_sock_recv(const struct ctx *c, struct vu_virtq *vq, int s,
{
const struct vu_dev *vdev = c->vdev;
int iov_cnt, idx, iov_used;
+ size_t off, hdrlen, l2len;
struct msghdr msg = { 0 };
- size_t off, hdrlen;
ASSERT(!c->no_udp);
@@ -90,7 +90,7 @@ static int udp_vu_sock_recv(const struct ctx *c, struct vu_virtq *vq, int s,
return 0;
/* reserve space for the headers */
- ASSERT(iov_vu[0].iov_len >= hdrlen);
+ ASSERT(iov_vu[0].iov_len >= MAX(hdrlen, ETH_ZLEN));
iov_vu[0].iov_base = (char *)iov_vu[0].iov_base + hdrlen;
iov_vu[0].iov_len -= hdrlen;
@@ -116,6 +116,10 @@ static int udp_vu_sock_recv(const struct ctx *c, struct vu_virtq *vq, int s,
iov_vu[idx].iov_len = off;
iov_used = idx + !!off;
+ /* pad frame to 60 bytes: first buffer is at least ETH_ZLEN long */
+ l2len = *dlen + hdrlen - sizeof(struct virtio_net_hdr_mrg_rxbuf);
+ vu_pad(&iov_vu[0], l2len);
+
vu_set_vnethdr(vdev, iov_vu[0].iov_base, iov_used);
/* release unused buffers */