From patchwork Tue Dec 31 20:22:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854422 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090185wrq; Tue, 31 Dec 2024 12:26:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX7DFUirg2TkgNyH0rGJHJZOwwl8WaIqzTI3M5PhSX6/GLNalkGNw9ecpdFxD1KE8qwIF64gQ==@linaro.org X-Google-Smtp-Source: AGHT+IHOUhFw0Fky2z19PGslssiIfy1aUs7ICiF8JjHixVZkZkQowdm841WkayTv5qNiAdWuDWRN X-Received: by 2002:ac8:5751:0:b0:465:3a62:a8f9 with SMTP id d75a77b69052e-46a4a9a436dmr795939031cf.50.1735676772792; Tue, 31 Dec 2024 12:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676772; cv=none; d=google.com; s=arc-20240605; b=N9WUcCGhTTeZX4khMSw7UFu4pVOVkLf76k8SRX8x4qkeZ65CZyF99ltDrOmN4RWjI0 UPrJCuG0dW89V5cSzZ/Uu+iuIS3wRDBvC52kT5NLeT7czYl07wwweNozaXQOcScIz7Rs fEGZj/Vtj/uHnrXa5H2axEGC3tnqw5g8va0AVKFipmyCPpuLdxjhn1oDz6G6L0F+QhM+ WkJudOjtFXOzlkLSuSwVZsrx6OMA/3Yx0xSGsUQs2Uj4512eevFrnF6L/trwdD8zh5qa KmLSuClPFj7WlQEGbcQ2eUpJCJGs2M2vMvuj2JAon5Zz69eiCgeHr862WxYvwy8g3uJg tEEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AloPmLUtJIdEn3N27rO6zDqGnD5UcjWX7RRR5V1X2ow=; fh=uFXjJShbbTDTIBTXW3Ai8PxnDc+PR8dmclHLaPJ+IPE=; b=WxBn8oheutjneXNIeph5px07gKH07WM14aW7YCETATHIaDtNsytCW0dzvSGYveZQyi kqwxaNdWKw2ONNHzQG83SA62NB457+xh0+YBb98sUt0SbZajnO0mkhSqtLzivquci9Ya ASTfrhiAytUkA+H0r+DXPsbCadegndVUkC6dyK0SkYYp9MO+YzpDjjAT7eTUCN2yw3V4 8aQbayf+Y6+JZQU0KIi92b8EiIFETpgoqMNqS206pE//1+kNJ0WoYUXeaihORG/AfQQG afcOkaFjS08wROfrBDOXERuxx28G7v52ukCaRFD0A5TOk1CAvrM8wv9pBqBq1VA09P74 Gi8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=snu2RYw0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3e6ad683si330064571cf.195.2024.12.31.12.26.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=snu2RYw0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSini-00026J-Bl; Tue, 31 Dec 2024 15:25:18 -0500 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 1tSinO-0001jP-Qw for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:55 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSinL-00012U-Oc for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:54 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4361f796586so106901725e9.3 for ; Tue, 31 Dec 2024 12:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676688; x=1736281488; 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=AloPmLUtJIdEn3N27rO6zDqGnD5UcjWX7RRR5V1X2ow=; b=snu2RYw09AfV61WBEZGxUx/cihUsE4gekL+Zmxfic+lEOcMxuwKRJbrUuXQNVYRang vXfDRIOUUiR3gN2gmDLEjEm+rL/cPfxSVZOr0mKwsdUYS+Qs2rEy6wTmAzmyVF8oZkZm GOsTZklIktlU2ATK2blJeyobb/yc2IvOzhY3u0i55cyNv19ym0qyadrduRviIGgQL17d bj4FQwD8X8kUKvhkV4t9lXPG6fIGE5hHckCUkw9cQ69oenY6s6bgjB9cDqvMJdP8vivS uBJlGHTrPaz7cL9VfwgKJgyADqTQo8KSfa8Zr+Y6lTI4KZXQ4R8JFNeC/LFgC8LCqsBb qYcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676688; x=1736281488; 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=AloPmLUtJIdEn3N27rO6zDqGnD5UcjWX7RRR5V1X2ow=; b=hOlw3MK1mRs9mYKMzVJQgOWs+qxSes6dhqtOZLASCVdKiDxqwEHiTzugu7ffEWfTGk tgZ7s64f8IiwY4w/wWbKbjn6b6tuVz12nlleyiEx53XLu/5cDsNqNUvKAEbsDDbbvhky Rt1v6t5GFHxOWOqNWt9JX9O6z2KIYvT7L6FbSZ/SGPCRIueaSDDjxP6QlKnc4LvsPM38 phmlU9Dc5tGwDIs0WMAkyHcSMnVGWF06Hwe9VWx4TNwnSjQ1c789KLypLWvDmAd+c3CT 9Sro9vscQVU77L+jjX665JyrYSKF35tbN6F7V5r9PoAJFCpi+YiR7oOPM/cLXV2vDxd3 XB3g== X-Gm-Message-State: AOJu0Yyx0tP2deqyk+bD+BxbEIyQw750KLFHD3IutUFfsfHwDDWfpF/g +NuYmfDFVLrw4OclPQIpQBqDpaMIVkGxaOcOgFGR0aZ5e34ZZmfCZR9ATG3xJ7X5dbdw9mtGDa9 A3U8= X-Gm-Gg: ASbGncvxjdxmru6Qo67coUU/kA/3cvtlHwRApe9h6UygiyEnKOO8WWN8AwnejOr1H+k Sq6g/mopeQtUjhU2BRDH1TTHyiQFA24IV9zvYJLRsV88bLJVduaURJqSYlqlDTXABNSI+xlBrXK IeFFAqocLQlRYc21/AA5b2QAuapCJEICIw4agySzBDjUEMUGqwH9CAmZteD8dcWaVGFeDbtCZ8H 6UvseRePlfYWSttD2k970KkDvDjICwM0HTHjG4sDBg1Jd3Ya4l/HaNw2KHlvIQfXyzP7h64twFs u6dzGGaSJmKdbjaSDDc6UJiBAlqXi1I= X-Received: by 2002:a05:600c:4f95:b0:428:d31:ef25 with SMTP id 5b1f17b1804b1-4366854c111mr370799555e9.12.1735676687957; Tue, 31 Dec 2024 12:24:47 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b119ccsm431476045e9.24.2024.12.31.12.24.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: William Hooper , Phil Dennis-Jordan , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 28/29] net/vmnet: Pad short Ethernet frames Date: Tue, 31 Dec 2024 21:22:27 +0100 Message-ID: <20241231202228.28819-29-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: William Hooper 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é, 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 Message-ID: <20241102205653.30476-1-wsh@wshooper.org> Signed-off-by: Philippe Mathieu-Daudé --- 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 dba5b5bab13..54d900ba679 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 "system/runstate.h" +#include "net/eth.h" #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 = qemu_send_packet_async(&s->nc, - s->iov_buf[s->packets_send_current_pos].iov_base, - s->packets_buf[s->packets_send_current_pos].vm_pkt_size, + pkt = s->iov_buf[s->packets_send_current_pos].iov_base; + pktsz = s->packets_buf[s->packets_send_current_pos].vm_pkt_size; + + if (net_peer_needs_padding(&s->nc)) { + min_pktsz = sizeof(min_pkt); + + if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pktsz)) { + pkt = min_pkt; + pktsz = min_pktsz; + } + } + + size = qemu_send_packet_async(&s->nc, pkt, pktsz, vmnet_send_completed); if (size == 0) {