From nobody Mon Nov 23 04:27:59 2026 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794334062; cv=none; d=zohomail.com; s=zohoarc; b=geWWHkvgE7Tf/JcJlVLRaEshTehIyPNLGiJg0iVFhuEwq12Rc1dzHKL99aHUuIrc+rOO2hsrgk7fjJEKpu9Ktfj8a/h5+SvAwMCZXyNVFV46glKNhuiAc9zlDQT9Gb8hfQ+BOMOV2V/A1rzV1GkfETzbeTcT/lM+CzYOPl5yUII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794334062; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fP6hp4P+erJ9gJfxTUKysDGWbM+GXPKl+5MRuAY0a4w=; b=VSS6JYx0rwtLPV07C4aWJz32YUE8A/1Wc+o8rzh7NxaoqHQKqjJ13mv7/sjrCViJhv0hnIf8E6PgDVsMvPXDGDTn9JWfSd/vuKoow2oeVtED1uYsTdzBnXifCYdR7+qGFYcBREFoneU2wfQNMtg4fS+mP9sUUvAqt8Cobzkx/7g= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794334062832724.1590861991639; Tue, 10 Nov 2026 10:07:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQqFM-0007DX-FY; Tue, 10 Nov 2026 13:07:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQqFJ-0007Bj-Br for qemu-devel@nongnu.org; Tue, 10 Nov 2026 13:07:01 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450: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 1xQqFH-0000If-DK for qemu-devel@nongnu.org; Tue, 10 Nov 2026 13:07:01 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-48dfc0421d9so2024321f8f.1 for ; Tue, 10 Nov 2026 10:06:58 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-498369a3f4esm6825701f8f.53.2026.11.10.10.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 10:06:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794334018; x=1794938818; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=fP6hp4P+erJ9gJfxTUKysDGWbM+GXPKl+5MRuAY0a4w=; b=FuPS92S6k0GYHOQuLMQkF9+5QShVKjED5oPXgZ9S20/snTXFZYoyX7jrwj29mxNZBk FwQkK4YEneqCqUOu8Cx9PUJTK7G2zdCiQndHEfQq9rUo25uHxx36E5yg7r3zWxvCsOII jJZ+FbiigrLiutzyjwZogsIHEfmk3/ePG3Ap5A7Z0SWJF0QXC19q4ytFUcMlUhfT89D3 ZJp3ZOqmppmy3AgCedj6RURn7w9c0YtB9D1/R7rr8ctVZ9j9YrtnTgrqJEr9q4HDLjNh dWdMceIDMMbNX91q7EVtLSdAOrFoc9zcOhjsV/gEAy+xIhHHi5g9mGQFlVA1RBo0KfU+ palA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794334018; x=1794938818; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fP6hp4P+erJ9gJfxTUKysDGWbM+GXPKl+5MRuAY0a4w=; b=JgMMTBn48Rfx/utBUAD5dQP7fwmAcMYbJl0oVvzI8IE736BildibfHg0cGlEVBJYHr NYSrPQFDMVq+3zxuWWW4Hyq0X9+W9nClK4F9ZUfYC7jDyBC83YtwQ9/63BqQsR2hDVOR lYqlfGnxPHB4qmY9Vw+DU8izq8FZ9KVRyHzToSi6KMyX0vkpwu4270t8s3W+LEqaLYoS 7GYMyNWJ1AbNg7JzYxjVEl8NpyIZ5pXxdTOy1HqYDpJX4rPS6ssn26d8ZCw9TNWjIJUj gIjRVlxwpk5vZqm7PqmNPYT/XPb0vqjywsoXuh3uROUDHYMQXDVGK4WLudFnr7vTgCvx Z/XQ== X-Gm-Message-State: APuU4Z/EeytOpFzK1YmqFmPc5qXHh2MDZYhEXM3qGONSIKoo+a86/kkY RkX96W+Imqf9ePpe2uxUo92DDkIbkqV+HN1e/qhsqQKGFEbvUChi9cW3yQKbHdZUrT5Wl1VvUEJ RZv/fMnc= X-Gm-Gg: AYBFou1H2BaQekcIbEnGVW0d5GJ3zSwJHotzenoHSMj5DrbOepDdyeVb0NM8udONfeL cMEumOqksa6FhsO2GG4/F6R0LeumBdZzUJ6sM1qL9UQ7yJmSaSYGqvtj+7UvKbY5VuCdPPFUHmg nRW9CtZHuuXMHaJ5s3cPaRzyjYni3mTD8PuNhreEafTxIrJw6g6Ja6+6YE1bETBdMKnCJH/yq+h lZ2aU3DiGKAm8UK3gOkWY0O2F7z408Qz6DaH0Axlr8rklrvsua2Ri7KxNBAi3Zfc/jOYVN5f5qD 2CLm0aXzY1cZvK6qJ3cgz4q+VsDRWiy3G3tk893zMa2yME5ypLVAHsK1akAxSDqYsg6sn6VYa6B oQ2cpruKohWV/RYlz8sQxBAz38JH0lXllAGnx9/l3RR0y0BustDrw74cU4tnFQF+GHdwIFiXibT jjX4sJ9dIzPLsGUKY5G96n0qGm9ATYVCyATv1o5O3WBFQE0xuxYbaa6lQ+h+mKq1zYRK5Yau54C /Kv6hKgZpdYm3N0WZxgNMZXZkrR1DDHgCovZGveoyIWTstGoaGaLorx3+Z72Lm4wXEeqbvX8Qmp SgkoI/xUAagC20g0in4MkEUHdytegZcr7pc5lRT87bZ+7QIc317mp6/ic06psiDrrm8yrv05aKn GXwr4WPToMt06NYkAxrW8dLLa6rAjkP15gA== X-Received: by 2002:a05:6000:a87:b0:48e:824:f0b9 with SMTP id ffacd0b85a97d-4983105fc57mr5598232f8f.45.1794334017698; Tue, 10 Nov 2026 10:06:57 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fabiano Rosas , qemu-stable@nongnu.org, "Dmitry Fleytman" , "Jason Wang" , "Samuel Thibault" , "Laurent Vivier" , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Zhang Chen" , "Li Zhijian" , Akihiko Odaki Subject: [PATCH v2 for-11.2 1/3] tests/qtest: Make netfilter tests accept padded ethernet packets Date: Tue, 10 Nov 2026 18:06:53 +0000 Message-ID: <20261110180655.2072265-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261110180655.2072265-1-peter.maydell@linaro.org> References: <20261110180655.2072265-1-peter.maydell@linaro.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @linaro.org) X-ZM-MESSAGEID: 1794334063661158500 Currently the various netfilter tests assume and assert that the data they get from the filter is an exact match for the data that they send in to it via the net socket backend. This happens to be the case currently because the net socket backend fails to pad frames to the ethernet minimum when the device expects that (unlike e.g. the tap backend). When we fix the socket backend to honour the device's request for padding, the netfilter will see padded packets for devices that require them (which is most of them), and not for those that don't (notably virtio-net). This seems best considered as a test error: if you're using netfilter to look at what a particular network device is receiving, you want to actually see what it is receiving. And most real-world users of filtering will be doing it with the backends like TAP that were already doing pad-before-filter; it's only the oddball backends like 'socket' that forgot to pad. Make the test cases accept as valid both padded and unpadded frames. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/test-filter-buffer.c | 4 +++- tests/qtest/test-filter-mirror.c | 4 +++- tests/qtest/test-filter-redirector.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/qtest/test-filter-buffer.c b/tests/qtest/test-filter-buf= fer.c index 441cbb975ca..418caccf00a 100644 --- a/tests/qtest/test-filter-buffer.c +++ b/tests/qtest/test-filter-buffer.c @@ -11,6 +11,7 @@ #include "qobject/qdict.h" #include "qemu/iov.h" #include "qemu/sockets.h" +#include "net/eth.h" =20 /* * Test that changing interval at runtime affects packet release timing. @@ -148,7 +149,8 @@ static void test_change_interval_timer(void) ret =3D recv(recv_sock, &len, sizeof(len), 0); g_assert_cmpint(ret, =3D=3D, sizeof(len)); len =3D ntohl(len); - g_assert_cmpint(len, =3D=3D, sizeof(send_buf)); + /* The snooped network device might or might not have asked for paddin= g */ + g_assert(len =3D=3D sizeof(send_buf) || len =3D=3D MAX(sizeof(send_buf= ), ETH_ZLEN)); =20 ret =3D recv(recv_sock, recv_buf, len, 0); g_assert_cmpint(ret, =3D=3D, len); diff --git a/tests/qtest/test-filter-mirror.c b/tests/qtest/test-filter-mir= ror.c index 723d2c2f291..9972712cb49 100644 --- a/tests/qtest/test-filter-mirror.c +++ b/tests/qtest/test-filter-mirror.c @@ -15,6 +15,7 @@ #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" +#include "net/eth.h" =20 static void test_mirror(void) { @@ -58,7 +59,8 @@ static void test_mirror(void) g_assert_cmpint(ret, =3D=3D, sizeof(len)); len =3D ntohl(len); =20 - g_assert_cmpint(len, =3D=3D, sizeof(send_buf)); + /* The snooped network device might or might not have asked for paddin= g */ + g_assert(len =3D=3D sizeof(send_buf) || len =3D=3D MAX(sizeof(send_buf= ), ETH_ZLEN)); recv_buf =3D g_malloc(len); ret =3D recv(recv_sock[0], recv_buf, len, 0); g_assert_cmpint(ret, =3D=3D, len); diff --git a/tests/qtest/test-filter-redirector.c b/tests/qtest/test-filter= -redirector.c index 5540c232c0b..a4f9b73c72a 100644 --- a/tests/qtest/test-filter-redirector.c +++ b/tests/qtest/test-filter-redirector.c @@ -57,6 +57,7 @@ #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" +#include "net/eth.h" =20 static void test_redirector_tx(void) { @@ -115,7 +116,8 @@ static void test_redirector_tx(void) g_assert_cmpint(ret, =3D=3D, sizeof(len)); len =3D ntohl(len); =20 - g_assert_cmpint(len, =3D=3D, sizeof(send_buf)); + /* The snooped network device might or might not have asked for paddin= g */ + g_assert(len =3D=3D sizeof(send_buf) || len =3D=3D MAX(sizeof(send_buf= ), ETH_ZLEN)); recv_buf =3D g_malloc(len); ret =3D recv(recv_sock, recv_buf, len, 0); g_assert_cmpint(ret, =3D=3D, len); --=20 2.43.0 From nobody Mon Nov 23 04:27:59 2026 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794334060; cv=none; d=zohomail.com; s=zohoarc; b=bDPiU0u3TZxz9OW7CIVgS/vsxie+rieDUxXRHMkS7uLji0k+vkrS4hUvHtLJp0vNa4jcZZL3LNCl+kmdelvawThqO8l5UEdypVJ/ByRyCmilijDTuhZthjdZcczjXWvo3iAb2WVj/TxBFv9FA8Wpel4w59AMtzOelgYw3B5kbZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794334060; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LaWGF+N6L9EnkTxRhEYuaJ0IgRPyJp84mCq60nLg0F4=; b=dCG/nWpsyd+jNsjMF6TFG/8C8ZFQD93eVu9x00MikHcMdMfs6eEVu2F7z4R0SQg8QgkwtY7Re5+yKou7cHo8ZI8HgyisWZHPZirpC6LCJmttKi7uuWimZ23MtXZ6lIYiOF05Q44SnbG18HM3ZCFXL89RQoIpZSc117Hxpf9vNzY= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17943340608251021.3456581178294; Tue, 10 Nov 2026 10:07:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQqFN-0007EE-3y; Tue, 10 Nov 2026 13:07:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQqFK-0007Cc-SF for qemu-devel@nongnu.org; Tue, 10 Nov 2026 13:07:03 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQqFI-0000Is-Cf for qemu-devel@nongnu.org; Tue, 10 Nov 2026 13:07:02 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-48e46e449e8so1602924f8f.3 for ; Tue, 10 Nov 2026 10:07:00 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-498369a3f4esm6825701f8f.53.2026.11.10.10.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 10:06:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794334019; x=1794938819; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=LaWGF+N6L9EnkTxRhEYuaJ0IgRPyJp84mCq60nLg0F4=; b=iy8wUuQPqeVzSievJ4lOsHnBrSp86KCeL5U7lb5pvMmax67grMsCbjgiDy2SLDssvq rAqtGZid24piOKyS7GEOAo69hn5MxLR+hcFkOwSCY2OqJ1/KcKJDmYFE8RCvMIGW4ApS lkcajdy2Ic7jVxIoeAwTaRq4Nv5zUPPjX7/H45vDdXxqXMgH1SGnsyniwmKqEMLYLT0C qhTsDYqxV48JakHziY2qKRjDFDP8x/yLT9FYAnd07za58KxlMSdNMyCg8uzSB2sx8fit tZneGPpWQbWdoMg/U/xiQWPBPFqL4ZLB5uDxdOUMreg6QwxKIQuhR8NrFhY3AaPJYlwR 31MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794334019; x=1794938819; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=LaWGF+N6L9EnkTxRhEYuaJ0IgRPyJp84mCq60nLg0F4=; b=OhmBJdaajvc8kSaReIzcBc2nf7Op5X3pSJzflYmn6nHoaJfxePkWltOG07jqA2xs04 FCL1BB3SFLtg+cwXUZmpICnRr3F2cNFQBrqCFB1phCA0ePjWNWKNZ8vD0vFzz+ihUpqx WHWiXypn+/mxkexCbmbvDNYCUdoFRyou3+yE48oA+RqP8nZ1wU9/c4xy2MV2OuIRUHX9 YqIq9CqW3EwPwcuYMp78fRHebyRnFK+h4nP7i1k6Qs+OUUJiF7WCaVMdBDJQZdf996uL LEIgkMUUmYivnid495cHt3nOnl/4iGzo5nHQap74lPlp80nKU9Hz/Aoy5cxaa1pr/U/H uEWQ== X-Gm-Message-State: APuU4Z+JtyYPc0DlPqefdsOjgyuZFAZ+ZSD/3TrLXbixgwunIWMkjNAx K1DNGQqZ7FdducgRNRbDTk5H5jrUZ+clQ1ZiPvOeypfO/4UVlPDvzteuOXUuv+MiieSmOG1gAYc WVI8IVSg= X-Gm-Gg: AYBFou0ZSOwNi7lbdidIdLCk7siajhBpzgQd0mhtkDTekBCZng6vVS0lnxar+mhECaB dBq0NWOMarbg5nvzBiJ+ITjNBAY3tidkPqd00/BplWn3N3powCrutvPnUIEGFCQYB5hXERDMY3L O+fmnyI3UWwinSmHeXJt4IdPOsT6n9ai0OShP6r8taAXeg8J4ls5QmnoADXDRpLjTZ8ndBSM6pI KMzFKiqmW6z1Ld5648B1T92DzL2UASBm72JI5jPyX1zJe87zzDgnYL6GK4MLQLIRcbxsZ78Ey7j ElAvN02iyY/NMyb8MnvIWSOff9x9Je1lwCFvmQvfigQFKW5vpyamzvJkx2k3niz+IEE5UOolrmH CZ8psDUwub5dTMOCNOgEtKZy1mXOgOcDYaL7dZ/JKFe9Db40r1XWsCBcUpClc8WJ4wwD1XgqaYN y6gb2fGS4Dfz+ooIE0FtQO0G58M7E8+tv82HkgLfO1bOwF2ZKGREwbndZaoAO6TOCeNTWF4xYQU AC2K3RTXqXv+hjxQP4LtML+Rm9aAahhbKJ6DChAj3jpIDpAhh67t7dJ3STAismTIKPD2fgq1AkX 2Lb1Anldu20YA44nwPAU1zHzd68P21T+iM+H3dkBYTcUwRk1mBFQniIZfzWcPqyVvLu/IQHG/Rv z/aoW0pAvqtkIwMKrCMFa+pgzicqUqQV6hg== X-Received: by 2002:a05:6000:490f:b0:48e:412:3813 with SMTP id ffacd0b85a97d-4993bdb6c5bmr2338251f8f.20.1794334018954; Tue, 10 Nov 2026 10:06:58 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fabiano Rosas , qemu-stable@nongnu.org, "Dmitry Fleytman" , "Jason Wang" , "Samuel Thibault" , "Laurent Vivier" , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Zhang Chen" , "Li Zhijian" , Akihiko Odaki Subject: [PATCH v2 for-11.2 2/3] net: Set do_not_pad for net backends Date: Tue, 10 Nov 2026 18:06:54 +0000 Message-ID: <20261110180655.2072265-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261110180655.2072265-1-peter.maydell@linaro.org> References: <20261110180655.2072265-1-peter.maydell@linaro.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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: qemu development 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 @linaro.org) X-ZM-MESSAGEID: 1794334063691158500 Currently our handling of short network packets (i.e. those which are smaller than the minimum ethernet frame size of 60 bytes) is a little confused. The intention is that we allow network device models to transmit short packets, but we protect them from having to deal with receiving short packets unless they explicitly opt into it. This means we don't have to have a lot of code in each network device to try to handle the short packet size -- historically that code was untested, and often a source of "carefully crafted packet can cause an out-of-bounds memory access" bugs. Our implementation of the padding is currently done when each network backend feeds a packet into the system via one of the qemu_send_packet family of functions. This mostly works, except that we missed some of the more obscure backends (e.g. the socket backend), and it means code duplication in each backend. We'd like to switch to making qemu_send_packet do the padding itself. To do that, we first need to make sure that all the NetClientState implementations which do not want padding set the do_not_pad flag. We do this by setting the flag for NetClientState instances created by qemu_new_net_client() and qemu_new_net_control_client(). Emulated network devices use qemu_new_nic(), which does not set the flag. Note that this also causes the net/hub client to request no padding. This is the right behaviour: we want the hub to accept short packets and forward them on to all destinations. Each destination then gets to choose whether it sees a padded packet or the short one. The hub.c code is length-agnostic and doesn't look inside the packets it is passing on, so it has no issues with short packets. That change means we can rely on do_not_pad being correct for all NetClientInfo structs, and so we can pad short packets in the qemu_send_packet() and qemu_sendv_packet() family of functions. If the callsite is already padding, then this will have no effect, but callsites like the socket and dgram backends will now correctly add padding. This fixes the bug where when two QEMU instances are connected via one of those backends a short ARP packet transmitted by one is not correctly padded by the other and gets dropped. Note that if we pad a packet, our return value on success will be the size of the padded packet, not the original. This is OK because this function (like the NetQueueDeliverFunc function type documented in include/net/queue.h and which we will eventually end up calling and returning the return value of) returns >0 - success 0 - queue packet for future redelivery <0 - failure (discard packet) and doesn't guarantee to return exactly the size of the packet sent. None of the callers try to use the return value as an exact size. Cc: qemu-stable@nongu.org Fixes: CVE-2026-118490 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2362 Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/net/eth.h | 22 ++++++++++++++++++++++ include/net/net.h | 3 ++- net/eth.c | 18 ++++++++++++++++++ net/net.c | 32 ++++++++++++++++++++++++++++---- net/tap.c | 2 +- 5 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/net/eth.h b/include/net/eth.h index 46dc9ed5acd..042b2fc42db 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -437,4 +437,26 @@ eth_parse_ipv6_hdr(const struct iovec *pkt, int pkt_fr= ags, bool eth_pad_short_frame(uint8_t *padded_pkt, size_t *padded_buflen, const void *pkt, size_t pkt_size); =20 +/** + * eth_pad_short_frame_iov - pad a short frame, iovec version + * + * This is equivalent to eth_pad_short_frame(), except that it works + * on a packet stored in a struct iovec. + * + * If the Ethernet frame size is shorter than 60 bytes, it will be padded = to + * 60 bytes at the address @padded_pkt (and the caller will need to handle + * it as a not-in-an-iovec packet). + * + * @padded_pkt: buffer address to hold the padded frame + * @padded_buflen: pointer holding length of @padded_pkt. If the frame is + * padded, the length will be updated to the padded one. + * @iov: iovec holding the original Ethernet frame + * @iovcnt: number of elements in @iov + * @pkt_size: size of the original Ethernet frame (i.e. iov_size(iov, iovc= nt)) + * @return true if the frame is padded, otherwise false + */ +bool eth_pad_short_frame_iov(uint8_t *padded_pkt, size_t *padded_buflen, + const struct iovec *iov, int iovcnt, + size_t pkt_size); + #endif diff --git a/include/net/net.h b/include/net/net.h index de4f03c3013..c2fd451f17e 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -171,7 +171,8 @@ void qemu_net_client_setup(NetClientState *nc, const char *model, const char *name, NetClientDestructor *destructor, - bool is_datapath); + bool is_datapath, + bool do_not_pad); NetClientState *qemu_new_net_client(NetClientInfo *info, NetClientState *peer, const char *model, diff --git a/net/eth.c b/net/eth.c index 12ec316e240..14006222d68 100644 --- a/net/eth.c +++ b/net/eth.c @@ -536,3 +536,21 @@ bool eth_pad_short_frame(uint8_t *padded_pkt, size_t *= padded_buflen, =20 return true; } + +bool eth_pad_short_frame_iov(uint8_t *padded_pkt, size_t *padded_buflen, + const struct iovec *iov, int iovcnt, + size_t pkt_size) +{ + assert(padded_buflen && *padded_buflen >=3D ETH_ZLEN); + + if (pkt_size >=3D ETH_ZLEN) { + return false; + } + + /* pad to minimum Ethernet frame length */ + iov_to_buf(iov, iovcnt, 0, padded_pkt, pkt_size); + memset(&padded_pkt[pkt_size], 0, ETH_ZLEN - pkt_size); + *padded_buflen =3D ETH_ZLEN; + + return true; +} diff --git a/net/net.c b/net/net.c index bf7e5d9b125..7c7fb4bd30e 100644 --- a/net/net.c +++ b/net/net.c @@ -267,7 +267,8 @@ void qemu_net_client_setup(NetClientState *nc, const char *model, const char *name, NetClientDestructor *destructor, - bool is_datapath) + bool is_datapath, + bool do_not_pad) { nc->info =3D info; nc->model =3D g_strdup(model); @@ -287,6 +288,7 @@ void qemu_net_client_setup(NetClientState *nc, nc->incoming_queue =3D qemu_new_net_queue(qemu_deliver_packet_iov, nc); nc->destructor =3D destructor; nc->is_datapath =3D is_datapath; + nc->do_not_pad =3D do_not_pad; QTAILQ_INIT(&nc->filters); } =20 @@ -301,7 +303,7 @@ NetClientState *qemu_new_net_client(NetClientInfo *info, =20 nc =3D g_malloc0(info->size); qemu_net_client_setup(nc, info, peer, model, name, - qemu_net_client_destructor, true); + qemu_net_client_destructor, true, true); =20 return nc; } @@ -317,7 +319,7 @@ NetClientState *qemu_new_net_control_client(NetClientIn= fo *info, =20 nc =3D g_malloc0(info->size); qemu_net_client_setup(nc, info, peer, model, name, - qemu_net_client_destructor, false); + qemu_net_client_destructor, false, true); =20 return nc; } @@ -344,7 +346,7 @@ NICState *qemu_new_nic(NetClientInfo *info, =20 for (i =3D 0; i < queues; i++) { qemu_net_client_setup(&nic->ncs[i], info, peers[i], model, name, - NULL, true); + NULL, true, false); nic->ncs[i].queue_index =3D i; } =20 @@ -742,6 +744,8 @@ static ssize_t qemu_send_packet_async_with_flags(NetCli= entState *sender, { NetQueue *queue; int ret; + uint8_t min_pkt[ETH_ZLEN]; + size_t min_pktsz =3D sizeof(min_pkt); =20 #ifdef DEBUG_NET printf("qemu_send_packet_async:\n"); @@ -752,6 +756,13 @@ static ssize_t qemu_send_packet_async_with_flags(NetCl= ientState *sender, return size; } =20 + if (net_peer_needs_padding(sender)) { + if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) { + buf =3D min_pkt; + size =3D min_pktsz; + } + } + /* Let filters handle the packet first */ ret =3D filter_receive(sender, NET_FILTER_DIRECTION_TX, sender, flags, buf, size, sent_cb); @@ -906,6 +917,19 @@ ssize_t qemu_sendv_packet_async(NetClientState *sender, return size; } =20 + if (net_peer_needs_padding(sender)) { + uint8_t min_pkt[ETH_ZLEN]; + size_t min_pktsz =3D sizeof(min_pkt); + + /* + * If we pad the packet, we get back a simple buffer, so handle + * it by sending it to the non-iov qemu_send_packet function + */ + if (eth_pad_short_frame_iov(min_pkt, &min_pktsz, iov, iovcnt, size= )) { + return qemu_send_packet_async(sender, min_pkt, min_pktsz, sent= _cb); + } + } + /* Let filters handle the packet first */ ret =3D filter_receive_iov(sender, NET_FILTER_DIRECTION_TX, sender, QEMU_NET_PACKET_FLAG_NONE, iov, iovcnt, sent_= cb); diff --git a/net/tap.c b/net/tap.c index 9bce0d088f9..ee6430d34a5 100644 --- a/net/tap.c +++ b/net/tap.c @@ -627,7 +627,7 @@ static TAPState *new_tap(NetClientState *peer, TAPState *s =3D TAP_NETDEV(object_new(TYPE_TAP_NETDEV)); =20 qemu_net_client_setup(&s->nc, &net_tap_info, peer, model, name, - tap_net_client_destructor, true); + tap_net_client_destructor, true, true); =20 s->queue_index =3D queue_index; =20 --=20 2.43.0 From nobody Mon Nov 23 04:27:59 2026 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1794334073; cv=none; d=zohomail.com; s=zohoarc; b=CatIX7mkr4Aj41Kiwa9/3w9zJJvEFwxctNfOl5oCDeEj60mfW7VwaebZSw99cLOyKDNSS2rfw26QWwKrjym6sI8kD6BdDRUmHu3ynWAryoK1etfDSzxvM/bCA2N62x3vOOarvpWR1miO3kQcArt1c22WJ90GBK3sVWHSZ083hW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794334073; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vWUKlujesHAaIn6IDqfcnh3YdDOi8lwA7YWzYsX797w=; b=O8rBYTmTk/TNwND1cd+G1aNQdwiyLh4mivYeqXejHjG1G5U2zn2je6VB7IyWHw5YJkjYp6M/tJPCXxigjnCDmTmF9dyKxb8W5P2YcpFNZDhpBFgZfP0tTE0NqJNMDSWoPBIC6ynLjYneYVmRSVB1OeSHC4FDB8tc+uEfwk5bjcA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794334073759177.98633334745182; Tue, 10 Nov 2026 10:07:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQqFO-0007EV-3q; Tue, 10 Nov 2026 13:07:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQqFM-0007Dd-JW for qemu-devel@nongnu.org; Tue, 10 Nov 2026 13:07:04 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xQqFK-0000JS-0x for qemu-devel@nongnu.org; Tue, 10 Nov 2026 13:07:03 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-4918c2d727fso1283789f8f.3 for ; Tue, 10 Nov 2026 10:07:01 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-498369a3f4esm6825701f8f.53.2026.11.10.10.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 10:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794334020; x=1794938820; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=vWUKlujesHAaIn6IDqfcnh3YdDOi8lwA7YWzYsX797w=; b=bENmdAsqc3cHiH4KLEWeprjceaolDm/bnHlWH2qja3ZKnJkzFABAKSiMJKr3hChruJ aSqx+4m+t+AdXMIU1X/Ytte4qEK15bfbt/bKtw+Ph0ICObrCiS7bcwZbKRgtl+pEKStI kTHT+AhHbRMQgjoEw+NMQa5NBwfhYT8ODK7mIz3GocQS1/Yb8k2/+Y44dgE1NLTiQkm+ YEBcE/DSRNfcycIxnoZP/qg2a584bIOOIE0XqzgxhU5bh8DhSi63a7W1NsjMyv37DVfz VI3IknlP0gcQ3am13PrIumqbiQNNNWGWKwUXivaHkCGBSsTR9Xt3F7S6DQwz32XrAXDW VXkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794334020; x=1794938820; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vWUKlujesHAaIn6IDqfcnh3YdDOi8lwA7YWzYsX797w=; b=Ky7URSmxsYk3m7+Z3jl7925n+GbrzHithr1hZiYk21/X4/8fdgcPiqF0Htt6+WRhic MW/NmP/iFPnqC6wXK3Ul5Rq52/zG8yLPy0P779DTuiC03jrI9pUVkAs61/iuP/x5dY+T I4pJtvIqoWCMvNXV9lCX3+CISOlmWr2iuRrjUWIFe0k8Qpj0L9BhYwVNh/oH7mHgVHpL 5KjUKnnuPErrP9UseHASPIavEVPHUMR2UC+YXzubQ4pB4Njt313rSDoI5ANku4tleURv dgro90WygdHR74op1gQw4T3vJCPBwsQ7gv1/ZGCrIr1ZQYXC2KkKgSrUoTkKuR/x327l lG+A== X-Gm-Message-State: APuU4Z+WgmPk7zo2UYcAvA6LLFggIc0h22htnNclD/lrlh33qSxHOk+T il2jtQLBgsjX3qZ+w7louJYiFyDck6CBmCBFAcU6d3rGkyY3MVf8YHNeAA75ZPClQ6MHxG0AaCe ZGjQh69g= X-Gm-Gg: AYBFou0zqR1ChG4CMK6P8vmF6RvgMa7t/IZOU8a2kJ4P0O+WiHRTlFMmlax0ogq0s4j VttPJ1a3TVUd+Q8uu02uVFWpr7OO+0HywPOLssCv2EKjjivIpolo63B+kWHN9MXMQ7zPcgCQB/Z vLpfYvPHFLei0Ou4CQ+ie0qJjgZuYkgXh2Ir5xgrmFTTgQc7w9OBjwKToIVQM+yxFMcljpJvFwB 0DNuXR0CNkp+X2fca63AHObo4ySHfuiaXekA1LB6+2lU+jqt/TomsYemNv/PfI9L28miZ8FhaJj mKzvOtqmoFYxcaJm5ttmRCKrVcQfPXVwpxl86gObOrnGcvQ+IauNoFGktv+0FZsMBe/Exq9sRb7 q60RsrJGB6u/W6vpu1hgU2TPigRaWmVpQnRNDAbSd4cK5yoK6nDvVahC4mIvPrj8ZeX2ke9hop/ 47Gg8/zH1WHLCcWFdy8H+Lw9PeKTKHAlHa1E0niAytz1JfOBJuTom5YkieW0rpdtZruI2wM3bdg jEqEZCRubjGGtOo7zhDj4a//iDl92m1PDtWpKm/EIiLXUYPRWCbpis1cUU72D8eyrRd1q4vN7Ru HMtrYcgWonolIbvh0C2XtAzaqYhmR8MAukfkugGfNauWHcxwdl78pwGgGrCXiVK/lwj9kVS8k6m AItGlw32xBEXBKkwDcI6Wr5lWPCgK1cbyBWTk5s6ciuGEdYbYcmZ9osE= X-Received: by 2002:a05:6000:26c6:b0:48e:6f84:2e8e with SMTP id ffacd0b85a97d-498307c5073mr6574740f8f.39.1794334020292; Tue, 10 Nov 2026 10:07:00 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fabiano Rosas , qemu-stable@nongnu.org, "Dmitry Fleytman" , "Jason Wang" , "Samuel Thibault" , "Laurent Vivier" , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Zhang Chen" , "Li Zhijian" , Akihiko Odaki Subject: [PATCH v2 for-11.2 3/3] net: Remove padding code from net backends Date: Tue, 10 Nov 2026 18:06:55 +0000 Message-ID: <20261110180655.2072265-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261110180655.2072265-1-peter.maydell@linaro.org> References: <20261110180655.2072265-1-peter.maydell@linaro.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @linaro.org) X-ZM-MESSAGEID: 1794334075921158500 We can remove the short-frame padding code from the net backends that were previously doing it, because the qemu_send_packet and qemu_sendv_packet calls they use now do the padding for them. Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau --- net/slirp.c | 9 --------- net/tap-win32.c | 15 ++------------- net/tap.c | 9 --------- net/vmnet-common.m | 11 ----------- 4 files changed, 2 insertions(+), 42 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index 451c0fd1ba4..eea12e79816 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -120,15 +120,6 @@ static ssize_t net_slirp_send_packet(const void *pkt, = size_t pkt_len, void *opaque) { SlirpState *s =3D opaque; - uint8_t min_pkt[ETH_ZLEN]; - size_t min_pktsz =3D sizeof(min_pkt); - - if (net_peer_needs_padding(&s->nc)) { - if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pkt_len)) { - pkt =3D min_pkt; - pkt_len =3D min_pktsz; - } - } =20 return qemu_send_packet(&s->nc, pkt, pkt_len); } diff --git a/net/tap-win32.c b/net/tap-win32.c index 38baf90e0b3..2fccfdbaacf 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -682,25 +682,14 @@ static ssize_t tap_receive(NetClientState *nc, const = uint8_t *buf, size_t size) static void tap_win32_send(void *opaque) { TAPState *s =3D opaque; - uint8_t *buf, *orig_buf; + uint8_t *buf; int max_size =3D 4096; int size; - uint8_t min_pkt[ETH_ZLEN]; - size_t min_pktsz =3D sizeof(min_pkt); =20 size =3D tap_win32_read(s->handle, &buf, max_size); if (size > 0) { - orig_buf =3D buf; - - if (net_peer_needs_padding(&s->nc)) { - if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) { - buf =3D min_pkt; - size =3D min_pktsz; - } - } - qemu_send_packet(&s->nc, buf, size); - tap_win32_free_buffer(s->handle, orig_buf); + tap_win32_free_buffer(s->handle, buf); } } =20 diff --git a/net/tap.c b/net/tap.c index ee6430d34a5..9f3d0b08ab7 100644 --- a/net/tap.c +++ b/net/tap.c @@ -261,8 +261,6 @@ static void tap_send(void *opaque) =20 while (true) { uint8_t *buf =3D s->buf; - uint8_t min_pkt[ETH_ZLEN]; - size_t min_pktsz =3D sizeof(min_pkt); =20 size =3D tap_read_packet(s->fd, s->buf, sizeof(s->buf)); if (size <=3D 0) { @@ -279,13 +277,6 @@ static void tap_send(void *opaque) size -=3D s->host_vnet_hdr_len; } =20 - if (net_peer_needs_padding(&s->nc)) { - if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) { - buf =3D min_pkt; - size =3D min_pktsz; - } - } - size =3D qemu_send_packet_async(&s->nc, buf, size, tap_send_comple= ted); if (size =3D=3D 0) { tap_read_poll(s, false); diff --git a/net/vmnet-common.m b/net/vmnet-common.m index ab33ce2b0c2..4dfc8abbc15 100644 --- a/net/vmnet-common.m +++ b/net/vmnet-common.m @@ -150,23 +150,12 @@ 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; =20 while (s->packets_send_current_pos < s->packets_send_end_pos) { 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; =20 - 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 --=20 2.43.0