On 9/12/26 12:57, Ammar Yasser wrote:
On Wed Sep 9, 2026 at 3:35 PM EEST, Laurent Vivier wrote:
On 9/4/26 23:28, aerosouund wrote:
From: Ammar Yasser
+ * The only structural limit the QEMU socket protocol imposes on frames is + * (2^32-1) bytes, but that would be ludicrously long in practice. For now, + * limit it somewhat arbitrarily to 65535 bytes. FIXME: Work out an appropriate + * limit with more precision. + */ +#define L2_MAX_LEN_PASST USHRT_MAX + +/** L2_MAX_LEN_VU - Maximum frame length for vhost-user mode (with L2 header) + * + * vhost-user allows multiple buffers per frame, each of which can be quite + * large, so the inherent frame size limit is rather large. Much larger than is + * actually useful for IP. For now limit arbitrarily to 65535 bytes. FIXME: + * Work out an appropriate limit with more precision. + */ +#define L2_MAX_LEN_VU USHRT_MAX + +/* Number of descriptors in each vhost-net virtqueue */ +#define VHOST_NDESCS 128 + +/* Bytes of pkt_buf backing one from-guest descriptor: a maximum size frame + * plus the virtio-net header the kernel writes in front of it + */ +#define VHOST_DESC_BYTES (L2_MAX_LEN_PASTA + \ + sizeof(struct virtio_net_hdr_mrg_rxbuf)) + +/* One maximum size frame per vhost-net descriptor */bbb +#define PKT_BUF_BYTES (VHOST_NDESCS * VHOST_DESC_BYTES)
128 * (65535 + 12) = 8390016
but we have in passt.c
madvise(pkt_buf, sizeof(pkt_buf), MADV_HUGEPAGE);
originaly we had:
2dbed699e78e ("passt: Align pkt_buf to PAGE_SIZE (start and size), try to fit in huge pages")
And your change is reverting the logic of:
b6945e055376 ("Simplify sizing of pkt_buf")
Hmm, i see the reasoning behind why it was this way before now. Generally speaking, i think it's pretty unlikely that the there will be a time where the packet buffer will be completely full (the kernel queued 128 packets and i didn't process any). Only in this case would the fact that this buffer is 8MB and doesn't have space for the virtio_net_mrg_rxbuf cause problems. So maybe we can just put it back to be 8MB. what do you think ?
I think we can keep the original value.
+ ret.iov_len = sizeof(struct virtio_net_hdr_mrg_rxbuf); + } else { + ret.iov_len = c->mode == MODE_PASST ? sizeof(thdr->vnet_len) : 0; + };
no need for the semicolon.
This change should be in PATCH 1
This won't work unfortunately. Since this change depends on the fields added to the context. the c->vhost.fd field
I was speaking about the sizeof(thdr->vnet_len) Thanks, Laurent>>
+ + return ret; }
/**