From nobody Sat Nov 23 15:09:48 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=1732251808; cv=none; d=zohomail.com; s=zohoarc; b=nuCl8XzZzNBMetg5/wmT6wyUHxKqcwDKnONoaocTqPHGGnXxZOhgr+DzFbIJ2glPDWo3q0NOUjo91tMiDyo2ju2sljffFBSvwvP+gCgm8kSqoWC/WO8/ECtW1zWbBBC1u0q95NmVc82fcq65Cqmtwwse4haqafgo1qbm+MMq6xQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732251808; 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=Pcm3TKfU601RmQ0HaOlFX8GbZkHqQu7xV7Of6HtMoeg=; b=j2qUWE45Q0/vmegfhEbzTEL9GTxqtwMpb59gg96UbcDnHBNijnzELD0ZLYP2ewKlQtST+eHNVNFBf6q3nYzfaknx943Gzps9CtEoc+t0brh4H0O6/VVvuc8o4hgVZdUUCIlzG68n9Ea2eT8llS1NpQPtz78itbrNyH6b84r+WcA= 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 1732251808163966.4444525159154; Thu, 21 Nov 2024 21:03:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tELpE-0005bv-Ji; Fri, 22 Nov 2024 00:03:24 -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 1tELp7-0005ai-RJ for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:17 -0500 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tELp6-0006Re-C9 for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:17 -0500 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-71809fe188cso805500a34.0 for ; Thu, 21 Nov 2024 21:03:16 -0800 (PST) Received: from localhost ([157.82.207.167]) by smtp.gmail.com with UTF8SMTPSA id 46e09a7af769-71c0378d05csm280819a34.36.2024.11.21.21.03.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 21:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1732251795; x=1732856595; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Pcm3TKfU601RmQ0HaOlFX8GbZkHqQu7xV7Of6HtMoeg=; b=REm8Sq0QFBOqVmD8h1bz83p3uEGQsSxmFzLy0vI81mKqKF8dYqUx5owV9WRHHbQAxe Qr4uuXd6pM74e/KTy5EgnMSPoxh1+NQI1TsJfaC6mMN0XXBBQEWMmf8tJDEzUhvkWzbZ pL+//QeBbB6WcFFom5tJxYoM5O0YoOfPJYpwvAXx+jDxcygkmwnTRN9s07sqGVMsDy+Y iezAEcHUgKsxFo2eg8AHiWEQiCIJYoCovIQkcVqEnnXxZt7KnMk5V7frs+GWbk5vsD07 olQ4RmWgrEcKkvG1KFEimgTZ3XKhDJlvMC4YHoF6FOU9RUCNOAX1PAjkDo0lnhaBzLIv inkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732251795; x=1732856595; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pcm3TKfU601RmQ0HaOlFX8GbZkHqQu7xV7Of6HtMoeg=; b=vY4qdd4eM0MCfwAB3VaFyLbnwi4rXhQcmN7b50FA0DjyB3G0g2U308LtMkYE5qwjhp MeMWbdSOvm2KcJ8Y7nM3mkxNs2j6Ww9eCOCENQ257mfuQak7gVeBUKUxZaDv6rt430cT o34t6ZLGd+2y1vc42YE9sz5w6dd5kinoyNNQqIT+0nMoBT9LGcCIp7h440mLU3ezJZqu XStEra8kL8eTXs9ZKdWrJJXIa77Wjn+DLpab72Nwo2Zff0ZN6nZ4CXQrBu7DJFVrgot2 IVFvPzhoyCVNhj0ihakS5dk/OICUTDkDnAw+CCNsUGXP6N7yMBasvt6DNRAuNLp4Bqfa 0yqw== X-Gm-Message-State: AOJu0YyKQSwzXj3BDCzQfGNF6CPffqrRG2FID3hvB/0OvyJQJrb6npIT g2/pNj3WQit0RXYNcp180Nom4sK9rfy3T+f9jmAOVyb73NigoYIypZcIf33Bz5IAHJM9TocZcqP uYpA= X-Gm-Gg: ASbGnctcBBh8Cl8o29TGW2xvBp1DLttGxmGXR3oeQfjgwuCcUkUizLVBDbFC7n74LZD yYS2Z8dG6volg1jkV6AtVLn40g7eRMDxuNXXwknnynsCJlgA7y7aUf1CM3m0VtP8paw2gXu9Laa w4Jah/GmeJYO+3Co6ue+fgArnnqIGpE18GJ+bYDobfdD/OiMN8xmaYJK1+wzt+ncO1kxgvAE3Dg +5bJF5Lv+ihidQFo7L8S1w2aQm/+DsDl+ldPSrISapwCuNnJ7TOjA== X-Google-Smtp-Source: AGHT+IFNp0hK2u+oec6bmfkHzf0MJB4ja6oLn1GXy+v+Eqf8y+X5aa7khf2LTpWSRYijqviDZla4kg== X-Received: by 2002:a05:6830:39ea:b0:718:12b5:1ed3 with SMTP id 46e09a7af769-71c04cd9145mr1148737a34.23.1732251794881; Thu, 21 Nov 2024 21:03:14 -0800 (PST) From: Akihiko Odaki Date: Fri, 22 Nov 2024 14:03:07 +0900 Subject: [PATCH v3 1/6] net: checksum: Convert data to void * MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-queue-v3-1-f2ff03b8dbfd@daynix.com> References: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> In-Reply-To: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> To: Jason Wang , "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: pass client-ip=2607:f8b0:4864:20::335; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x335.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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1732251808574116600 Convert the data parameter of net_checksum_calculate() to void * to save unnecessary casts for callers. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/net/checksum.h | 2 +- net/checksum.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/checksum.h b/include/net/checksum.h index 7dec37e56c78..188e4cca0b7f 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h @@ -30,7 +30,7 @@ uint32_t net_checksum_add_cont(int len, uint8_t *buf, int= seq); uint16_t net_checksum_finish(uint32_t sum); uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, uint8_t *addrs, uint8_t *buf); -void net_checksum_calculate(uint8_t *data, int length, int csum_flag); +void net_checksum_calculate(void *data, int length, int csum_flag); =20 static inline uint32_t net_checksum_add(int len, uint8_t *buf) diff --git a/net/checksum.c b/net/checksum.c index 1a957e4c0b10..537457d89d07 100644 --- a/net/checksum.c +++ b/net/checksum.c @@ -57,7 +57,7 @@ uint16_t net_checksum_tcpudp(uint16_t length, uint16_t pr= oto, return net_checksum_finish(sum); } =20 -void net_checksum_calculate(uint8_t *data, int length, int csum_flag) +void net_checksum_calculate(void *data, int length, int csum_flag) { int mac_hdr_len, ip_len; struct ip_header *ip; @@ -101,7 +101,7 @@ void net_checksum_calculate(uint8_t *data, int length, = int csum_flag) return; } =20 - ip =3D (struct ip_header *)(data + mac_hdr_len); + ip =3D (struct ip_header *)((uint8_t *)data + mac_hdr_len); =20 if (IP_HEADER_VERSION(ip) !=3D IP_HEADER_VERSION_4) { return; /* not IPv4 */ --=20 2.47.0 From nobody Sat Nov 23 15:09:48 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=1732251834; cv=none; d=zohomail.com; s=zohoarc; b=RvbUnaIyyok1ze8yBB6lDOyNwhie+fh2sYv2hTBAcPp2snY+rm4g1s6VUxtvqhpM5/SGGHDiQ60l8jyk4Be+WmplBEH/uZZzj0NYvAn/6SFNlD0xTG0k4QjcWUNBujxaPlns4FzOpxzK9hqFcFGgTE6e6YTExdm+ClXQQnlyw4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732251834; 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=oDsLPJ4AXpeDDZy1IJMYSeMrcK9siIVRfnf8cnUeqpk=; b=YopZdjPnB1pR1bW/t6CTqUgf+ltQL7W9hZBtZlQC9YNQqlLd6BkKvG++nm1SYUQb4Ju0IgkIVZXUPQk/zB1fBvsTo/x24jXl58r8SABKbAevJARc06r7phrou3fT7abHAItwHXtmL5HTlrjc08JSDjwmU8hCc7ZLwS6zcmZEYeA= 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 1732251834120647.6330839795802; Thu, 21 Nov 2024 21:03:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tELpH-0005fh-FR; Fri, 22 Nov 2024 00:03:27 -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 1tELpA-0005bQ-P9 for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:21 -0500 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tELp9-0006Rt-Ce for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:20 -0500 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-71811707775so963404a34.3 for ; Thu, 21 Nov 2024 21:03:19 -0800 (PST) Received: from localhost ([157.82.207.167]) by smtp.gmail.com with UTF8SMTPSA id 46e09a7af769-71c0381ed10sm284235a34.45.2024.11.21.21.03.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 21:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1732251798; x=1732856598; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=oDsLPJ4AXpeDDZy1IJMYSeMrcK9siIVRfnf8cnUeqpk=; b=iTYLeI8vYbYphVExrApX1bKYzuCnLkOafY84I8r5fRH60ej3kU93luhyACaBUeDpaq x7GuvqQQ9p6B2Rw7Vs3CiuHYkhxCjaJN67JeykA7sIDCen9/pj1fyRgtDOgMLNUuw8MH D86snC+5tA4XQgbqfFaBlxu0LylTqbivOKBPfOYH6JsnJAQx3qPL0E54ysT5i5Mfi8QA cKo7SAAEwosMw6faIBy73k07J66H1CKVvWg/9eE15M2RgyTKErep78+5sAFCeOTMvDoA npwiYm9C0M9eDBk9PuDBgmzZXWFVXX9lbp9gdysvWRvC7K1eLAjnsbTlBjaKpVN4P+Sr WAig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732251798; x=1732856598; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oDsLPJ4AXpeDDZy1IJMYSeMrcK9siIVRfnf8cnUeqpk=; b=Itff+k+zFwc61dhstcVvyva3T8+ybGjfl65Xazu/0Yy9suyeLIWpPFTwCJRfwIf/aA S2STzGhFJICWI/juIsDOgDJo+64QICh8HsoHrgbn496Mb2fN2SfiZraAtMktH/c41XsO lTblkw9Av5XYmN4uFof0Rmf8MZXbWpIgpmtdQkMEb96HlHeANaXyBZ3ObuQYILRcsuC3 7FLO45NTXDV7dJwDXgJRJWfJ+ZBTy+yLgZcRlOkC8fifW379VXFak1gqAEkYJULXaAQW pGrfS5l13HZfTaOBLQDqu/pLwz367wuamidUlbsUOr+FWMqtmTJ5h1cn2oTjohWjXVCw LJWg== X-Gm-Message-State: AOJu0YzSXfNqotGDB3ogmOzUTtemgTU9Tw7BAs92s7xWUgm9cjtq8bix 6vTILF4vJ0DabAoAhecZzaVL3Jxa3jnMZAwoh9/b7LQ9IEWmRaTz415gmDMF0qi90/ipFR95h08 AtSI= X-Gm-Gg: ASbGncuwvipDTZWUEiXZ+Lp0/+g/OgYmLDVhVheeROoHljHHRUuvuSr9WEXi23r2fP0 sMt1TU2f6uhfbHA+yCV9cQd/r/BNRi1C3OLXfPtvpHKyYqMyUdcAaJu/ARjuIh1/Z4RAxut9NpZ vS0dtdEV5/zVNWkLkst2ckGDxSAFXjSsOkSMzvnYTosWtIbVr8gwZNS4Dh/jOLjfzubyg/ppZ+x C9SKCFmnbrIW0zZiVvGK35vKT+M1/JfVwasLzAqFRcVqyeOHD3Tbw== X-Google-Smtp-Source: AGHT+IEyaOwnTFPID7ftcgOOzVhgbKk/zi/GbCqHSp8hTOuQrmrzYt64z5FQm9WYCKfSvJnWkGGonQ== X-Received: by 2002:a9d:67c8:0:b0:709:4757:973 with SMTP id 46e09a7af769-71c04cec8d3mr1298360a34.23.1732251798078; Thu, 21 Nov 2024 21:03:18 -0800 (PST) From: Akihiko Odaki Date: Fri, 22 Nov 2024 14:03:08 +0900 Subject: [PATCH v3 2/6] virtio-net: Fix size check in dhclient workaround MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-queue-v3-2-f2ff03b8dbfd@daynix.com> References: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> In-Reply-To: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> To: Jason Wang , "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, devel@daynix.com, Akihiko Odaki , qemu-stable@nongnu.org X-Mailer: b4 0.14-dev-fd6e3 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: pass client-ip=2607:f8b0:4864:20::330; envelope-from=akihiko.odaki@daynix.com; helo=mail-ot1-x330.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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1732251834584116600 work_around_broken_dhclient() accesses IP and UDP headers to detect relevant packets and to calculate checksums, but it didn't check if the packet has size sufficient to accommodate them, causing out-of-bound access hazards. Fix this by correcting the size requirement. Fixes: 1d41b0c1ec66 ("Work around dhclient brokenness") Cc: qemu-stable@nongnu.org Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 75b4a28fb3ae..a2a8d6b07bcc 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1697,8 +1697,11 @@ static void virtio_net_hdr_swap(VirtIODevice *vdev, = struct virtio_net_hdr *hdr) static void work_around_broken_dhclient(struct virtio_net_hdr *hdr, uint8_t *buf, size_t size) { + size_t csum_size =3D ETH_HLEN + sizeof(struct ip_header) + + sizeof(struct udp_header); + if ((hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && /* missing csum */ - (size > 27 && size < 1500) && /* normal sized MTU */ + (size >=3D csum_size && size < 1500) && /* normal sized MTU */ (buf[12] =3D=3D 0x08 && buf[13] =3D=3D 0x00) && /* ethertype =3D= =3D IPv4 */ (buf[23] =3D=3D 17) && /* ip.protocol =3D=3D UDP */ (buf[34] =3D=3D 0 && buf[35] =3D=3D 67)) { /* udp.srcport =3D=3D b= ootps */ --=20 2.47.0 From nobody Sat Nov 23 15:09:48 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=1732251859; cv=none; d=zohomail.com; s=zohoarc; b=XRwo6NwUrApvArlf06nC8O/Hp+DNg3NtyTJrwK3nElWnq3yCHWiiLp29/5KTHzpoTe2ODOJn0EqBbwTRwoKIs0m/eBIu1aSc1WsmycRSmyqvsBY9Oe7FnJBWcDpPf9lqc4EPtMizgPWn6CoXszJiYHtxrwA2sHPepSixDmWqaz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732251859; 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=RFrNi2VVoowoqBy/v/ykZ3Me3c8V3mgQT6KledOV830=; b=fX/ltvSehd7zA+AJzP8aHEnGDcfXd133RWBj7X4vMP43LwFwLb4x418GqszrC55kdP64k5h5GvMENsLzG4tYXoqU3YaM2I8l1ZC0MRPLpgSqJZw/EGJk46se9axmwOY4Hd7JtbWXbc9cYIWzZ8BkNTtld1w/z9PE2Nvq1lGzIKg= 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 1732251859270749.0570186352807; Thu, 21 Nov 2024 21:04:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tELpL-0005m3-1i; Fri, 22 Nov 2024 00:03:31 -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 1tELpE-0005cQ-Ut for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:25 -0500 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tELpD-0006SP-Be for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:24 -0500 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-296b0d23303so958542fac.2 for ; Thu, 21 Nov 2024 21:03:21 -0800 (PST) Received: from localhost ([157.82.207.167]) by smtp.gmail.com with UTF8SMTPSA id 586e51a60fabf-2971d882c3dsm378121fac.44.2024.11.21.21.03.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 21:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1732251801; x=1732856601; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RFrNi2VVoowoqBy/v/ykZ3Me3c8V3mgQT6KledOV830=; b=N5ePF+LvCRJQOtuvvh7ndzqXvKOc05HcFlOuxg9YKZinZeQm2y3OcRzRZavSelfxx0 Zo7CeVGPFpRyAOg4y6+GcPiKN1BjH6Kv37hLo9C7sjavLWSmZoImksSaE7Z90dzTvZ62 GJHQjGaQAS5CaTcWrX58nWdR3iqxI8JvdOYHtvgvluuT3mmpCMEY6evdtlRAmJX9aoDX PA4bVk4fdXHdOeNZseVR7Cxdsb7c6knb/X4Xe/INPxnExicvCcsFhlkMxz31E/RkXTfk FCZjFfKf8X94XGXrDXtbQBd4Uncu7Sr3fDtxzBEveLkHzLS6GID+QZUQkwUy0XXTa/AB sTLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732251801; x=1732856601; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RFrNi2VVoowoqBy/v/ykZ3Me3c8V3mgQT6KledOV830=; b=grAAGAQCaIMYbrLOoHXUhiVslJaRR4t6TYZeD8ON7zu+vcHTb3NCUrthLT8RuBLGUa YvirgzaHVLa3jmgeIJRCJRwI+2gr5z6AmGmeCXJuX8MWKE2t3Zh4xhs/LZXiO148jL6N +fMBhZnvTvCF0fsB21K8J2qac+o8wLjiuwkYnkhzZsyZm0gren/ZF9rQhOV1waQPD6el yfq8x5WllvEIikFLoeu5mDkpmIYaS8U1dk72bpkennBT/IrZRCmY2IycYwQwfwkgl9Tr P34QbqsPYpC8zwgWzjiH6ewe5RQcTGV1aUT7UTOCKywqvsOQ+73nZadqUwI4sqKmy7KG xWcw== X-Gm-Message-State: AOJu0YxnrR8ZBl3kWHlkLSc1U09QoLwzu9zKjniffzcwzYxnxrjwiJo+ xfVirEOo2/vj6vSoZUwcp4RoihKdv3Rg3re22vXoACXoVNE1XvVFyuOKhlibVhFaeVfvrgpyhqa 7c/o= X-Gm-Gg: ASbGncuvoiBvC72Tegs+5KkDIJ02LgxHIBzd5VOk6lTq3i4lPojn81ryDqRkJV5dgLI 4wyHD8S3s+uBbdVtf5IjlSobiVQD2cp+JYVfpurh9TalUnhUVwMhXzj39XZ+4y3H+VctpA7B99H Pzn0LA1THIDEq+mVHLJNA8Oo/etadXWY8AU0nhE1xyrrqMhdLTxuo24xv6XSXBCJ8OUH5Mk4HYl y/oNE7USYVpt9I1X4UaDf2IGR6PMgHKoYmUj6T4aZdT1jmSbvNP5Q== X-Google-Smtp-Source: AGHT+IEFtOrZjtB0E6GXqF4mxiPc7RfgQoajBAuBGF8sqsqPv9vj+dZkPy72h2JqZLtQIMsfUy+vDw== X-Received: by 2002:a05:6870:9e47:b0:297:291c:ad88 with SMTP id 586e51a60fabf-297291d0d9amr732788fac.28.1732251801164; Thu, 21 Nov 2024 21:03:21 -0800 (PST) From: Akihiko Odaki Date: Fri, 22 Nov 2024 14:03:09 +0900 Subject: [PATCH v3 3/6] virtio-net: Do not check for the queue before RSS MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-queue-v3-3-f2ff03b8dbfd@daynix.com> References: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> In-Reply-To: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> To: Jason Wang , "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: pass client-ip=2001:4860:4864:20::2a; envelope-from=akihiko.odaki@daynix.com; helo=mail-oa1-x2a.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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1732251860616116600 virtio_net_can_receive() checks if the queue is ready, but RSS will change the queue to use so, strictly speaking, we may still be able to receive the packet even if the queue initially provided is not ready. Perform RSS before virtio_net_can_receive() to cover such a case. Fixes: 4474e37a5b3a ("virtio-net: implement RX RSS processing") Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index a2a8d6b07bcc..d4aaf362b70f 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1911,10 +1911,6 @@ static ssize_t virtio_net_receive_rcu(NetClientState= *nc, const uint8_t *buf, size_t offset, i, guest_offset, j; ssize_t err; =20 - if (!virtio_net_can_receive(nc)) { - return -1; - } - if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss= ) { int index =3D virtio_net_process_rss(nc, buf, size, &extra_hdr); if (index >=3D 0) { @@ -1924,6 +1920,10 @@ static ssize_t virtio_net_receive_rcu(NetClientState= *nc, const uint8_t *buf, } } =20 + if (!virtio_net_can_receive(nc)) { + return -1; + } + /* hdr_len refers to the header we supply to the guest */ if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_l= en)) { return 0; --=20 2.47.0 From nobody Sat Nov 23 15:09:48 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=1732251865; cv=none; d=zohomail.com; s=zohoarc; b=UypGj3jeniAn7hoCq0IG/+dK4xop/ycEhVvn7Al96ZEuAzfCqKC36aQ06A0EkldptMPIljU1w1KV8d0bIEOCXrDzqZll2ymmsNhdornhyRcEMR56ulOhatR7kQhzTdY3uqJG4LxOn/mxKmwL9QuOQBTr/zX36sMwWqOeFfqyrOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732251865; 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=aydS1nIFZysizdq/nBxIGIRe/Qf80XxmCfhRmPTZ8i4=; b=TsaA4RoML/9Z7/cJYPm7cwoDm7k/uPwRc50P9GHJ/c/cXDjMi9Ff+KawNJvUd1xt6+RsdTdOxBkuYAmH/qxPnJMAFR2ZlNZwKRrBaqkMfXkmxsNTKLu4+Z1CwDg8bP9A1tW0f3kntZNU4ciLLKWNuVPk8kbOP3RqmKeeEPWcHtM= 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 1732251865000131.9533271904087; Thu, 21 Nov 2024 21:04:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tELpS-0005uS-92; Fri, 22 Nov 2024 00:03:38 -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 1tELpH-0005gT-Fj for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:28 -0500 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tELpF-0006Sb-Pe for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:27 -0500 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3e5fbc40239so1022579b6e.3 for ; Thu, 21 Nov 2024 21:03:25 -0800 (PST) Received: from localhost ([157.82.207.167]) by smtp.gmail.com with UTF8SMTPSA id 46e09a7af769-71c03790782sm286676a34.40.2024.11.21.21.03.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 21:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1732251804; x=1732856604; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aydS1nIFZysizdq/nBxIGIRe/Qf80XxmCfhRmPTZ8i4=; b=wOk1FlECEOpwgWB5zEGdZCYTcNAYz5WkGFFGmSlsKHBSIVOgqzRD/QEIFNqMvRFINw ZZAr3lJC96PVDUW2apoYltcj0TPqJMlOPlQGF25cyAYhArDU2FyOsKV50Iw2fqcg7mc9 60qjlelSd5iWRzAVVEoq0PvziXj2A/5ycfe2/235X14vQ7XUcoWUD5QhyWUjhOwExGmA RDJR3ftllGZ5d5L1Dl49z3AcXmHzqVzID/isVbw6Snea3TFGGqFn08UtpKXU/AdEB7ze LwppqRZprHcTz17WTgp6oHlgZ/rPEkLvKYr+R31mkTPxyTvNmhLvUv78VHcs7j/Ks+bC PXvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732251804; x=1732856604; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aydS1nIFZysizdq/nBxIGIRe/Qf80XxmCfhRmPTZ8i4=; b=ebmDam8+hZTvYHlA3I4m2FnzKQkl+ouuWfrizBrNxO8JJpx3eeTzW6txgW4poN5u5s p34VBBvSpd7GdOpj6jdHlWIyolnAtfHAdwdlV0l5T1x7B5HwNaSFCJ2hYQ4oVzm5hX4F asdg4qei/p8XXU8FavzWn3J1e8wnu9YindF07+8eXn+apBLN2LvImRhTu48AP+mKSpzF 8o4bK218m/LnrqwNZ6vm5OLEKqXcv1yM08G9xCL6rVM3kc7J3Jv72wGHf372M3AFIm3D 2jQ/nNjgmHmrKg9bUaQ+Pjv5eFHjw+znXX2M51XB+Wn9zZ6RxJafHqFFVnuidTE/U/Oz akRA== X-Gm-Message-State: AOJu0YwGIWEUqlWyvw12GrqN3pBhRfRL3xbEDKVIOyrakf82xOxKMTkd SFkwoBlFrXo7XmWHcSsQq1QKrZMoGMWODdn8UJHrjp2OwSwgNUlLgbFPBRqzfivmk0AjGfFJkQu jF18= X-Gm-Gg: ASbGncuSGe7pW0JbpkV2k2DbwSwlZXfCTiqAYSugoEyffknqHdTR+LLnDrT3c1hdYH7 04+Hr/CZlv5wk+v2muGF8KSE9CJBLv9nj4q2C0d18zkNAoc5fB2out1gj+Y0SiEAckueQisxeGp HHZoXk0ZY4JpiVkrPCkcJLgIgEug9wGqSfKeNlU8vduwL29brzY3u+MPMDhTaY+Yro+v/ja2que jRWYRLHWJzrmJyh3mPPe/fdhw/Gxi8zL8viAGAJgjefCT4eUWdboQ== X-Google-Smtp-Source: AGHT+IHpQmyuEUl7ZY7IQgoZ44mIjfwxuXcIKwAs/YISw8GDNwPYV1qaN8Vf7okuxWynyJunmfUp5A== X-Received: by 2002:a05:6808:1210:b0:3e6:5f5:5e25 with SMTP id 5614622812f47-3e9158395a3mr1914216b6e.19.1732251804221; Thu, 21 Nov 2024 21:03:24 -0800 (PST) From: Akihiko Odaki Date: Fri, 22 Nov 2024 14:03:10 +0900 Subject: [PATCH v3 4/6] virtio-net: Fix hash reporting when the queue changes MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-queue-v3-4-f2ff03b8dbfd@daynix.com> References: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> In-Reply-To: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> To: Jason Wang , "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x22d.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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1732251866664116600 virtio_net_process_rss() fills the values used for hash reporting, but the values used to be thrown away with a recursive function call if the queue changes after RSS. Avoid the function call to keep the values. Fixes: a4c960eedcd2 ("virtio-net: Do not write hashes to peer buffer") Buglink: https://issues.redhat.com/browse/RHEL-59572 Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index d4aaf362b70f..b544d2e91a77 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1898,10 +1898,10 @@ static int virtio_net_process_rss(NetClientState *n= c, const uint8_t *buf, } =20 static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *b= uf, - size_t size, bool no_rss) + size_t size) { VirtIONet *n =3D qemu_get_nic_opaque(nc); - VirtIONetQueue *q =3D virtio_net_get_subqueue(nc); + VirtIONetQueue *q; VirtIODevice *vdev =3D VIRTIO_DEVICE(n); VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE]; size_t lens[VIRTQUEUE_MAX_SIZE]; @@ -1911,12 +1911,10 @@ static ssize_t virtio_net_receive_rcu(NetClientStat= e *nc, const uint8_t *buf, size_t offset, i, guest_offset, j; ssize_t err; =20 - if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss= ) { + if (n->rss_data.enabled && n->rss_data.enabled_software_rss) { int index =3D virtio_net_process_rss(nc, buf, size, &extra_hdr); if (index >=3D 0) { - NetClientState *nc2 =3D - qemu_get_subqueue(n->nic, index % n->curr_queue_pairs); - return virtio_net_receive_rcu(nc2, buf, size, true); + nc =3D qemu_get_subqueue(n->nic, index % n->curr_queue_pairs); } } =20 @@ -1924,6 +1922,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState = *nc, const uint8_t *buf, return -1; } =20 + q =3D virtio_net_get_subqueue(nc); + /* hdr_len refers to the header we supply to the guest */ if (!virtio_net_has_buffers(q, size + n->guest_hdr_len - n->host_hdr_l= en)) { return 0; @@ -2049,7 +2049,7 @@ static ssize_t virtio_net_do_receive(NetClientState *= nc, const uint8_t *buf, { RCU_READ_LOCK_GUARD(); =20 - return virtio_net_receive_rcu(nc, buf, size, false); + return virtio_net_receive_rcu(nc, buf, size); } =20 /* --=20 2.47.0 From nobody Sat Nov 23 15:09:48 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=1732251833; cv=none; d=zohomail.com; s=zohoarc; b=L+9vnwdUSH33fN8I+BGgitFSogMp6YnFIkRxy+MQJjHZzOv9uCUWyA3DrZt5Qq6Ve2H2wKhykc7boeZLDvhZeYEpOPshEhMWtETYXyTwfC6uYjyC+6ORxY5ZeBUaEQzM1qWwLms6gtJwtruHBJpiVANJSCF5VVmR18jG/laOKsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732251833; 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=d+nFMN+RotazVwbRC0Glc2LmAaySUwmgO7t30fjYowY=; b=K8F5l0Qrek0v+rAmlLtt3VCegcPQ/91DsGOvdsTBOFd4//JBETOFUvAroA/jhUqGI8hCIt+64vU0cBJpK3RVEEICqkHcRc80/XJ9Qsd59bD2bP3ROVxG9mXmSYzg7478mNXQsTVcIYrc5H2tbJgJ2Ua5xlW1UpQ5WuWTo/61euU= 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 17322518338311017.785618040203; Thu, 21 Nov 2024 21:03:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tELpP-0005ps-Ue; Fri, 22 Nov 2024 00:03:37 -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 1tELpK-0005lb-Ah for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:30 -0500 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tELpI-0006U4-M8 for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:29 -0500 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5ee58c5c2e3so837550eaf.2 for ; Thu, 21 Nov 2024 21:03:28 -0800 (PST) Received: from localhost ([157.82.207.167]) by smtp.gmail.com with UTF8SMTPSA id 006d021491bc7-5f06972add3sm259571eaf.1.2024.11.21.21.03.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 21:03:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1732251807; x=1732856607; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=d+nFMN+RotazVwbRC0Glc2LmAaySUwmgO7t30fjYowY=; b=zuKqmoO7FoUK1ilMytiCZzfhp7KO8/mnF87el+8Pm2W+Va6CsirYrKNcfNZUdltr4w kK5PHlVfTpujBw55+XCNXqvIowO5zWwj1Y6Szeh33RUQ7iZZ9O9GLSbdiWFyqhsmphu+ JSByJ/I2iHyX35NDs51ClfmgycvkJjIBuKX6TC77H5poPWN3woJ/7z+Mdvdsk1fpp+tT zbQnD1T6APAH2CplaGknsOW6REpCbkJXyDQTKYd3+T3eMmAUOoEwWV0G9DzTfS9REJvR uzvY8+PW/4Dw9yBapB57Tr3+UCx56bjazHhjduWLVCGKlN5Ql2B2GPxbq9JOhFTS0yOE 0H4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732251807; x=1732856607; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d+nFMN+RotazVwbRC0Glc2LmAaySUwmgO7t30fjYowY=; b=lu5bTL7luapRvVQXnzdmEAaVKqj0AvRGzaylRUv9wU7eIFWIvZuBvT4M6AqvYEMPYH 9fbf6cT9/L/L0fwoYJk1tlWNoNbUp9L5Nr5WqLnbA6mdg6HZrniK1b6T6nilcfxTC7a2 RYlizIyu20vfjJmKeIzEd9Uj2yRci0isP0yhqAdeBSPC01lQvZsvjcjaI9+Bro5i3804 UXnhcAib15NLQY+dA7/tA/Tb3IsEgQCjwul1GQIn5WLGpbxrQKMqT6WNTfmQwfPwxy9T d+k1rg3YYUYaevRSlFyQXB/nHfqXywwoV1z/pYrgFXTdttZdu/aEzi+0yX2tFOjz1xZY cByA== X-Gm-Message-State: AOJu0YzQzCPCADG9Hfx7XrsPd0hnrgy1ibtBKQ2s/LLkbAQ45ZwHbBmR JdVK7JLWVjXukRq4DVW8nInHdInZCxC+bKF6JZwDWnA6AnFOXIb8c430Ipb3QX9XJJePEKS+W8A WYus= X-Gm-Gg: ASbGnctXtWBCmgx1TzA6EAKdzog83BlVA3Lzwvl/d4aT+JvToJdHuh7AvHYmi06OSfQ nLb+tslo0bLb2VEitmotxMVb/iuKkz2r+1GAMKkzVpEuSblElzmnEDQ0qt3RZt6a91t1yP9epau eJmg+tzn0Jsa5v8Q6bRGtRHf2DTauZ3RMwf89baDR89wj/cDxDU52kFEUKcyPFeLJcO4ufz31UO wK97Y7vHGIDhdJ//Cr38vh4+Rh0VVj/kq6UCFT7ngsaU8EQcUEYKA== X-Google-Smtp-Source: AGHT+IFP/8j7E1U3w4AAzhqTkNSbbOzH3dT9owXxO4OlvyJY242mrSUnlEyWXzb2YL7/sMuz+RJrMA== X-Received: by 2002:a05:6820:2d49:b0:5e1:c19d:3f4e with SMTP id 006d021491bc7-5f06aa6f0a9mr1404436eaf.8.1732251807312; Thu, 21 Nov 2024 21:03:27 -0800 (PST) From: Akihiko Odaki Date: Fri, 22 Nov 2024 14:03:11 +0900 Subject: [PATCH v3 5/6] virtio-net: Initialize hash reporting values MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-queue-v3-5-f2ff03b8dbfd@daynix.com> References: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> In-Reply-To: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> To: Jason Wang , "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: pass client-ip=2607:f8b0:4864:20::c30; envelope-from=akihiko.odaki@daynix.com; helo=mail-oo1-xc30.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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1732251834572116600 The specification says hash_report should be set to VIRTIO_NET_HASH_REPORT_NONE if VIRTIO_NET_F_HASH_REPORT is negotiated but not configured with VIRTIO_NET_CTRL_MQ_RSS_CONFIG. However, virtio_net_receive_rcu() instead wrote out the content of the extra_hdr variable, which is not uninitialized in such a case. Fix this by zeroing the extra_hdr. Fixes: e22f0603fb2f ("virtio-net: reference implementation of hash report") Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/virtio-net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b544d2e91a77..44ea72b50e0e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1911,6 +1911,8 @@ static ssize_t virtio_net_receive_rcu(NetClientState = *nc, const uint8_t *buf, size_t offset, i, guest_offset, j; ssize_t err; =20 + memset(&extra_hdr, 0, sizeof(extra_hdr)); + if (n->rss_data.enabled && n->rss_data.enabled_software_rss) { int index =3D virtio_net_process_rss(nc, buf, size, &extra_hdr); if (index >=3D 0) { --=20 2.47.0 From nobody Sat Nov 23 15:09:48 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=1732251852; cv=none; d=zohomail.com; s=zohoarc; b=KwEpYQsmJaHxih7UQqclxI1q+7wJZYbdRoPw9vEQaEfjRc4LbbEWQ7hcSJP9FCYvT9OONS/V2VXweHKPeC6YPylWEvheUKbgRHwdAdZ/O0j7lqygVYvR2ILt65j4xVIgPeXY5C/rMfRA5SBNT6y0DO6whLZyua4T563MaI2SvtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732251851; 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=lm07o6s5E1yl5hc4ZDjLUu2SLmHwkCbH+IFUtNg70Mo=; b=mDaKKBSt1jlHalAQPAa7Vi2Cit3g8mACzYsw4Ha7jBTNUNkL+0rhW3acwdHFYsYnT4VFF4FsQCIJOuFsLo5LTvZZKq+rLcAjeAtTZpr67Gbis+47TOdJOAtJ6HzaH7Kx5lol/FIn7dCyxVZhyLZF65N2anzE4K/ijC4BpTmgcCg= 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 1732251851886780.1723209663473; Thu, 21 Nov 2024 21:04:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tELpU-00063F-7i; Fri, 22 Nov 2024 00:03:40 -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 1tELpO-0005pt-Fx for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:35 -0500 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tELpL-0006X2-O6 for qemu-devel@nongnu.org; Fri, 22 Nov 2024 00:03:34 -0500 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-2958ddf99a7so1597748fac.2 for ; Thu, 21 Nov 2024 21:03:31 -0800 (PST) Received: from localhost ([157.82.207.167]) by smtp.gmail.com with UTF8SMTPSA id 586e51a60fabf-2971d56d992sm377978fac.9.2024.11.21.21.03.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2024 21:03:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1732251810; x=1732856610; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=lm07o6s5E1yl5hc4ZDjLUu2SLmHwkCbH+IFUtNg70Mo=; b=EUg0FomH8aAuNdRvWYi0d68jxU2lauo978HN6Wj8kh3buZypK2n7zdA2WmkCPbZOu5 xuHcvA1Sn87uRYAjm++wZM/9VupVTk9AbtM7mSAakdABKVL+WDh2C/9YUCpWO722e3TT K+vvCAS2pgAcnlXNCPzsN+oHs0ZgfCKIsmKoa8gWURJ9onp1t22vZd68dTNaimmcbQW4 fEF6ZziRQnA9/ocqSMlz2PJrhE27OvEbbywBHcuv3fXQhXUI55qkEpRixuasVL2ateu5 txEUpQXheExVWIUPrgw7qKesAf/TrVdW9pHqw6acTGwsMoscWA3ekPjhFaEzIW93eoD2 bmZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732251810; x=1732856610; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lm07o6s5E1yl5hc4ZDjLUu2SLmHwkCbH+IFUtNg70Mo=; b=l0CzUsXOI2mOyxDeXc1n+aT7+9cEn2VFjUVZLahgme+3ftp+qh+CiS57yb+0rSi58z TgV5ItNOz4K4g67L+APRUK2KvLXY4mufeZvpvhftbyMvL2EBab3fWzxiDa3eWD6HSKxd aucBvMrU3zE327IPsBCI1PvArwx2HKXq0GQElIzbhOlx+N7dabGRH3WAEw/kTUTRNz+U vefnxQvgRAHU72BSYF4YSFVCmvU5qn+4+xTGQ1U6pbaxDGlY9wkjDGaymYId3/PCHX8V eN8eddc6gr4qoKLqefQzX8f304WXRMLB3X7VGeBU0mLzQWdS9K5p6C5YsKtpKCL9BfN7 qk7g== X-Gm-Message-State: AOJu0YyUseSGW8E1Qb388qZpx04C346P2hvV9A73rbI2ZGATuJJGY1OJ gtYV3RoWhz0qrb5fxaXRV9a+zCAFYL87pMI4c2fbqQ3xAjZbfmYf/c5tRLhm62EhUrEkh5aWEpF b+ng= X-Gm-Gg: ASbGncuMHdHPLPPO1DX6VO/qyvy+jbXf5WgZbnWAB3dNTy+1PC7knaFKpR2PdjQf8dI TVUWQa4OjGZKQ5gPwUZrXryiHxLXowGx+AD6m2fIvFr4z60culj18vN6WlYpWzRSOT7NbUWoUEE Z8UfsG7ZPqT8n05zHrvb+g+/e0w4fjrd3dhoFIPIjGHp19w4bExzTUAkNLGoPISqnnbuPd7DenO 7huFDlYdK9PKSgCqSC02nBFuQxUoz3oHHPkZw8iCAv1ANgWMshFpA== X-Google-Smtp-Source: AGHT+IEki3PDwileZavRyApRUozdmVz2sm81vdfgl/UThyJ4Vw/td6BUwJcCAd6orGkvFV99vGGVSQ== X-Received: by 2002:a05:6870:3b0a:b0:296:827c:9073 with SMTP id 586e51a60fabf-29720d91504mr1837604fac.26.1732251810362; Thu, 21 Nov 2024 21:03:30 -0800 (PST) From: Akihiko Odaki Date: Fri, 22 Nov 2024 14:03:12 +0900 Subject: [PATCH v3 6/6] virtio-net: Copy received header to buffer MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241122-queue-v3-6-f2ff03b8dbfd@daynix.com> References: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> In-Reply-To: <20241122-queue-v3-0-f2ff03b8dbfd@daynix.com> To: Jason Wang , "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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: pass client-ip=2001:4860:4864:20::2e; envelope-from=akihiko.odaki@daynix.com; helo=mail-oa1-x2e.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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1732251852776116600 receive_header() used to cast the const qualifier of the pointer to the received packet away to modify the header. Avoid this by copying the received header to buffer. Signed-off-by: Akihiko Odaki --- hw/net/virtio-net.c | 85 +++++++++++++++++++++++++++++--------------------= ---- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 44ea72b50e0e..bc0f31b6669b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1695,41 +1695,44 @@ static void virtio_net_hdr_swap(VirtIODevice *vdev,= struct virtio_net_hdr *hdr) * cache. */ static void work_around_broken_dhclient(struct virtio_net_hdr *hdr, - uint8_t *buf, size_t size) + size_t *hdr_len, const uint8_t *bu= f, + size_t buf_size, size_t *buf_offse= t) { size_t csum_size =3D ETH_HLEN + sizeof(struct ip_header) + sizeof(struct udp_header); =20 + buf +=3D *buf_offset; + buf_size -=3D *buf_offset; + if ((hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && /* missing csum */ - (size >=3D csum_size && size < 1500) && /* normal sized MTU */ + (buf_size >=3D csum_size && buf_size < 1500) && /* normal sized MT= U */ (buf[12] =3D=3D 0x08 && buf[13] =3D=3D 0x00) && /* ethertype =3D= =3D IPv4 */ (buf[23] =3D=3D 17) && /* ip.protocol =3D=3D UDP */ (buf[34] =3D=3D 0 && buf[35] =3D=3D 67)) { /* udp.srcport =3D=3D b= ootps */ - net_checksum_calculate(buf, size, CSUM_UDP); + memcpy((uint8_t *)hdr + *hdr_len, buf, csum_size); + net_checksum_calculate((uint8_t *)hdr + *hdr_len, csum_size, CSUM_= UDP); hdr->flags &=3D ~VIRTIO_NET_HDR_F_NEEDS_CSUM; + *hdr_len +=3D csum_size; + *buf_offset +=3D csum_size; } } =20 -static void receive_header(VirtIONet *n, const struct iovec *iov, int iov_= cnt, - const void *buf, size_t size) +static size_t receive_header(VirtIONet *n, struct virtio_net_hdr *hdr, + const void *buf, size_t buf_size, + size_t *buf_offset) { - if (n->has_vnet_hdr) { - /* FIXME this cast is evil */ - void *wbuf =3D (void *)buf; - work_around_broken_dhclient(wbuf, wbuf + n->host_hdr_len, - size - n->host_hdr_len); + size_t hdr_len =3D n->guest_hdr_len; =20 - if (n->needs_vnet_hdr_swap) { - virtio_net_hdr_swap(VIRTIO_DEVICE(n), wbuf); - } - iov_from_buf(iov, iov_cnt, 0, buf, sizeof(struct virtio_net_hdr)); - } else { - struct virtio_net_hdr hdr =3D { - .flags =3D 0, - .gso_type =3D VIRTIO_NET_HDR_GSO_NONE - }; - iov_from_buf(iov, iov_cnt, 0, &hdr, sizeof hdr); + memcpy(hdr, buf, sizeof(struct virtio_net_hdr)); + + *buf_offset =3D n->host_hdr_len; + work_around_broken_dhclient(hdr, &hdr_len, buf, buf_size, buf_offset); + + if (n->needs_vnet_hdr_swap) { + virtio_net_hdr_swap(VIRTIO_DEVICE(n), hdr); } + + return hdr_len; } =20 static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) @@ -1897,6 +1900,13 @@ static int virtio_net_process_rss(NetClientState *nc= , const uint8_t *buf, return (index =3D=3D new_index) ? -1 : new_index; } =20 +typedef struct Header { + struct virtio_net_hdr_v1_hash virtio_net; + struct eth_header eth; + struct ip_header ip; + struct udp_header udp; +} Header; + static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *b= uf, size_t size) { @@ -1906,15 +1916,15 @@ static ssize_t virtio_net_receive_rcu(NetClientStat= e *nc, const uint8_t *buf, VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE]; size_t lens[VIRTQUEUE_MAX_SIZE]; struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE]; - struct virtio_net_hdr_v1_hash extra_hdr; + Header hdr; unsigned mhdr_cnt =3D 0; size_t offset, i, guest_offset, j; ssize_t err; =20 - memset(&extra_hdr, 0, sizeof(extra_hdr)); + memset(&hdr.virtio_net, 0, sizeof(hdr.virtio_net)); =20 if (n->rss_data.enabled && n->rss_data.enabled_software_rss) { - int index =3D virtio_net_process_rss(nc, buf, size, &extra_hdr); + int index =3D virtio_net_process_rss(nc, buf, size, &hdr.virtio_ne= t); if (index >=3D 0) { nc =3D qemu_get_subqueue(n->nic, index % n->curr_queue_pairs); } @@ -1979,21 +1989,18 @@ static ssize_t virtio_net_receive_rcu(NetClientStat= e *nc, const uint8_t *buf, if (n->mergeable_rx_bufs) { mhdr_cnt =3D iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg), sg, elem->in_num, - offsetof(typeof(extra_hdr), hdr.num_bu= ffers), - sizeof(extra_hdr.hdr.num_buffers)); + offsetof(typeof(hdr), + virtio_net.hdr.num_buffers), + sizeof(hdr.virtio_net.hdr.num_buffers)= ); } =20 - receive_header(n, sg, elem->in_num, buf, size); - if (n->rss_data.populate_hash) { - offset =3D offsetof(typeof(extra_hdr), hash_value); - iov_from_buf(sg, elem->in_num, offset, - (char *)&extra_hdr + offset, - sizeof(extra_hdr.hash_value) + - sizeof(extra_hdr.hash_report)); - } - offset =3D n->host_hdr_len; - total +=3D n->guest_hdr_len; - guest_offset =3D n->guest_hdr_len; + guest_offset =3D n->has_vnet_hdr ? + receive_header(n, (struct virtio_net_hdr *)&hdr, + buf, size, &offset) : + n->guest_hdr_len; + + iov_from_buf(sg, elem->in_num, 0, &hdr, guest_offset); + total +=3D guest_offset; } else { guest_offset =3D 0; } @@ -2019,11 +2026,11 @@ static ssize_t virtio_net_receive_rcu(NetClientStat= e *nc, const uint8_t *buf, } =20 if (mhdr_cnt) { - virtio_stw_p(vdev, &extra_hdr.hdr.num_buffers, i); + virtio_stw_p(vdev, &hdr.virtio_net.hdr.num_buffers, i); iov_from_buf(mhdr_sg, mhdr_cnt, 0, - &extra_hdr.hdr.num_buffers, - sizeof extra_hdr.hdr.num_buffers); + &hdr.virtio_net.hdr.num_buffers, + sizeof hdr.virtio_net.hdr.num_buffers); } =20 for (j =3D 0; j < i; j++) { --=20 2.47.0