This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2d9b47d051c7c1cb10942792e9063e240386cdf0 Author: wangzitong7 <[email protected]> AuthorDate: Tue Nov 10 15:21:27 2026 +0800 drivers/virtio/virtio-net: leave room for the 802.1Q tag in the frame buffer A VLAN device inherits the MTU of the real device and vlan_transmit() inserts a 4-byte tag before handing the frame to it, but the virtio-net frame buffer is sized to CONFIG_NET_ETH_PKTSIZE only. A full-sized tagged frame is then rejected by virtio_net_send() with -EINVAL and dropped by the upper half, and an RX buffer cannot hold one either. Add the tag length to VIRTIO_NET_BUFSIZE when CONFIG_NET_VLAN is set. Signed-off-by: wangzitong7 <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/virtio/virtio-net.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/virtio/virtio-net.c b/drivers/virtio/virtio-net.c index dd33137907b..cec2e71e432 100644 --- a/drivers/virtio/virtio-net.c +++ b/drivers/virtio/virtio-net.c @@ -54,7 +54,16 @@ #define VIRTIO_NET_HDRSIZE (sizeof(struct virtio_net_hdr_s)) #define VIRTIO_NET_LLHDRSIZE (sizeof(struct virtio_net_llhdr_s)) -#define VIRTIO_NET_BUFSIZE (CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE) + +/* Largest frame the driver accepts on TX and posts room for on RX. With + * 802.1Q enabled, a VLAN device keeps the MTU of the real device and + * inserts a 4-byte tag in front of the EtherType, so a full-sized tagged + * frame is that many bytes longer than CONFIG_NET_ETH_PKTSIZE. + */ + +#define VIRTIO_NET_BUFSIZE (CONFIG_NET_ETH_PKTSIZE + \ + VIRTIO_NET_ETH_HDRSIZE - ETH_HDRLEN + \ + CONFIG_NET_GUARDSIZE) /* Virtio net virtqueue index and number */
