From nobody Sun Nov 24 11:11:54 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=1723962901; cv=none; d=zohomail.com; s=zohoarc; b=IK+qK+QHtYCu63I8Ki2MpRcayjKuEGN4qpA6HZELgwAVlT0U7xqW9xnhaudPfC8xuawXFIUQSLyed2StN8n7lO76Y/11bF4uDf25TdjyVQwSxt42RPTh0zl1nfuhfqKj4nFyS+oL2VGNj2yhn9JTX/Qflq2qYxdTZJX0P3Qx864= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723962901; 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=0OhiIxpJkNFluxrVI0ZxVzkgEYfQ9vkEsD6MIsBKeP0=; b=G143VDwjTRx3uvlkVudKPkIIVW3DaCOuaKvKWDF/jx2mAJg0kV5y0OZyyN7pQs+9D1v1/IJOuzstKjR0t5wz9un8XtyFXg0gVa7wFsNg7kqSmTnDqoj4FwWSpzPKC40e4M0v/BwHS/1nTAub6D/umAUQgulq1dtaD99zKATDWqk= 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 1723962901448899.3270817351089; Sat, 17 Aug 2024 23:35:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfZUL-0004lQ-Uc; Sun, 18 Aug 2024 02:34:05 -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 1sfZUB-0004kQ-Fu for qemu-devel@nongnu.org; Sun, 18 Aug 2024 02:33:57 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sfZU9-00048E-5K for qemu-devel@nongnu.org; Sun, 18 Aug 2024 02:33:55 -0400 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3db23a608eeso2347416b6e.1 for ; Sat, 17 Aug 2024 23:33:51 -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-7c6b61ca26csm4859210a12.36.2024.08.17.23.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 23:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wshooper-org.20230601.gappssmtp.com; s=20230601; t=1723962830; x=1724567630; 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=0OhiIxpJkNFluxrVI0ZxVzkgEYfQ9vkEsD6MIsBKeP0=; b=1A7XkQSkFTQaDn4Nq0VOu/nC83eBsCczO+n9hGluLygthcTB92rO/lHt0lJBPw8kWD 3Q4uNNslY3kQrdTKFz0HbQIddCOoKx1A8Q/GB6aNOQCcekgdBb1lnHJKIJ45BGpJYLe1 ANV6GtLjLwm7xil0dQKdoNiDmuTClI7EAwaz52pV+zur48C/wZV3QO6TaqaDdvXzL5xq ZdmlX61zTUJUiDkAXEkYTgCTzBx2SL02Yu80DVbayndTuk5fTM8siyPQikObgCGdaCAb lYZLFwVK2vIBg7S58Vqsq2AoLpg8/1YrE5OsKRz1Y6b2YoN66J1EuQBW7qrtbKu0cesZ rq2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723962830; x=1724567630; 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=0OhiIxpJkNFluxrVI0ZxVzkgEYfQ9vkEsD6MIsBKeP0=; b=r9E2J6CTswt0bwrIBs5ZDib2vUIFg8BcGvwsRqzy5bcy3i6+4LNAkI2W7F6obc7xlL sIwYXJEZgNh5wDMbIEEGie1AHn134QlmAOu/i9LWm0Sf4bgYhVpyaIMh48x+OzxlLu2A 2PnnNq7PtsHxy85doC7/mGDqWtJFogPUdeMOFiTXAVW5dcjHbsErmAU7phSCeP+yyB5J vNOF5vq9mdbJxCYb6HKOqQU9rtNsTpWhMrRvJejvcTHfehIH6uuMxHldj0iHCWM3Ex5R iwc7qRWHEZIsrf2m6717XoTrPxlGVzEks5ov/2YQJHhT20/LfMbVks8QP+v1mLBMBAPq is8A== X-Gm-Message-State: AOJu0Yz0ZOS5k4p4ER65U26qbVP6b7jjdLMJ2MkDhIY4Y+5oN76VrIIL CfqgIsLHLLQGIRA4XL/iqrFuZdOmU4CXYBfJYkeeQnLY0gGEX6mm8FpWe6LEzx0XFAl+x41M4gX dBos= X-Google-Smtp-Source: AGHT+IGeUtJi3XMcbJpzSYZwb/yYFee94fQ8CzrMx5A40yCvFS/5GHeqbhyDRNRqbh5NfPGHz9gFiw== X-Received: by 2002:a05:6808:3008:b0:3dd:2c1d:8d08 with SMTP id 5614622812f47-3dd3add4edamr7386230b6e.31.1723962830188; Sat, 17 Aug 2024 23:33:50 -0700 (PDT) From: William Hooper To: qemu-devel@nongnu.org Cc: Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2] net/vmnet: Pad short Ethernet frames Date: Sat, 17 Aug 2024 23:33:44 -0700 Message-Id: <20240818063344.6969-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::236; envelope-from=wsh@wshooper.org; helo=mail-oi1-x236.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1723962904225116600 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 and Philippe Mathieu-Daud=C3=A9 for reviewing an earlier version. Signed-off-by: William Hooper Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2058 Reviewed-by: Phil Dennis-Jordan --- net/vmnet-common.m | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index 30c4e53c13..bce1cc590d 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,25 @@ 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; + 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; + } + } + + ssize_t size =3D qemu_send_packet_async(&s->nc, pkt, pktsz, vmnet_send_completed); =20 if (size =3D=3D 0) { --=20 2.37.1