From nobody Mon Nov 23 04:28:04 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=1793123249; cv=none; d=zohomail.com; s=zohoarc; b=D0uGw9qNL4AtJ8SljcdY7omkRZsQkeyQjMmBpAuP+R+/yYVpuh4g1ZYVG/idccn+zyMTG4PvDdNKEcVYEO190OG28M/G1I4LlyhMfZapDXqC2673JB5S+eBBXP7ww1i0F4gYbJHr/5YoDK1Lw5ojzfypyEgF5VhQjoLGDKmZyXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793123249; h=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=N8sT9/MtzApMiV5CXh0LloivfPnedXy5IEWayysGbdg=; b=QpD0EP4pYMLUkb/OwlUKDoW82m1zvzaSSLk1CFV2gby9d0KVgfXuMA1adRqA8iUNgWIYvWhbgaTKmZTQ9U/w8O4rr9ey3fvMz8X/J75CpiqaLa03ch9QMWZCYYyZWlUCzC5WcPpF7S7woYsZ16nv9wbnq7TB2YGSGn3XQc1Vl6g= 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 1793123249025390.5689880065039; Tue, 27 Oct 2026 10:47:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLlFt-0006nL-RY; Tue, 27 Oct 2026 13:46:38 -0400 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 1xLlFp-0006mX-CG for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:33 -0400 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 1xLlFn-0000id-8M for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:33 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4956869750eso710235e9.2 for ; Tue, 27 Oct 2026 10:46:30 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a92b8812c5sm5518875e9.10.2026.10.27.10.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2026 10:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793123189; x=1793727989; 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:content-type; bh=N8sT9/MtzApMiV5CXh0LloivfPnedXy5IEWayysGbdg=; b=cUSVfyEZpYNWcCYitM2+KlVYmol06/jGNXPlIG36iMaZS4cptc6I6C/A+uIAWqGY0S FKTnhVCM2hVbBVUq2PrS1TUix6PzfQugUS4kvMii+qPxu+oC3PqJog+jDzAC2SY6vOwW pO9NBliYnOqsQDrrKSy0RMMbUavpg6qvmWo5p3zsMA6hVfTmYbTrGnSOI3GVVW9SRj8W G/gXqBuuH4fXFBuPxx0ms68PHGkXQxD4gNxUQbS1EfKgUCAVNpH8Ler+wRMs7vf6XvzG 8QFFlT3J1dR0kHSnJk42tiMDSolrWeA/yL0ZqOepchhaObH4vPIN1KfQZZKp+cw+g/rW hT3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793123189; x=1793727989; h=content-transfer-encoding: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=N8sT9/MtzApMiV5CXh0LloivfPnedXy5IEWayysGbdg=; b=ThKS6EeQpqVScUuXlBYdIVMgDENlaeqv9S0TYupJvvvZc05HYN8PLO5kvD0uZDdRg/ Is72QKi1Z4L6F95E3stANsvy9Fd+fypzmmNuPb1X6ev1XhVaTx/PdWrz1+p1CdbYj3QQ ALKykhf04dVb75tP/ZX7OVLzLNpXPsGwpOUwV4NwgJWDClbV4vl6XRh70a47NufWeKKr 4XYo+GZ733+5w6rGL4fb4pYDirTTZ5w1YnDDr2H5G88aLwFQ5/U8jRx8BjVVrUqBf+4O 5Re6hSfCCAHTY+JBcpW8lL2+08+2tDc8RqO9ZxRm3BD8jpUdbJhNZUtfZHuMGIEjxtMW jHAg== X-Gm-Message-State: AFq9FYIXjFmfew+g3CV4NS0xFbE14B77hkyN8dWq3e9H7G0qG8f1owsX q5ZZxZBR3E/Y9uDdj/oyYJTphwEX0w/sM61+GP6Qkb2j0oSsTKVltbLx38N8CfoG0cJ8RGas/oa E6onNP20= X-Gm-Gg: AYBFou2c3q9TtPzTx+hyHjfh1+wVILCothzpnRlxTfalqpaLhKChH3Xa9WwUscepoFf PdfSXogLvPXPYtYwZc7q3iGrKMyO7TofnBLAtKkYzo6nSWh/2PP9UFspTsOTPPF9yiaJclHIjsq DZp+kIhFhhGJqdnGf21lfmYo06qlNl82um/A443jPPkc4xrE+0MsmqOc29ZaUwPYNrZ+3UFj3m1 GEl4/2vXx/Qwp51tKyjHKIs5LpuDp8R4DJWw3bF2OusdXZ+fU2RkoMrtJxMGWfu6VyWwog7MRRP q5s4P2I6YN9pr+JOZiSDnicRANsH7ttdHKhs6C6nNcl4xYJMJh8rewiyE7Vs3rUP8biT7aut29O QAv3yFPtpe5WrjcPZgSgX+iwytoXGNWBVx5IC3Mu+o8lN5NmkcZTRzdJxDCbbZzdRFwfA9SQkY3 eiixuD6QuyVqx5I1yeFgDIUSv13z+q9lSPDdHOAnJwi4IRKMwM+PAFzgsZsb/lHZVWsrZ4J4N5d +IY+7s92/XQkd+wImYpIoS9fRRZSWvjx3b778PsvKk2RP2y6Cw+FTXOmaVKnXJUamhM8rs2+PwR qCtJ3gQfVagHB+oiCu7CrMEa76BJmp/LELk5Mk4594izvDioo0vJTVl8W094kA== X-Received: by 2002:a05:600c:c085:b0:4a7:8fe8:130c with SMTP id 5b1f17b1804b1-4a78fe81333mr70752675e9.28.1793123188778; Tue, 27 Oct 2026 10:46:28 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Akihiko Odaki , Jason Wang , Samuel Thibault , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Zhang Chen , Li Zhijian Subject: [PATCH 1/4] tests/qtest: Make netfilter tests accept padded ethernet packets Date: Tue, 27 Oct 2026 17:46:22 +0000 Message-ID: <20261027174625.4025878-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261027174625.4025878-1-peter.maydell@linaro.org> References: <20261027174625.4025878-1-peter.maydell@linaro.org> MIME-Version: 1.0 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::32a; envelope-from=peter.maydell@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: 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: 1793123252193154100 Content-Type: text/plain; charset="utf-8" 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:28:04 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=1793123268; cv=none; d=zohomail.com; s=zohoarc; b=LhFeTOU1Lg+PqbI86plIYId+Yz9A90rVHHb0BR7jusqE2m+9lFH2nvIUWMHiv+7wHiYiMFf9uRJQPhbPSIN3E3+d+FU4Ypx3Q+ir/UXKuf/UhkX/FV/MEmeUr+mBKInzL424mtx0OxWQBIi8IoSxwfpJc1lVtPnGda+Ngwi/TjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793123268; h=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=3K9rWJJeJ1opaIcb0feWqc4Wlnwrg7nSQ3xZ6D43aPY=; b=BzNveJgiOI4QRHvTnZOhniBpJvxUugnLOqsInf8yzYrgMwHkEACGIsn0KYBf/++kv3DDlfqdEmszzqsrjVwasDgFvMLGw86ZUivqze8dsQ8fE4gjIwdfZSIddSHqknojFo6iNwcMcfx2uqgJPRr9WR0EU52kj4NYhIen/EJnU/I= 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 1793123268290809.7804702893669; Tue, 27 Oct 2026 10:47:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLlFu-0006nY-Af; Tue, 27 Oct 2026 13:46:38 -0400 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 1xLlFp-0006mZ-Iz for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:33 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xLlFn-0000if-Fc for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:33 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4a549cd7fd2so1257075e9.0 for ; Tue, 27 Oct 2026 10:46:31 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a92b8812c5sm5518875e9.10.2026.10.27.10.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2026 10:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793123190; x=1793727990; 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:content-type; bh=3K9rWJJeJ1opaIcb0feWqc4Wlnwrg7nSQ3xZ6D43aPY=; b=e8uMe8QAhcacXHhaT4XAWB0ZKdYU0MMH7ZDsVnjOMbYUzrfTDWVmV3//uJieR4CgeD +M+8WHdOe7sXhi8nckvQCyaWtM0AdXJBFFkG0PD64L/fXJujDZXu9ZsP65xyOht1cPmK mxWSLQFBflnLPcMjTgMfKOMTdp5KhO6cp/GaAugSu/KYiUC0L0Ene+ce8CYHRv1sHDzz Ecv7YGrgWIeaOc5s+Tp0H6nrAB9YpiFocI2wYVYOClCk9GGcd2nY9aZpLsnjTWpnUl15 NnamoYdpnfpDoqXztEIZOybWSQ+UomdK8ozRx6WZTiHC2rlPxyNCyVcwjL2bsoH0bAyB wK/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793123190; x=1793727990; h=content-transfer-encoding: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=3K9rWJJeJ1opaIcb0feWqc4Wlnwrg7nSQ3xZ6D43aPY=; b=QstsfeyCXuL/Vx26lcMfxyt0PQiFFeWyLZCG1BMn+r7WZz/MHZSzsGMoCNGYlkapDq J7OXoZse2K9E7g+USVSrD7Z+KBrojKn99f3mlNy33WxLe/KigczGTEDMQTOrec4TO0QZ 6pC89UcJediY6FiG020dlVEtZkjRgnWOnmteqfDi0tYsJlz7BESETffxbRE48bj9RHCY ZG6mNuq/nMp+MFnzuT1ENv3Wv5v/VfHal6Tp5dIfKDVmkSsTcS5/1XiLuOxMGsbRc1Hd M08Sw6/5Det+9U1vyDftct9+zimm/vfJbNunkrbOBRUXsS3MoQa5UOSrNaV2O/ouMVii OZfg== X-Gm-Message-State: AFq9FYJDKB9kMSUTjnNjy+nmtjUMNOaVBol8G9ByNisQSrnBi8gc8k4W WYncqaWyZAKnc+S9DlugdOJRFDL4sw4SLDjC27bNy5rzOCgdncHfrirFx2yhDzraUb67YgfCzmL djEuRv6Y= X-Gm-Gg: AYBFou2LbsNgrbg2U02fESVlrvmX+BpWjVDVhfZgvJ6HpqBm16+M6XOlhrEWB577GNQ HUPeyXrG3zVgh4GC7O4gwjQSHIAFgA9aczKbFTshfUUF1gnaerrANwQaFQWROO/fdxCSw+gL2S+ xsFHr7eN9fjb+aPlAz+uhQcWEnCEuOEDQSGY1xFbutoxSD4p86C4Tt4U6shXRqwPC65HDwsxz4w 4OmcDmkiYOAAQpy7pE/CotKaiNFWBfc++849MBRGlS28HsMqo7BxNk1g+iaMpKJowMUptsjF0X/ g2U36LtFCTPXS4FsEQVX7GFBkU7HxKxIifJR6RHXXrh3bSh4TNMgsXdVmM5MgShSSjYWdRgNGeM bJG+SD7OYX74C6mDEWwYUv/AHH+7WzHsfw94AiQ/rGDCL6Sb19Ya+/AHoSLsTX32LP/p9FUI040 8JyuyhyCWuo0MfIa/OQu7GeZrDgpBsNEtldtWiLXWcvbHDTre51Lb1cZ2aFbryaAMVGrqHl+SCy 6WR4redV9zj9VXLCzOzUG1jJjJOxfwEtMEdhYzBCfwjwlJxUU0qcN6Qolrotw5LXTgwHZR4TNBf tLxpO/8+czr03tQP8SZl2OZqryz06KSplEJtUlOBaUYk1tTYw2EmBQFeqR7j X-Received: by 2002:a05:600c:c84:b0:4a2:10f9:37db with SMTP id 5b1f17b1804b1-4a7c0a4b2efmr82102805e9.7.1793123189891; Tue, 27 Oct 2026 10:46:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Akihiko Odaki , Jason Wang , Samuel Thibault , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Zhang Chen , Li Zhijian Subject: [PATCH 2/4] net: Set do_not_pad for net backends Date: Tue, 27 Oct 2026 17:46:23 +0000 Message-ID: <20261027174625.4025878-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261027174625.4025878-1-peter.maydell@linaro.org> References: <20261027174625.4025878-1-peter.maydell@linaro.org> MIME-Version: 1.0 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::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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: 1793123269329158500 Content-Type: text/plain; charset="utf-8" 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. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/net/net.h | 3 ++- net/net.c | 10 ++++++---- net/tap.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index fdf6a2ddd44..3c5b99c806e 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -169,7 +169,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/net.c b/net/net.c index d7fa637ce51..1042a9d3a8e 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 diff --git a/net/tap.c b/net/tap.c index d71e3dd1175..ada69a21021 100644 --- a/net/tap.c +++ b/net/tap.c @@ -620,7 +620,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:28:04 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=1793123264; cv=none; d=zohomail.com; s=zohoarc; b=PHobNqAktkrwXZr9f6XEIzq/gXnGtZR7PB/7ssOauykTZ41wL8ZaXMARzXq9zTRIOk+9wugNNPpnV7ANp3ZrS8UQmWr4pHoP2f/kI1bXDhI3x4YKFt9xMO+BdgNPTz7JoAs43nW6rBl1/egTXthq7ACz14dO3P7fJHC4QC8pj1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793123264; h=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=Zq2Sa/uOqbcY5SjiEhkMQu9ePszRZfI1ZosMKgXKR+A=; b=Mi3YjkWZzJFjhw1UUA6AvmQY8qEh4KFuX2zX7ob1zoSB0jF78kkTdmHI60st2s349bhbqtSeiZf+gY8zJrfrjWMgWIvoe9s1STBZJoXromp08vlK4btvD51ywxf0KZNvUDBjYTLodblQ4zP/536Nnbrkw40S3t7xO+2IuFf4+bw= 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 1793123264502345.2635179954917; Tue, 27 Oct 2026 10:47:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLlFv-0006o2-9S; Tue, 27 Oct 2026 13:46:39 -0400 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 1xLlFq-0006n3-Rt for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:35 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xLlFo-0000in-Ji for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:34 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-48dfc0421d9so105055f8f.1 for ; Tue, 27 Oct 2026 10:46:32 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a92b8812c5sm5518875e9.10.2026.10.27.10.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2026 10:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793123191; x=1793727991; 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:content-type; bh=Zq2Sa/uOqbcY5SjiEhkMQu9ePszRZfI1ZosMKgXKR+A=; b=fBOUXM1o332PeEFn3XW58bvynknQg7/3cwYrTdqbB+wkbjnisV2jbsU3QtzUlWMHbL vFwyxnoSe6gl5ttNk/GG0W6qdEwIFExlxi6dHGIFyeQunsQ9WmsBBGJhFwo7IUwDVEWa CHoKjbI712v9+E9Hzqq8bIo6pwXZiK04wpSORydLbPc+UARQ6iUR0qxmMWwZD/zfp+SO DFhcK/VVrsDmwlv1/09Jo283yxSsMMbPZERslFm7tJy2s6jquhcVpaFSLPqE51QWcJ8R YlV/otn8CDjEZ9LVNcrTwUvAk5OJ0RHl2lTzeOW7RG3vhbOaw34O+A6lahgcQJz9y+90 rxbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793123191; x=1793727991; h=content-transfer-encoding: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=Zq2Sa/uOqbcY5SjiEhkMQu9ePszRZfI1ZosMKgXKR+A=; b=v3tWq3CD/irpIfQc0W3EgYF9lMsVxzTjITAbWV9ai++6upvojOR9wWAmYZ/ZyvRk96 QhiEur1Sa6BSZpvDGBTQwvSUBcgOghnK/PjCgHqTbADg2UdsVeJQKSh9H+VYbs7h1FCi 562TWCoYSG1Rz0XrEg3pX1VY+I8bk4x4Op8CbqB4wXIvKRV8g60tDhGw8LxldWxHjVEV HoJq3BbZ2gr/2DPBfMUGwIE9n9T+OVtmNnYOdCNWr50OOmxHgp66ob9qdmscAhQWGhoE G+bx8flzskzE3ADwl1vQdD2oM2AiKrX8yostfgEZq95NPTtR54YuGWVzJYGEC1o59F2I iwuQ== X-Gm-Message-State: AFq9FYI6LA62RFT4Vtud9Xvkx+KktneuUlBFEdgOzO5WVOdQDot2lpM4 JfloBoy7eD5WvSdknbJV0ZWiaf51N8kB9hTkurRJgwpXjV3PtpY3dF0wAqW+hwR5avIgGqpO2ID rcQe++EM= X-Gm-Gg: AYBFou0Co+9X3UiCYJjZR0g+9bo5akE7His/WH5iIRxAa1o0qXUxhtyEcg6U7as5mSx J0nmSccyWDRVcXm4wBg74mb4VVHbsIgu9inVaaPRWM/MJjBC5c1SlfsrAKz56M/bQo8kJmcVmIi wjKjKGr1gdRQq1rnxm4DMCYpMlmWnRMA6glyTmDbZ4GJDqVYIHOTas/eBjZy9XFeCBcvNUloDIT cFu82WMQUPvr2b+SuOcXHAW+4LR6KMJdLtspLTrU20iarAGCGTdFDuZ954VWMeLL5K+DWmg8VYi KGEc+Bs0mOsL5tA6zuCeAWX7omDykVn8z7MxMVglbfSeVzj2xgr4MVMhFGEQmL7dVh0T8mb9yFg SPN3RgT5pk2NBZnQ3bQSVHhe4ZwASITpXOMUayLonuaU92pQWck141NFH6RqJWiM1u+pfMb4oNE KwW4ROkrKGAW+XbV8qLmcK8BrLNg21nCrys40GcuyDNjQGj+PyO5ZnkQYRTCwOSMlNHRIS28+Jv OsxcliIFhKchk4mPSbuJXeUB5N/07ozlz+9MotdARaeVSns+6tHZhe30NpLfQwZ6dRtzulU+FST tewi1zvF3sEaY3wxoUwtjLyqBPAwjR3wadl/oG9qqWP+x2skMzxWuE1uH95J X-Received: by 2002:a05:600c:3f0f:b0:4a1:acaa:9d4c with SMTP id 5b1f17b1804b1-4a35acafb3fmr186104355e9.25.1793123190972; Tue, 27 Oct 2026 10:46:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Akihiko Odaki , Jason Wang , Samuel Thibault , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Zhang Chen , Li Zhijian Subject: [PATCH 3/4] net: Pad short packets in qemu_send_packet and qemu_sendv_packet Date: Tue, 27 Oct 2026 17:46:24 +0000 Message-ID: <20261027174625.4025878-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261027174625.4025878-1-peter.maydell@linaro.org> References: <20261027174625.4025878-1-peter.maydell@linaro.org> MIME-Version: 1.0 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::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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: 1793123267400158500 Content-Type: text/plain; charset="utf-8" Now that we can rely on do_not_pad being correct for all NetClientInfo structs, 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 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 ++++++++++++++++++++++ net/eth.c | 18 ++++++++++++++++++ net/net.c | 22 ++++++++++++++++++++++ 3 files changed, 62 insertions(+) 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/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 1042a9d3a8e..408871d3c21 100644 --- a/net/net.c +++ b/net/net.c @@ -735,6 +735,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"); @@ -745,6 +747,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); @@ -899,6 +908,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); --=20 2.43.0 From nobody Mon Nov 23 04:28:04 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=1793123232; cv=none; d=zohomail.com; s=zohoarc; b=QHUWrNLYD9vBYI104ruKnb0Ym2b2FKgDvXZ7hx67UGPBtVzfJGTtOFWWN9evb0Z/Tp82qAywihMtTHrX3BnfaMjh8qb0fJU0SfZF4DedN9m3HBS69nDVeHTULjM1GBw9LjDWkHCN+ie8Rkh8djoQnTA5uxei0z+cbsWuyib8sKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793123232; h=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=m5klfN9HYpmqR5jE7JRUeg/q9a5L8gTTTh4pweWQuow=; b=NDi/ts2zu2SeLO7orF2BbsEJC+RMPe4zMU94XUjpk4D0qcpBpT3rHCQPuH6jpsiXhiLN2OR00SjcpZnpnh+V9mc1JsQDmORhBk+LSeOO0BgkdE63Pm5CTwHktH3DoTXC8TID24/MwT/AECqNLAbVpQZd/PfGt8vL0ne9es3LG14= 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 1793123232468503.5923236446058; Tue, 27 Oct 2026 10:47:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLlFx-0006oU-QU; Tue, 27 Oct 2026 13:46:42 -0400 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 1xLlFr-0006n5-5I for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:35 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xLlFp-0000j2-Cv for qemu-devel@nongnu.org; Tue, 27 Oct 2026 13:46:34 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4a218c463d1so978715e9.0 for ; Tue, 27 Oct 2026 10:46:33 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a92b8812c5sm5518875e9.10.2026.10.27.10.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2026 10:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793123192; x=1793727992; 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:content-type; bh=m5klfN9HYpmqR5jE7JRUeg/q9a5L8gTTTh4pweWQuow=; b=Nbo8x3xvlpLf9aQLRhpw8U/VBKsxeieZ/QXWHHJOGv04YTeJICvp/ZL72Nn+WQ2vN8 lY69Mn2/MFW4wtjjP+artol6OZcC2UFtJyE5D71UZdEhnO1FOI40M3tIaKlu3QQAtMhZ Po2CeWJMDGlGFXPo3KbB6s3SNo0aUsdnYlsJCoilE71+byV6H/vmsofosnvDFY++q1UL xbkUZXOBbHXJ4GoOO+wZb2md50WUg61EGr8Do9to9oYBcat/cTnR9jmXvNfRrQM36ToR URc1ix+8oHk6VMW+nUgSbfSwXnJT3W3mTpTHyM/DXkZugJT/Nwp8UYlsrzqvPZtiNhva YtzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793123192; x=1793727992; h=content-transfer-encoding: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=m5klfN9HYpmqR5jE7JRUeg/q9a5L8gTTTh4pweWQuow=; b=GXuTUJ6nEoEaVZ9Gy17/Vh1yBR4p94HTWdNjjw3rRKw2lo2JocH75qdlWb6rBpOi6r YEiGLemUIiNILbxHwyhjtZ/2hn40PmA8g91uYLhK1zNTQ0pwB+xfVimHRnVu6mfMrGw7 2jAYiuCVg+5H1aShFBtvgS0Ni+L3tdRYm8ugmQrxmqXDT87bmeN78K5jv0yLyle27jUm G6qIv7LgDyufpbF7lQryqEoFItMfkd4RD8c2W/PLvtNZcwTBtAGcQUor9eSZSs8LhVF5 XGS/UI8tEUi4UPHUGbw8o3RbSGG0TM+RPt6/Z9+BiwUthmUWeA1dW0TFOk7Q4DJ97MTT EImA== X-Gm-Message-State: AFq9FYKeyf1FGuGzwujbePNChH2zm7s7LeLu+JYbG9Wx2OFU/5hlBkm0 pgaHsQAKAOanlHSqf0s9vPpOE8wsjgol3xs2Rfhswux8kZPNTNhVpKh61XVNIMDoY2tFxbD7nyL IhEjIf2Q= X-Gm-Gg: AYBFou3hg6q3KNiJSsO0+34XgH4osICDOGWdCGpT6/cSlIXKzs66nnYcL+OQLAV0YJL Egx8ll1XKt8TvYQkMMBVNJPLXJszxynnxCuM8Khz5ziRKHgIaFMQ/lf1ARttNvgettA/FdMg1Lv geMiPgY5A37V6ryZA7oUSM8xMnW6KKljZNRxR/MiEyuQ/zHLGU9qf3iYhzJEHX4SE8YRpz/Mrc9 EZmkYBAD4rTjw8aCa7QGPCMth2DeYA/mcOoMNkvRNEos8cL+6krl3eVPHuEpQl72y1lahVMmRrU e5/7mEYdMo3WFKH0LcT1il5df+xDgrisRprWfQ0I2QAjp1j0Y9N/9uKjyQxiwRFSoXKcRxL1ToF /8P7jz3LTIbYTyHa0vi7YPA6CxCD7EkRPOjzsJ9VR0K1WeR0N6KPG7JxjaNk4fp3o0IupdOQFU/ JeRoHl9Ktc143TTm2DDy45mzoJhuXRgcqnqQgujxfTLlOR44igI/YXBnQxL6kvb87pCbzULI6X7 frbcP5Q+9pJtWTzDKCETBS6nelUl03jcZUPu8sZJsXWCVEi00VnQRaq4L4UN74H9j/4aezkw9NW DKQSL57BWJ3QZ0/C+j8+uzm9d2pG7mR03QxCgYyy6EQmSjFcALKTB4nZuxzkTKNr0dytNecWNTg Sbxo5Hw== X-Received: by 2002:a05:600c:3541:b0:4a1:fbf8:55c9 with SMTP id 5b1f17b1804b1-4a35acc6a2emr211595835e9.33.1793123191974; Tue, 27 Oct 2026 10:46:31 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Dmitry Fleytman , Akihiko Odaki , Jason Wang , Samuel Thibault , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Zhang Chen , Li Zhijian Subject: [PATCH 4/4] net: Remove padding code from net backends Date: Tue, 27 Oct 2026 17:46:25 +0000 Message-ID: <20261027174625.4025878-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261027174625.4025878-1-peter.maydell@linaro.org> References: <20261027174625.4025878-1-peter.maydell@linaro.org> MIME-Version: 1.0 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::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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: 1793123235154154100 Content-Type: text/plain; charset="utf-8" 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 ada69a21021..786c31f5adf 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