From nobody Sat Nov 23 20:38:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1730581085; cv=none; d=zohomail.com; s=zohoarc; b=i5A4pPqNU6moRTSCslLyyvUFQSSXtljLhmlCKgwm/bjvBQjvQgMSmEC3frSe8zqCWbui/MbQzPhkM6Rgs2NoNRF1lwm9PBA060EvVH2ctLp5brAGY6ciBFdzsGpvnOTqjr6pGUFVcnT1wY3X1aQiPDjD4+veg8mQSOqOdyVNCvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730581085; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YWiSh8qhBF5hdQNW3uEFIh3fsWF3IYhFSQHrFmKnx9s=; b=k2OTFTVOQ3YUuuKWSDmIdXBWS+G8yOHicXxj0IYKAMXzNL2u4vApfJ7CtozldxZE6MglivGd4yHbdc9u6Q8kgy1MwAtIp1P7usxUu1/xQWC5DmaLR2jAKwKY94+KU7tX2dRrsuznHylof5baUn4IhhhdskL73pNjOc37PP+AarI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730581085175173.8150077449984; Sat, 2 Nov 2024 13:58:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7LB7-0006yk-PM; Sat, 02 Nov 2024 16:57:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t7LB6-0006yb-Oq for qemu-devel@nongnu.org; Sat, 02 Nov 2024 16:57:01 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t7LB4-00083p-Pk for qemu-devel@nongnu.org; Sat, 02 Nov 2024 16:57:00 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7206304f93aso2867130b3a.0 for ; Sat, 02 Nov 2024 13:56:58 -0700 (PDT) Received: from localhost.localdomain (syn-076-081-243-074.biz.spectrum.com. [76.81.243.74]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ee45298a89sm4243132a12.16.2024.11.02.13.56.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 02 Nov 2024 13:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wshooper-org.20230601.gappssmtp.com; s=20230601; t=1730581016; x=1731185816; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YWiSh8qhBF5hdQNW3uEFIh3fsWF3IYhFSQHrFmKnx9s=; b=Pk4nQVE++pGCoaY1Is6prdAnx7LWimjFCxmVDa/zzNTRkQfQfStmNzYwYXCj+rib+/ c8UPdDoMxjX4aBlzwYl2MjI7XjnDFi7PEY2/yVHVJ3KG8Y9AGthctrhwtiUN8uRQD+P1 Gv+7tFTFb5CcKrdoygrx9rN8If9twfUOrq8rkAK3FvW6VuFhgJ0kngNJqXrpAvEjqNlC cPbtqBui640Tcqg8UZCL/RtauVIqei9l3iLMAFGbpHMbqvQ9k8Shp86qDXf989zh29oZ 1+5HclBrUPRZQK0zWeQ1ybShRv+T28KWWAFGJBl4glbXbxsLx5aMdFX5Ew3piwUz0NCt +Nvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730581016; x=1731185816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YWiSh8qhBF5hdQNW3uEFIh3fsWF3IYhFSQHrFmKnx9s=; b=L+KYmbtsQLYcY4aV8pja4yXAWPrLs4R++nX4RxAC6EidQmVQ7lEjHgjqlDq0Ny8m78 sKLte2y2kCcnxTaiQPNQOyKdjUGNLP8lzpK9HVpwDJTd62vNz+fXAhhsfqtrRYWO15Vz mCHJX6eUTYUj8vJN3Ujgxy8hZE5TvGEI2x5XZ/9PcJ2ngzOq5jJ0bn3vMKcFyu0wN6P4 S5zWp/zl0PASQQUdHnLORNxr00scr6hsQfVl9vBNJH1uWZQet7ja8Tuuq7rjgsu/mMCm DTORWNnDIALosxcu+8olgDWBta9pSKCE10o7NlQiGFma6UQUDzYujspmfz6yi013jgJZ xfSA== X-Gm-Message-State: AOJu0YxKU8OKGuAzlvZH+Q4376hnHqNIfJYCUWztvVoclRtoOoK13rzD SuV3VjLauBTrdfPvhA7n1HzUlfSCl8ZRinNFOBIamKXQuAGHnKxp0uY0HCF3+mA91hI4ObitJu0 LLno= X-Google-Smtp-Source: AGHT+IH8ovnYlsPjwWHd1V4Ij/cgrrTi6x9vaqhkqkLB0VoV5minrhJ4lSy8BuN0EreNsPky6b0zHQ== X-Received: by 2002:a05:6a00:3d51:b0:71e:cd0:cc99 with SMTP id d2e1a72fcca58-720c98a1bfamr12661172b3a.4.1730581016227; Sat, 02 Nov 2024 13:56:56 -0700 (PDT) From: William Hooper To: qemu-devel@nongnu.org Cc: Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Phil Dennis-Jordan Subject: [PATCH v3] net/vmnet: Pad short Ethernet frames Date: Sat, 2 Nov 2024 13:56:53 -0700 Message-Id: <20241102205653.30476-1-wsh@wshooper.org> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::42c; envelope-from=wsh@wshooper.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @wshooper-org.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1730581086623116600 At least on macOS 12.7.2, vmnet doesn't pad Ethernet frames, such as the host's ARP replies, to the minimum size (60 bytes before the frame check sequence) defined in IEEE Std 802.3-2022, so guests' Ethernet device drivers may drop them with "frame too short" errors. This patch calls eth_pad_short_frame() to add padding, as in net/tap.c and net/slirp.c. Thanks to Bin Meng, Philippe Mathieu-Daud=C3=A9, and Phil Dennis-Jordan for reviewing earlier versions. Signed-off-by: William Hooper Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2058 Reviewed-by: Phil Dennis-Jordan --- net/vmnet-common.m | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index 30c4e53c13..4b7e330c05 100644 --- a/net/vmnet-common.m +++ b/net/vmnet-common.m @@ -18,6 +18,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "sysemu/runstate.h" +#include "net/eth.h" =20 #include #include @@ -147,10 +148,26 @@ static int vmnet_read_packets(VmnetState *s) */ static void vmnet_write_packets_to_qemu(VmnetState *s) { + uint8_t *pkt; + size_t pktsz; + uint8_t min_pkt[ETH_ZLEN]; + size_t min_pktsz; + ssize_t size; + while (s->packets_send_current_pos < s->packets_send_end_pos) { - ssize_t size =3D qemu_send_packet_async(&s->nc, - s->iov_buf[s->packets_send_current_p= os].iov_base, - s->packets_buf[s->packets_send_curre= nt_pos].vm_pkt_size, + pkt =3D s->iov_buf[s->packets_send_current_pos].iov_base; + pktsz =3D s->packets_buf[s->packets_send_current_pos].vm_pkt_size; + + if (net_peer_needs_padding(&s->nc)) { + min_pktsz =3D sizeof(min_pkt); + + if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pktsz)) { + pkt =3D min_pkt; + pktsz =3D min_pktsz; + } + } + + size =3D qemu_send_packet_async(&s->nc, pkt, pktsz, vmnet_send_completed); =20 if (size =3D=3D 0) {