From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189324; cv=none; d=zohomail.com; s=zohoarc; b=K7JQV71NmYM7moD4DrEPZmZQR14iCard7KSihCuv+NHbEjFi77lWm1fhb0Q2C8GFzOeGyxTwA4F3SN+SZyhLUXVG0UwP25Yr/Q5sRfhSSWji+/BVj6gSrsI9VjMNdsvRSa6g3CY49EyZnaW9FSmW8PZIHZ3iX1LNCX1sLuqZrNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189324; 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=4ZjB3Af3Eu7jTZIe/vhr6IHTcD6ismi5yenfs4fh47Q=; b=CN2BgpkvNpCt464P/zLqqHl8RuFcyCUc7wMqgkcvtJQqNA8/0Hid9aAYyjaR0qBXpK37Eqdtzg7L+RIqWvb6ruIW4oLdEAHrC2ZyAYcl3hfARAacvsSn3eQQF0ad3VycSGEyzZVH+zBV9Il7Xi+2EnK+W3d71SN1HhPNpozok88= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189324428440.5032030682852; Tue, 29 Oct 2024 01:08:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hG7-00078Q-6t; Tue, 29 Oct 2024 04:07:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hG4-00077q-OH for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hG3-0003vf-7g for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:20 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-_9t5xDVFPZ-mOBR7Ad9T-w-1; Tue, 29 Oct 2024 04:07:15 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF88B1955F10 for ; Tue, 29 Oct 2024 08:07:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7DB6A1956086; Tue, 29 Oct 2024 08:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4ZjB3Af3Eu7jTZIe/vhr6IHTcD6ismi5yenfs4fh47Q=; b=OAZDNqlw5QGtI7P66fbx1+ncMWK999KyGvpuKRwLgYnL9MUsREXewESbfrtZdg0A71xPlU /+Zcnp7D9XzXLNIZHdkdn/Z8/a0ZPI2qcMwsS255zavl5msvYN1R+8Ai7/5NPoIupm6EBu aPB5UGvfwCL/ZFE9PQvi2vilhODlaQI= X-MC-Unique: _9t5xDVFPZ-mOBR7Ad9T-w-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang Subject: [PULL 01/14] net: fix build when libbpf is disabled, but libxdp is enabled Date: Tue, 29 Oct 2024 16:06:52 +0800 Message-ID: <20241029080705.3238-2-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189324779116600 From: Daniel P. Berrang=C3=A9 The net/af-xdp.c code is enabled when the libxdp library is present, however, it also has direct API calls to bpf_xdp_query_id & bpf_xdp_detach which are provided by the libbpf library. As a result if building with --disable-libbpf, but libxdp gets auto-detected, we'll fail to link QEMU /usr/bin/ld: libcommon.a.p/net_af-xdp.c.o: undefined reference to symbol = 'bpf_xdp_query_id@@LIBBPF_0.7.0' There are two bugs here * Since we have direct libbpf API calls, when building net/af-xdp.c, we must tell meson that libbpf is a dependancy, so that we directly link to it, rather than relying on indirect linkage. * When must skip probing for libxdp at all, when libbpf is not found, raising an error if --enable-libxdp was given explicitly. Fixes: cb039ef3d9e3112da01e1ecd9b136ac9809ef733 Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- meson.build | 10 ++++++++-- net/meson.build | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index c26c417de1..9432c5f173 100644 --- a/meson.build +++ b/meson.build @@ -2164,8 +2164,14 @@ endif # libxdp libxdp =3D not_found if not get_option('af_xdp').auto() or have_system - libxdp =3D dependency('libxdp', required: get_option('af_xdp'), - version: '>=3D1.4.0', method: 'pkg-config') + if libbpf.found() + libxdp =3D dependency('libxdp', required: get_option('af_xdp'), + version: '>=3D1.4.0', method: 'pkg-config') + else + if get_option('af_xdp').enabled() + error('libxdp requested, but libbpf is not available') + endif + endif endif =20 # libdw diff --git a/net/meson.build b/net/meson.build index e0cd71470e..bb97b4dcbe 100644 --- a/net/meson.build +++ b/net/meson.build @@ -39,7 +39,7 @@ if have_netmap system_ss.add(files('netmap.c')) endif =20 -system_ss.add(when: libxdp, if_true: files('af-xdp.c')) +system_ss.add(when: [libxdp, libbpf], if_true: files('af-xdp.c')) =20 if have_vhost_net_user system_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost-user.c'),= if_false: files('vhost-user-stub.c')) --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189310; cv=none; d=zohomail.com; s=zohoarc; b=Bh2pAQZMDmVDXBA5JpobRiARmry/L1VFJc7BnQHt9KgjScIc6WfIdlTofaz6cL+idDZwX5ID6X65uY9AN3JLgauNeXYIkP51eMBHpB+u806zifxeReInirtMNyUiajPnwAZh2zu/Rvu9bXkgn53TSnLvjNO6NpS+ju8eFsgw6mQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189310; 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=1bv3Ni3J1teSkGbpGS4vKRXQ+UmcTRKnZUd/nHd5DYY=; b=X0WU/JYpVK7nE4S/UxzUhWYQE+zLPG062EcKbpMerG7P2b1glEh5WpJaVlONmzlccvCKeaH3jJ75oHO8RQYV+y2KON8FfVRi79ODeKEEFv7GzCnJd/Ke/VZ1K4y6tkkWct6v5mqAtTm6KILZxOeCNtXJpgCFi4e2oOUb9iKjwUU= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189310347347.6887862754006; Tue, 29 Oct 2024 01:08:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGJ-00079v-5H; Tue, 29 Oct 2024 04:07:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGH-00079Z-GW for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGF-0003wV-Ol for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:33 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-UOQ1082XMmeVbf4_98UQmw-1; Tue, 29 Oct 2024 04:07:24 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 81BEE1955F3B; Tue, 29 Oct 2024 08:07:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 963B81956086; Tue, 29 Oct 2024 08:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1bv3Ni3J1teSkGbpGS4vKRXQ+UmcTRKnZUd/nHd5DYY=; b=UOx0fhUNr9N4t4JufYo+T2FCYFnf5MCetymSwNs61M/HPGJbVGc1Uz9RjiE/ZYAsS2dg2M aT/C26A7h1b07zMC8VV3rWEE3ALu7rgw5PiPlyO0Ba28og8OkAFagYWsrbpbbZ/d5RlI8v tCiqE1sMu/eRCwQ5cX0bQjDqWu84+KA= X-MC-Unique: UOQ1082XMmeVbf4_98UQmw-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 02/14] hw/net: fix typo s/epbf/ebpf/ in virtio-net Date: Tue, 29 Oct 2024 16:06:53 +0800 Message-ID: <20241029080705.3238-3-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189310869116600 From: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index fb84d142ee..7c050246ea 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1254,7 +1254,7 @@ static void rss_data_to_rss_config(struct VirtioNetRs= sData *data, config->default_queue =3D data->default_queue; } =20 -static bool virtio_net_attach_epbf_rss(VirtIONet *n) +static bool virtio_net_attach_ebpf_rss(VirtIONet *n) { struct EBPFRSSConfig config =3D {}; =20 @@ -1276,7 +1276,7 @@ static bool virtio_net_attach_epbf_rss(VirtIONet *n) return true; } =20 -static void virtio_net_detach_epbf_rss(VirtIONet *n) +static void virtio_net_detach_ebpf_rss(VirtIONet *n) { virtio_net_attach_ebpf_to_backend(n->nic, -1); } @@ -1286,8 +1286,8 @@ static void virtio_net_commit_rss_config(VirtIONet *n) if (n->rss_data.enabled) { n->rss_data.enabled_software_rss =3D n->rss_data.populate_hash; if (n->rss_data.populate_hash) { - virtio_net_detach_epbf_rss(n); - } else if (!virtio_net_attach_epbf_rss(n)) { + virtio_net_detach_ebpf_rss(n); + } else if (!virtio_net_attach_ebpf_rss(n)) { if (get_vhost_net(qemu_get_queue(n->nic)->peer)) { warn_report("Can't load eBPF RSS for vhost"); } else { @@ -1300,7 +1300,7 @@ static void virtio_net_commit_rss_config(VirtIONet *n) n->rss_data.indirections_len, sizeof(n->rss_data.key)); } else { - virtio_net_detach_epbf_rss(n); + virtio_net_detach_ebpf_rss(n); trace_virtio_net_rss_disable(); } } --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189344; cv=none; d=zohomail.com; s=zohoarc; b=lAJWm0EZPc6/1Afwy/gRrMQkE3lkvhbq34Jw13fMFG8wGNfuNiJkTy2+8CUQc94z7b72xxyYj5apbE3YsL2EsZm56ITC57m+r9KgjF6BUQLUZ0HzsX5FLOcR/07ZiboFgrDoI4bufOVbap4VYtFkerVfCNJeT+w/QwCxymunpp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189344; 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=HHd2khAkamBh5tFzuUIoWG4bBvfNivxOiVFOwC1nFGY=; b=k2mWbkAWmuMEtMJFpHVnBbBLTPRWTe1l75RM8x5aavc8lJmYHC6nNW7N/me1jpv8d10HkaZ+bDzQEVApJCatCcD6DgWB7S6+1ehGsQsCsbQKzI+DgzDtxYTPCe5Due4kAxZpFXpBRpcBIP36iFZqicqSPUzE5JH/Nk0fKknlYtw= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189344254837.7664097294476; Tue, 29 Oct 2024 01:09:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGD-00079R-2z; Tue, 29 Oct 2024 04:07:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGA-00078v-NP for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hG9-0003w6-8M for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:26 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-Kb-rnj3pNZmZHKTn9-k2Pw-1; Tue, 29 Oct 2024 04:07:23 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 523401956096 for ; Tue, 29 Oct 2024 08:07:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 561621956089; Tue, 29 Oct 2024 08:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HHd2khAkamBh5tFzuUIoWG4bBvfNivxOiVFOwC1nFGY=; b=i3UJZt2cR5Do2v13RB/50vYdC5lUBIBF6nYW9x5Rds2Zg+GQtYH/xNrwS5CV2NsTyibWid 4zykPoTUsYUDjq52uUMYhn649HBSZEywLpAzBKQ+rHUlwtKzaxtX210bHlcPYRpo5l41dD X+Kmp9R3oFEhNKp2jOiTiNrkt17UmlY= X-MC-Unique: Kb-rnj3pNZmZHKTn9-k2Pw-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang Subject: [PULL 03/14] ebpf: drop redundant parameter checks in static methods Date: Tue, 29 Oct 2024 16:06:54 +0800 Message-ID: <20241029080705.3238-4-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189344823116600 From: Daniel P. Berrang=C3=A9 Various static methods have checks on their parameters which were already checked immediately before the method was invoked. Drop these redundat checks to simplify the following commit which adds formal error reporting. Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- ebpf/ebpf_rss.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index dcaa80f380..0c42355a93 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -49,10 +49,6 @@ bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) =20 static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) { - if (!ebpf_rss_is_loaded(ctx)) { - return false; - } - ctx->mmap_configuration =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_configuration, 0); @@ -90,10 +86,6 @@ toeplitz_fail: =20 static void ebpf_rss_munmap(struct EBPFRSSContext *ctx) { - if (!ebpf_rss_is_loaded(ctx)) { - return; - } - munmap(ctx->mmap_indirections_table, qemu_real_host_page_size()); munmap(ctx->mmap_toeplitz_key, qemu_real_host_page_size()); munmap(ctx->mmap_configuration, qemu_real_host_page_size()); @@ -177,15 +169,10 @@ bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, in= t program_fd, return true; } =20 -static bool ebpf_rss_set_config(struct EBPFRSSContext *ctx, +static void ebpf_rss_set_config(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config) { - if (!ebpf_rss_is_loaded(ctx)) { - return false; - } - memcpy(ctx->mmap_configuration, config, sizeof(*config)); - return true; } =20 static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx, @@ -194,8 +181,7 @@ static bool ebpf_rss_set_indirections_table(struct EBPF= RSSContext *ctx, { char *cursor =3D ctx->mmap_indirections_table; =20 - if (!ebpf_rss_is_loaded(ctx) || indirections_table =3D=3D NULL || - len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { + if (len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { return false; } =20 @@ -207,20 +193,16 @@ static bool ebpf_rss_set_indirections_table(struct EB= PFRSSContext *ctx, return true; } =20 -static bool ebpf_rss_set_toepliz_key(struct EBPFRSSContext *ctx, +static void ebpf_rss_set_toepliz_key(struct EBPFRSSContext *ctx, uint8_t *toeplitz_key) { /* prepare toeplitz key */ uint8_t toe[VIRTIO_NET_RSS_MAX_KEY_SIZE] =3D {}; =20 - if (!ebpf_rss_is_loaded(ctx) || toeplitz_key =3D=3D NULL) { - return false; - } memcpy(toe, toeplitz_key, VIRTIO_NET_RSS_MAX_KEY_SIZE); *(uint32_t *)toe =3D ntohl(*(uint32_t *)toe); =20 memcpy(ctx->mmap_toeplitz_key, toe, VIRTIO_NET_RSS_MAX_KEY_SIZE); - return true; } =20 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, @@ -231,18 +213,14 @@ bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, str= uct EBPFRSSConfig *config, return false; } =20 - if (!ebpf_rss_set_config(ctx, config)) { - return false; - } + ebpf_rss_set_config(ctx, config); =20 if (!ebpf_rss_set_indirections_table(ctx, indirections_table, config->indirections_len)) { return false; } =20 - if (!ebpf_rss_set_toepliz_key(ctx, toeplitz_key)) { - return false; - } + ebpf_rss_set_toepliz_key(ctx, toeplitz_key); =20 return true; } --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189341; cv=none; d=zohomail.com; s=zohoarc; b=ZPzy4APAy3ZwfC/oQOv12zXI7eZlDpfXJYbhht1zAEsUy66XYGrtAZBZyIGnB5YogWTkJUgBbgC29sx1pgHfDW2HcdeHbf9c00d5uSRXT6II20s+RGH6d5M7AczLV8ciGVFmDIN3bjfrU6GsvP1gymoh3Z28Nu3ylmHKt6eYOtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189340; 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=ro9PCYPY9m4BRbkqSeL9WdJZPAwtrPGW/UX72Dkz8J8=; b=CmVDyyxqbDdLyqWVWwX/pz0dgf957NIqmd+4fRIOsKpu8g5tWDC0rEMJm/Yk/nF/Kx0oW+1TYx5RXrn4DESuBPX6dKP0DERNfdfSheBv4UzN/6rQwOhQJ1cdRycBJNgnuKIXwVeuAVfrrp2O6CcE8sOtTqZtpQDfWYdxY5e7+4Q= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189340989875.6496486302209; Tue, 29 Oct 2024 01:09:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGJ-0007AW-Pe; Tue, 29 Oct 2024 04:07:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGH-00079l-Ui for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGG-0003wT-BS for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:33 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-YZiqxrpMMniFsimxxzTodA-1; Tue, 29 Oct 2024 04:07:27 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B9AC1955D4A for ; Tue, 29 Oct 2024 08:07:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3F23A1956089; Tue, 29 Oct 2024 08:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ro9PCYPY9m4BRbkqSeL9WdJZPAwtrPGW/UX72Dkz8J8=; b=c8t4fASZruUH0E02MqQQsS1owN/M6d5/A/0ZHofvuNaHsDb7pUu8YuDMDLg66ilx6W0aEC fePMCDwr7sFc/uGnGId9YnyDG0vbatLKLpyccf2jVSU/sD1psal1ROzkRBreHIeWp/zyOD rNG1NE9HUPlt7ve+ZmziCvkMZmUyJ+8= X-MC-Unique: YZiqxrpMMniFsimxxzTodA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang Subject: [PULL 04/14] ebpf: improve error trace events Date: Tue, 29 Oct 2024 16:06:55 +0800 Message-ID: <20241029080705.3238-5-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189343117116600 From: Daniel P. Berrang=C3=A9 A design pattern of trace_foo_error("descriptive string") is undesirable because it does not allow for filtering trace events based on the error scenario. Split eBPF error trace event into three separate events to address this filtering need. Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- ebpf/ebpf_rss.c | 10 +++++----- ebpf/trace-events | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 0c42355a93..d39916b368 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -53,21 +53,21 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_configuration, 0); if (ctx->mmap_configuration =3D=3D MAP_FAILED) { - trace_ebpf_error("eBPF RSS", "can not mmap eBPF configuration arra= y"); + trace_ebpf_rss_mmap_error(ctx, "configuration"); return false; } ctx->mmap_toeplitz_key =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_toeplitz_key, 0); if (ctx->mmap_toeplitz_key =3D=3D MAP_FAILED) { - trace_ebpf_error("eBPF RSS", "can not mmap eBPF toeplitz key"); + trace_ebpf_rss_mmap_error(ctx, "toeplitz key"); goto toeplitz_fail; } ctx->mmap_indirections_table =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_indirections_table, 0); if (ctx->mmap_indirections_table =3D=3D MAP_FAILED) { - trace_ebpf_error("eBPF RSS", "can not mmap eBPF indirection table"= ); + trace_ebpf_rss_mmap_error(ctx, "indirections table"); goto indirection_fail; } =20 @@ -105,14 +105,14 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) =20 rss_bpf_ctx =3D rss_bpf__open(); if (rss_bpf_ctx =3D=3D NULL) { - trace_ebpf_error("eBPF RSS", "can not open eBPF RSS object"); + trace_ebpf_rss_open_error(ctx); goto error; } =20 bpf_program__set_type(rss_bpf_ctx->progs.tun_rss_steering_prog, BPF_PR= OG_TYPE_SOCKET_FILTER); =20 if (rss_bpf__load(rss_bpf_ctx)) { - trace_ebpf_error("eBPF RSS", "can not load RSS program"); + trace_ebpf_rss_load_error(ctx); goto error; } =20 diff --git a/ebpf/trace-events b/ebpf/trace-events index b3ad1a35f2..a0f157be37 100644 --- a/ebpf/trace-events +++ b/ebpf/trace-events @@ -1,4 +1,6 @@ # See docs/devel/tracing.rst for syntax documentation. =20 # ebpf-rss.c -ebpf_error(const char *s1, const char *s2) "error in %s: %s" +ebpf_rss_load_error(void *ctx) "ctx=3D%p" +ebpf_rss_mmap_error(void *ctx, const char *object) "ctx=3D%p object=3D%s" +ebpf_rss_open_error(void *ctx) "ctx=3D%p" --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189437; cv=none; d=zohomail.com; s=zohoarc; b=dTM1HYwgT0ZXdrCMOnn2b7e7wBDNC5nkaI9jv+Od7lRe4GU0cdF4gpcSKE2eQulDNl6be4XGHa0I+4az+xPrQDFBh2UlMLAbvC9Ng4KD8tzlSlIR2QtN4lpflDkcKI+GLg2lMQla1m1x5fw4zD+tHnv+rUX7/tUaHkDlg2w2qlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189437; 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=xwhu0kU3gMv+/8fWBsagGexY67ihqH3a0cEyPFcMJII=; b=AoipIDnn69GjEFiGql1NysAdIpDCZP34g37wODkOwazfz5+hMxYia4335wEHc203SxsXyDCQiLtQED+g0P/T7ZMuDJYBmGFUWLT9bQ9j2ajXdCtiwoAtUfWMrq/DY5NDN/ICMeRr8tFCqc1HbjCcycWXHnFDWg3iBDiUrA9vt0k= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189437939573.7418500007111; Tue, 29 Oct 2024 01:10:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGL-0007As-A7; Tue, 29 Oct 2024 04:07:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGJ-0007A3-FH for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGH-0003wl-Ip for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:35 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-TpGj8ea9MpyT_JD3mIDyhQ-1; Tue, 29 Oct 2024 04:07:30 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D0B7C1955D5A for ; Tue, 29 Oct 2024 08:07:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F69E1956086; Tue, 29 Oct 2024 08:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xwhu0kU3gMv+/8fWBsagGexY67ihqH3a0cEyPFcMJII=; b=TAN+wN0EHd4zZLHO9INt1ascgjJUbP31FNp8EyZ8MvnkWG9bsidqDjeVUtBKjnQI8gPC3J YE4EoYO+04K2WEqUwKXiikLuQ4ms+ZldKHK2z0fvtOWY10+/5vX0DjyMnhEfppSYMgmFHe BYdeizLQIYeETID80j1o9iaev4j2wYM= X-MC-Unique: TpGj8ea9MpyT_JD3mIDyhQ-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang Subject: [PULL 05/14] ebpf: add formal error reporting to all APIs Date: Tue, 29 Oct 2024 16:06:56 +0800 Message-ID: <20241029080705.3238-6-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189439344116600 From: Daniel P. Berrang=C3=A9 The eBPF code is currently reporting error messages through trace events. Trace events are fine for debugging, but they are not to be considered the primary error reporting mechanism, as their output is inaccessible to callers. This adds an "Error **errp" parameter to all methods which have important error scenarios to report to the caller. Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- ebpf/ebpf_rss-stub.c | 8 +++--- ebpf/ebpf_rss.c | 59 +++++++++++++++++++++++++++++++++++--------- ebpf/ebpf_rss.h | 10 +++++--- hw/net/virtio-net.c | 7 +++--- 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/ebpf/ebpf_rss-stub.c b/ebpf/ebpf_rss-stub.c index 8d7fae2ad9..d0e7f99fb9 100644 --- a/ebpf/ebpf_rss-stub.c +++ b/ebpf/ebpf_rss-stub.c @@ -23,19 +23,21 @@ bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) return false; } =20 -bool ebpf_rss_load(struct EBPFRSSContext *ctx) +bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error **errp) { return false; } =20 bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int program_fd, - int config_fd, int toeplitz_fd, int table_fd) + int config_fd, int toeplitz_fd, int table_fd, + Error **errp) { return false; } =20 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, - uint16_t *indirections_table, uint8_t *toeplitz_key) + uint16_t *indirections_table, uint8_t *toeplitz_key, + Error **errp) { return false; } diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index d39916b368..67cdab197d 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -47,13 +47,14 @@ bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) return ctx !=3D NULL && (ctx->obj !=3D NULL || ctx->program_fd !=3D -1= ); } =20 -static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) +static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx, Error **errp) { ctx->mmap_configuration =3D mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_WRITE, MAP_SHARED, ctx->map_configuration, 0); if (ctx->mmap_configuration =3D=3D MAP_FAILED) { trace_ebpf_rss_mmap_error(ctx, "configuration"); + error_setg(errp, "Unable to map eBPF configuration array"); return false; } ctx->mmap_toeplitz_key =3D mmap(NULL, qemu_real_host_page_size(), @@ -61,6 +62,7 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) ctx->map_toeplitz_key, 0); if (ctx->mmap_toeplitz_key =3D=3D MAP_FAILED) { trace_ebpf_rss_mmap_error(ctx, "toeplitz key"); + error_setg(errp, "Unable to map eBPF toeplitz array"); goto toeplitz_fail; } ctx->mmap_indirections_table =3D mmap(NULL, qemu_real_host_page_size(), @@ -68,6 +70,7 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx) ctx->map_indirections_table, 0); if (ctx->mmap_indirections_table =3D=3D MAP_FAILED) { trace_ebpf_rss_mmap_error(ctx, "indirections table"); + error_setg(errp, "Unable to map eBPF indirection array"); goto indirection_fail; } =20 @@ -95,7 +98,7 @@ static void ebpf_rss_munmap(struct EBPFRSSContext *ctx) ctx->mmap_indirections_table =3D NULL; } =20 -bool ebpf_rss_load(struct EBPFRSSContext *ctx) +bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error **errp) { struct rss_bpf *rss_bpf_ctx; =20 @@ -106,6 +109,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) rss_bpf_ctx =3D rss_bpf__open(); if (rss_bpf_ctx =3D=3D NULL) { trace_ebpf_rss_open_error(ctx); + error_setg(errp, "Unable to open eBPF RSS object"); goto error; } =20 @@ -113,6 +117,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) =20 if (rss_bpf__load(rss_bpf_ctx)) { trace_ebpf_rss_load_error(ctx); + error_setg(errp, "Unable to load eBPF program"); goto error; } =20 @@ -126,7 +131,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) ctx->map_toeplitz_key =3D bpf_map__fd( rss_bpf_ctx->maps.tap_rss_map_toeplitz_key); =20 - if (!ebpf_rss_mmap(ctx)) { + if (!ebpf_rss_mmap(ctx, errp)) { goto error; } =20 @@ -143,13 +148,28 @@ error: } =20 bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int program_fd, - int config_fd, int toeplitz_fd, int table_fd) + int config_fd, int toeplitz_fd, int table_fd, + Error **errp) { if (ebpf_rss_is_loaded(ctx)) { + error_setg(errp, "eBPF program is already loaded"); return false; } =20 - if (program_fd < 0 || config_fd < 0 || toeplitz_fd < 0 || table_fd < 0= ) { + if (program_fd < 0) { + error_setg(errp, "eBPF program FD is not open"); + return false; + } + if (config_fd < 0) { + error_setg(errp, "eBPF config FD is not open"); + return false; + } + if (toeplitz_fd < 0) { + error_setg(errp, "eBPF toeplitz FD is not open"); + return false; + } + if (table_fd < 0) { + error_setg(errp, "eBPF indirection FD is not open"); return false; } =20 @@ -158,7 +178,7 @@ bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int = program_fd, ctx->map_toeplitz_key =3D toeplitz_fd; ctx->map_indirections_table =3D table_fd; =20 - if (!ebpf_rss_mmap(ctx)) { + if (!ebpf_rss_mmap(ctx, errp)) { ctx->program_fd =3D -1; ctx->map_configuration =3D -1; ctx->map_toeplitz_key =3D -1; @@ -177,11 +197,14 @@ static void ebpf_rss_set_config(struct EBPFRSSContext= *ctx, =20 static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx, uint16_t *indirections_table, - size_t len) + size_t len, + Error **errp) { char *cursor =3D ctx->mmap_indirections_table; =20 if (len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { + error_setg(errp, "Indirections table length %zu exceeds limit %d", + len, VIRTIO_NET_RSS_MAX_TABLE_LEN); return false; } =20 @@ -206,17 +229,31 @@ static void ebpf_rss_set_toepliz_key(struct EBPFRSSCo= ntext *ctx, } =20 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, - uint16_t *indirections_table, uint8_t *toeplitz_key) + uint16_t *indirections_table, uint8_t *toeplitz_key, + Error **errp) { - if (!ebpf_rss_is_loaded(ctx) || config =3D=3D NULL || - indirections_table =3D=3D NULL || toeplitz_key =3D=3D NULL) { + if (!ebpf_rss_is_loaded(ctx)) { + error_setg(errp, "eBPF program is not loaded"); + return false; + } + if (config =3D=3D NULL) { + error_setg(errp, "eBPF config table is NULL"); + return false; + } + if (indirections_table =3D=3D NULL) { + error_setg(errp, "eBPF indirections table is NULL"); + return false; + } + if (toeplitz_key =3D=3D NULL) { + error_setg(errp, "eBPF toeplitz key is NULL"); return false; } =20 ebpf_rss_set_config(ctx, config); =20 if (!ebpf_rss_set_indirections_table(ctx, indirections_table, - config->indirections_len)) { + config->indirections_len, + errp)) { return false; } =20 diff --git a/ebpf/ebpf_rss.h b/ebpf/ebpf_rss.h index 239242b0d2..86a5787789 100644 --- a/ebpf/ebpf_rss.h +++ b/ebpf/ebpf_rss.h @@ -14,6 +14,8 @@ #ifndef QEMU_EBPF_RSS_H #define QEMU_EBPF_RSS_H =20 +#include "qapi/error.h" + #define EBPF_RSS_MAX_FDS 4 =20 struct EBPFRSSContext { @@ -41,13 +43,15 @@ void ebpf_rss_init(struct EBPFRSSContext *ctx); =20 bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx); =20 -bool ebpf_rss_load(struct EBPFRSSContext *ctx); +bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error **errp); =20 bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int program_fd, - int config_fd, int toeplitz_fd, int table_fd); + int config_fd, int toeplitz_fd, int table_fd, + Error **errp); =20 bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, - uint16_t *indirections_table, uint8_t *toeplitz_key); + uint16_t *indirections_table, uint8_t *toeplitz_key, + Error **errp); =20 void ebpf_rss_unload(struct EBPFRSSContext *ctx); =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7c050246ea..289fba8152 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1265,7 +1265,8 @@ static bool virtio_net_attach_ebpf_rss(VirtIONet *n) rss_data_to_rss_config(&n->rss_data, &config); =20 if (!ebpf_rss_set_all(&n->ebpf_rss, &config, - n->rss_data.indirections_table, n->rss_data.key)= ) { + n->rss_data.indirections_table, n->rss_data.key, + NULL)) { return false; } =20 @@ -1336,7 +1337,7 @@ static bool virtio_net_load_ebpf_fds(VirtIONet *n) } } =20 - ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= ); + ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= , NULL); =20 exit: if (!ret) { @@ -1354,7 +1355,7 @@ static bool virtio_net_load_ebpf(VirtIONet *n) =20 if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) { if (!(n->ebpf_rss_fds && virtio_net_load_ebpf_fds(n))) { - ret =3D ebpf_rss_load(&n->ebpf_rss); + ret =3D ebpf_rss_load(&n->ebpf_rss, NULL); } } =20 --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189310; cv=none; d=zohomail.com; s=zohoarc; b=PrI9c1T9jezPi8VGlhvSMSGypTtyHmhoIDS8/bhUk9JQSZojWJsIlil2NftRy1zxaNf0UGlHCj+eNRYTd5wwN6mcKXfek4swvYKoc6VeneFrHYaBrTUaasiM03g5duohSDio69JQgCOPXTNwzO/De4ISeEJ/X6gbXPRDK0qwwoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189310; 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=m2suDZfQpDqpwj6AS4dJJjae/UH5ptWRp3zP+J83GOs=; b=ekp3y8SADa5ALF6KhaSy5iF0U2Y+Q19IoIqG+CGXUXwbeBsJqNASEQBUeQmkCnFEyZJiSuJsIEKKr4jNc16rsxqtwXekv+Qt+P7vTYKVp1TCmDLsxR7ecQkufBOuhEunRrcvoQPC1fJeYIDXJRYUmZ7GsieO9cYstpVJmWb7ASg= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189310621232.83751056663675; Tue, 29 Oct 2024 01:08:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGP-0007BA-Pm; Tue, 29 Oct 2024 04:07:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGN-0007B1-EN for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGM-0003xB-0Y for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:39 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-AV2E5m3vN3GbVJ5q5ECWHQ-1; Tue, 29 Oct 2024 04:07:33 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D79F1956048 for ; Tue, 29 Oct 2024 08:07:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C0D751956086; Tue, 29 Oct 2024 08:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m2suDZfQpDqpwj6AS4dJJjae/UH5ptWRp3zP+J83GOs=; b=S4D2V5RVhfFhvZS+mwP5tHakufMuOZFZyCZP/LC9ZpJIWLC3HHQ88+5ZSFXtpOWbsnmKOL PyFORHhBsiB+2IwYXuB0aAADOAMT5tNNOTP5PqZQFtvZMw2qS6194kWYAzKCWgZs6to+Wu lrT+s6R8K54znhtdR3+3DRbYJMmAVP4= X-MC-Unique: AV2E5m3vN3GbVJ5q5ECWHQ-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang Subject: [PULL 06/14] hw/net: report errors from failing to use eBPF RSS FDs Date: Tue, 29 Oct 2024 16:06:57 +0800 Message-ID: <20241029080705.3238-7-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189312938116600 From: Daniel P. Berrang=C3=A9 If the user/mgmt app passed in a set of pre-opened FDs for eBPF RSS, then it is expecting QEMU to use them. Any failure to do so must be considered a fatal error and propagated back up the stack, otherwise deployment mistakes will not be detectable in a prompt manner. When not using pre-opened FDs, then eBPF RSS is tried on a "best effort" basis only and thus fallback to software RSS is valid. Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 289fba8152..c08ae55424 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1316,28 +1316,27 @@ static void virtio_net_disable_rss(VirtIONet *n) virtio_net_commit_rss_config(n); } =20 -static bool virtio_net_load_ebpf_fds(VirtIONet *n) +static bool virtio_net_load_ebpf_fds(VirtIONet *n, Error **errp) { int fds[EBPF_RSS_MAX_FDS] =3D { [0 ... EBPF_RSS_MAX_FDS - 1] =3D -1}; int ret =3D true; int i =3D 0; =20 if (n->nr_ebpf_rss_fds !=3D EBPF_RSS_MAX_FDS) { - warn_report("Expected %d file descriptors but got %d", - EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds); - return false; - } + error_setg(errp, "Expected %d file descriptors but got %d", + EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds); + return false; + } =20 for (i =3D 0; i < n->nr_ebpf_rss_fds; i++) { - fds[i] =3D monitor_fd_param(monitor_cur(), n->ebpf_rss_fds[i], - &error_warn); + fds[i] =3D monitor_fd_param(monitor_cur(), n->ebpf_rss_fds[i], err= p); if (fds[i] < 0) { ret =3D false; goto exit; } } =20 - ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= , NULL); + ret =3D ebpf_rss_load_fds(&n->ebpf_rss, fds[0], fds[1], fds[2], fds[3]= , errp); =20 exit: if (!ret) { @@ -1349,13 +1348,15 @@ exit: return ret; } =20 -static bool virtio_net_load_ebpf(VirtIONet *n) +static bool virtio_net_load_ebpf(VirtIONet *n, Error **errp) { bool ret =3D false; =20 if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) { - if (!(n->ebpf_rss_fds && virtio_net_load_ebpf_fds(n))) { - ret =3D ebpf_rss_load(&n->ebpf_rss, NULL); + if (n->ebpf_rss_fds) { + ret =3D virtio_net_load_ebpf_fds(n, errp); + } else { + ret =3D ebpf_rss_load(&n->ebpf_rss, errp); } } =20 @@ -3761,7 +3762,23 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) net_rx_pkt_init(&n->rx_pkt); =20 if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { - virtio_net_load_ebpf(n); + Error *err =3D NULL; + if (!virtio_net_load_ebpf(n, &err)) { + /* + * If user explicitly gave QEMU RSS FDs to use, then + * failing to use them must be considered a fatal + * error. If no RSS FDs were provided, QEMU is trying + * eBPF on a "best effort" basis only, so report a + * warning and allow fallback to software RSS. + */ + if (n->ebpf_rss_fds) { + error_propagate(errp, err); + } else { + warn_report("unable to load eBPF RSS: %s", + error_get_pretty(err)); + error_free(err); + } + } } } =20 --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189396; cv=none; d=zohomail.com; s=zohoarc; b=DV4gGoz6leR9fmo+aP3K6Jwrv5CBrhqh3tXtfnsF3nQN6h1QQHIbRMrCuuFtoazAiEPww1E6OSiPXJdArP50WReQyG4g+H5f5BehgdNKWtJsCrf3CxRKGjZU48xDDg+46xfe890R6g0pSyUeiMr7uNDxFmyrmGVpFm2BCoMstEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189396; 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+NcLslf7XWhzylz6z1ydJdZcyNutMW/KLHKzB7lV50=; b=dWM0IunlXEKPhuFR69ZB9vAs0r9HOtzANlA4436JRLcEqx5zUTIZscSComRi13/8ZurvHEbiGkfGCs5VnTOVb4Nq4kjwNLWuCSBNIlOGjh5D0pe/l+gmmPL+Pac7nJMuqYXj5PhMu9HFjdpZq5ReqssdJbf4ZKBDWgt/NkjYx3I= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189396407756.7206375544032; Tue, 29 Oct 2024 01:09:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hI4-0001f6-1i; Tue, 29 Oct 2024 04:09:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hHj-0001PT-Gf for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:09:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hHh-00043j-V3 for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:09:03 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-MGSK25_HP1OFzN6AjUmQwg-1; Tue, 29 Oct 2024 04:07:37 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4E0031955F3B for ; Tue, 29 Oct 2024 08:07:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E91741956086; Tue, 29 Oct 2024 08:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D+NcLslf7XWhzylz6z1ydJdZcyNutMW/KLHKzB7lV50=; b=iL62sWAZkLDfK14SoWwF5dS6+/HqseF7UKL+vg2dHfp8j/iYkEHWkqNjlqWtvJxTB/ABZ8 rIS4eVu1eu08fIdG/UQ+/XUEq+YCfvuvecDJ2F8xh87+JO1R5DbflEkqiGw9gi+fPp2Kwt XBWK88SZAJgITfQ1Htt7nREMkziqD4o= X-MC-Unique: MGSK25_HP1OFzN6AjUmQwg-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang Subject: [PULL 07/14] ebpf: improve trace event coverage to all key operations Date: Tue, 29 Oct 2024 16:06:58 +0800 Message-ID: <20241029080705.3238-8-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189397067116600 From: Daniel P. Berrang=C3=A9 The existing error trace event is renamed to have a name prefix matching its source file & to remove the redundant first arg that adds no useful information. Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- ebpf/ebpf_rss.c | 19 +++++++++++++++++++ ebpf/trace-events | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 67cdab197d..e793786c17 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -74,6 +74,10 @@ static bool ebpf_rss_mmap(struct EBPFRSSContext *ctx, Er= ror **errp) goto indirection_fail; } =20 + trace_ebpf_rss_mmap(ctx, + ctx->mmap_configuration, + ctx->mmap_toeplitz_key, + ctx->mmap_indirections_table); return true; =20 indirection_fail: @@ -131,6 +135,11 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx, Error *= *errp) ctx->map_toeplitz_key =3D bpf_map__fd( rss_bpf_ctx->maps.tap_rss_map_toeplitz_key); =20 + trace_ebpf_rss_load(ctx, + ctx->program_fd, + ctx->map_configuration, + ctx->map_indirections_table, + ctx->map_toeplitz_key); if (!ebpf_rss_mmap(ctx, errp)) { goto error; } @@ -178,6 +187,12 @@ bool ebpf_rss_load_fds(struct EBPFRSSContext *ctx, int= program_fd, ctx->map_toeplitz_key =3D toeplitz_fd; ctx->map_indirections_table =3D table_fd; =20 + trace_ebpf_rss_load(ctx, + ctx->program_fd, + ctx->map_configuration, + ctx->map_indirections_table, + ctx->map_toeplitz_key); + if (!ebpf_rss_mmap(ctx, errp)) { ctx->program_fd =3D -1; ctx->map_configuration =3D -1; @@ -259,6 +274,8 @@ bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struc= t EBPFRSSConfig *config, =20 ebpf_rss_set_toepliz_key(ctx, toeplitz_key); =20 + trace_ebpf_rss_set_data(ctx, config, indirections_table, toeplitz_key); + return true; } =20 @@ -268,6 +285,8 @@ void ebpf_rss_unload(struct EBPFRSSContext *ctx) return; } =20 + trace_ebpf_rss_unload(ctx); + ebpf_rss_munmap(ctx); =20 if (ctx->obj) { diff --git a/ebpf/trace-events b/ebpf/trace-events index a0f157be37..bf3d9b6451 100644 --- a/ebpf/trace-events +++ b/ebpf/trace-events @@ -1,6 +1,10 @@ # See docs/devel/tracing.rst for syntax documentation. =20 # ebpf-rss.c +ebpf_rss_load(void *ctx, int progfd, int cfgfd, int toepfd, int indirfd) "= ctx=3D%p program-fd=3D%d config-fd=3D%d toeplitz-fd=3D%d indirection-fd=3D%= d" ebpf_rss_load_error(void *ctx) "ctx=3D%p" +ebpf_rss_mmap(void *ctx, void *cfgptr, void *toepptr, void *indirptr) "ctx= =3D%p config-ptr=3D%p toeplitz-ptr=3D%p indirection-ptr=3D%p" ebpf_rss_mmap_error(void *ctx, const char *object) "ctx=3D%p object=3D%s" ebpf_rss_open_error(void *ctx) "ctx=3D%p" +ebpf_rss_set_data(void *ctx, void *cfgptr, void *toepptr, void *indirptr) = "ctx=3D%p config-ptr=3D%p toeplitz-ptr=3D%p indirection-ptr=3D%p" +ebpf_rss_unload(void *ctx) "rss unload ctx=3D%p" --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189329; cv=none; d=zohomail.com; s=zohoarc; b=Z+uIzZCSIXQ6EfB5EQdD+kTDipUEdo4KQj6b2hZELzCm8gyeB137avOwXiJSZCcyntYzwDpNPn0F7TgSBjbPCG276KLH1JMc10MEd45Xt3+XsWvhTr7wZM1wISi9IxxKxwQpysbvGlO6+jBx6Q/2Ni+dz8TT3ltCHP/1eT/zoEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189329; 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=sVyOAwecPe1+DneilUFhngyUTT3SIJxkG+8rgg9pMfA=; b=ncB4UwOwzrDr/EuQGMob5pg6IqeEMhqIUX+jvuvdCEILZOlov1AfWk0KrvL84D7NH5hLkW9jeij9//dfX0VR74AZ62lpUZHG8j/OlNJutByDliV0CGIZYMHF0fUOmLzYM608dLTETNxhC0+uwhKg6KiscM1LNt+rGw2FfIdDvt8= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17301893298151018.9118985540827; Tue, 29 Oct 2024 01:08:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGT-0007Bn-Sa; Tue, 29 Oct 2024 04:07:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGR-0007BY-Vq for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGQ-0003xj-HU for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:43 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-311-39HM99g5OYS2pzogppFDcg-1; Tue, 29 Oct 2024 04:07:40 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8829A1955D4E for ; Tue, 29 Oct 2024 08:07:39 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 347D41956086; Tue, 29 Oct 2024 08:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sVyOAwecPe1+DneilUFhngyUTT3SIJxkG+8rgg9pMfA=; b=bbrkp4Ev89gK4l+2BrcndSQPJkfUbQPSOKxDM4iebr79mMNFDjejnIl8qzLAZ2iOEBCZ1p mXElMuxcDwFHFAUleMNNLdzhoB0jsQ64J+fgj3SSagN5UKsEyVMc+3zLEEF6f5BnpHFSNA cKRJKW5F0nh1xE95DxjqNzMzrROH9l0= X-MC-Unique: 39HM99g5OYS2pzogppFDcg-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jason Wang Subject: [PULL 08/14] hw/net: improve tracing of eBPF RSS setup Date: Tue, 29 Oct 2024 16:06:59 +0800 Message-ID: <20241029080705.3238-9-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189330769116600 From: Daniel P. Berrang=C3=A9 This adds more trace events to key eBPF RSS setup operations, and also distinguishes events from multiple NIC instances. Signed-off-by: Daniel P. Berrang=C3=A9 Signed-off-by: Jason Wang --- hw/net/trace-events | 8 +++++--- hw/net/virtio-net.c | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/net/trace-events b/hw/net/trace-events index 4c6687923e..91a3d0c054 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -394,9 +394,11 @@ virtio_net_announce_notify(void) "" virtio_net_announce_timer(int round) "%d" virtio_net_handle_announce(int round) "%d" virtio_net_post_load_device(void) -virtio_net_rss_disable(void) -virtio_net_rss_error(const char *msg, uint32_t value) "%s, value 0x%08x" -virtio_net_rss_enable(uint32_t p1, uint16_t p2, uint8_t p3) "hashes 0x%x, = table of %d, key of %d" +virtio_net_rss_load(void *nic, size_t nfds, void *fds) "nic=3D%p nfds=3D%z= u fds=3D%p" +virtio_net_rss_attach_ebpf(void *nic, int prog_fd) "nic=3D%p prog-fd=3D%d" +virtio_net_rss_disable(void *nic) "nic=3D%p" +virtio_net_rss_error(void *nic, const char *msg, uint32_t value) "nic=3D%p= msg=3D%s, value 0x%08x" +virtio_net_rss_enable(void *nic, uint32_t p1, uint16_t p2, uint8_t p3) "ni= c=3D%p hashes 0x%x, table of %d, key of %d" =20 # tulip.c tulip_reg_write(uint64_t addr, const char *name, int size, uint64_t val) "= addr 0x%02"PRIx64" (%s) size %d value 0x%08"PRIx64 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index c08ae55424..60e19bffcb 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1241,6 +1241,7 @@ static bool virtio_net_attach_ebpf_to_backend(NICStat= e *nic, int prog_fd) return false; } =20 + trace_virtio_net_rss_attach_ebpf(nic, prog_fd); return nc->info->set_steering_ebpf(nc, prog_fd); } =20 @@ -1297,12 +1298,13 @@ static void virtio_net_commit_rss_config(VirtIONet = *n) } } =20 - trace_virtio_net_rss_enable(n->rss_data.hash_types, + trace_virtio_net_rss_enable(n, + n->rss_data.hash_types, n->rss_data.indirections_len, sizeof(n->rss_data.key)); } else { virtio_net_detach_ebpf_rss(n); - trace_virtio_net_rss_disable(); + trace_virtio_net_rss_disable(n); } } =20 @@ -1353,6 +1355,7 @@ static bool virtio_net_load_ebpf(VirtIONet *n, Error = **errp) bool ret =3D false; =20 if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) { + trace_virtio_net_rss_load(n, n->nr_ebpf_rss_fds, n->ebpf_rss_fds); if (n->ebpf_rss_fds) { ret =3D virtio_net_load_ebpf_fds(n, errp); } else { @@ -1484,7 +1487,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, virtio_net_commit_rss_config(n); return queue_pairs; error: - trace_virtio_net_rss_error(err_msg, err_value); + trace_virtio_net_rss_error(n, err_msg, err_value); virtio_net_disable_rss(n); return 0; } --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189392; cv=none; d=zohomail.com; s=zohoarc; b=C/wnLTiVxXxtaPp+URLad6n0dQ9wlVLi5Fv1w1b5RljmXjc9oJuFHqhOUT8hhhf6OT9Sq/rToWkfeR5KMMBrSXRdiEbEPSa+d6E+6xg4BHAUx4QW7OJOLOP+ld1slmnDHEPwmEQU/NtJPeX5kslTB2UrDi6FjokuzCKQKzfhgBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189392; 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=NO7nOOKs6u7MijXEa8MD5cKLb3kFzJ7DMjc0OCON5Yc=; b=PUyf+siwWO5Yy14i5pXDay3x3Oo8BYTJZFfg44sKX9mMpDA6bD9bwyadYiK0FRXKXrVSG0y/dE7XWzhBIpFcfk9KC4un93wcn2gClOnTO1lNxHI4UkXsyVnCMZY5GXx/aMRiN0xGSYQgWQymXLSJVsi9EVkT/xn67c8v3f19k8Q= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189392667312.12824744674026; Tue, 29 Oct 2024 01:09:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hI9-0001nO-Hh; Tue, 29 Oct 2024 04:09:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hHk-0001TB-NY for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:09:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hHi-00043c-Ad for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:09:04 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-kFaoZbajP1GT-8huI6vS9Q-1; Tue, 29 Oct 2024 04:07:44 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 607CA1955F2C; Tue, 29 Oct 2024 08:07:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5D8901956086; Tue, 29 Oct 2024 08:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NO7nOOKs6u7MijXEa8MD5cKLb3kFzJ7DMjc0OCON5Yc=; b=KN6+4rewlReNTHFXV87AQbBrqU2TCiJWTVlu3sD7LFwH4YCZ/M/GgoIlhijsc1D8KvexgM wGk4huoal0I2IIE92OqYpnniqw/ZrssmKD+t2P4dX+MJTXUpri5TJC4LhuLAVlrLiLroe2 epijVXZEke+hRXAhpSd/jD0AEEv31sU= X-MC-Unique: kFaoZbajP1GT-8huI6vS9Q-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Daniil Tatianin , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Jason Wang Subject: [PULL 09/14] net/stream: deprecate 'reconnect' in favor of 'reconnect-ms' Date: Tue, 29 Oct 2024 16:07:00 +0800 Message-ID: <20241029080705.3238-10-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189393350116600 From: Daniil Tatianin Do the same thing we already did for chardev in c8e2b6b4d7e, and introduce a new 'reconnect-ms' option to make it possible to specify sub-second timeouts. This also changes the related documentaion and tests to use reconnect-ms as well. Signed-off-by: Daniil Tatianin Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Jason Wang --- docs/about/deprecated.rst | 10 ++++++++++ net/stream.c | 34 ++++++++++++++++++++++------------ qapi/net.json | 13 ++++++++++++- qemu-options.hx | 24 ++++++++++++------------ tests/qtest/netdev-socket.c | 2 +- 5 files changed, 57 insertions(+), 26 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index ce38a3d0cf..1e1e9f5f18 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -400,6 +400,16 @@ Backend ``memory`` (since 9.0) The ``reconnect`` option only allows specifiying second granularity timeou= ts, which is not enough for all types of use cases, use ``reconnect-ms`` inste= ad. =20 + +Net device options +'''''''''''''''''' + +Stream ``reconnect`` (since 9.2) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``reconnect`` option only allows specifiying second granularity timeou= ts, +which is not enough for all types of use cases, use ``reconnect-ms`` inste= ad. + CPU device properties ''''''''''''''''''''' =20 diff --git a/net/stream.c b/net/stream.c index 97e6ec6679..4de5613844 100644 --- a/net/stream.c +++ b/net/stream.c @@ -51,7 +51,7 @@ typedef struct NetStreamState { guint ioc_write_tag; SocketReadState rs; unsigned int send_index; /* number of bytes sent*/ - uint32_t reconnect; + uint32_t reconnect_ms; guint timer_tag; SocketAddress *addr; } NetStreamState; @@ -387,10 +387,9 @@ static gboolean net_stream_reconnect(gpointer data) =20 static void net_stream_arm_reconnect(NetStreamState *s) { - if (s->reconnect && s->timer_tag =3D=3D 0) { + if (s->reconnect_ms && s->timer_tag =3D=3D 0) { qemu_set_info_str(&s->nc, "connecting"); - s->timer_tag =3D g_timeout_add_seconds(s->reconnect, - net_stream_reconnect, s); + s->timer_tag =3D g_timeout_add(s->reconnect_ms, net_stream_reconne= ct, s); } } =20 @@ -398,7 +397,7 @@ static int net_stream_client_init(NetClientState *peer, const char *model, const char *name, SocketAddress *addr, - uint32_t reconnect, + uint32_t reconnect_ms, Error **errp) { NetStreamState *s; @@ -412,8 +411,8 @@ static int net_stream_client_init(NetClientState *peer, s->ioc =3D QIO_CHANNEL(sioc); s->nc.link_down =3D true; =20 - s->reconnect =3D reconnect; - if (reconnect) { + s->reconnect_ms =3D reconnect_ms; + if (reconnect_ms) { s->addr =3D QAPI_CLONE(SocketAddress, addr); } qio_channel_socket_connect_async(sioc, addr, @@ -432,13 +431,24 @@ int net_init_stream(const Netdev *netdev, const char = *name, sock =3D &netdev->u.stream; =20 if (!sock->has_server || !sock->server) { + uint32_t reconnect_ms =3D 0; + + if (sock->has_reconnect && sock->has_reconnect_ms) { + error_setg(errp, "'reconnect' and 'reconnect-ms' are mutually " + "exclusive"); + return -1; + } else if (sock->has_reconnect_ms) { + reconnect_ms =3D sock->reconnect_ms; + } else if (sock->has_reconnect) { + reconnect_ms =3D sock->reconnect * 1000u; + } + return net_stream_client_init(peer, "stream", name, sock->addr, - sock->has_reconnect ? sock->reconnec= t : 0, - errp); + reconnect_ms, errp); } - if (sock->has_reconnect) { - error_setg(errp, "'reconnect' option is incompatible with " - "socket in server mode"); + if (sock->has_reconnect || sock->has_reconnect_ms) { + error_setg(errp, "'reconnect' and 'reconnect-ms' options are " + "incompatible with socket in server mode"); return -1; } return net_stream_server_init(peer, "stream", name, sock->addr, errp); diff --git a/qapi/net.json b/qapi/net.json index 87fc0d0b28..2739a2f423 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -650,15 +650,26 @@ # attempt a reconnect after the given number of seconds. Setting # this to zero disables this function. (default: 0) (since 8.0) # +# @reconnect-ms: For a client socket, if a socket is disconnected, then +# attempt a reconnect after the given number of milliseconds. Setting +# this to zero disables this function. This member is mutually +# exclusive with @reconnect. (default: 0) (Since: 9.2) +# # Only SocketAddress types 'unix', 'inet' and 'fd' are supported. # +# Features: +# +# @deprecated: Member @reconnect is deprecated. Use @reconnect-ms +# instead. +# # Since: 7.2 ## { 'struct': 'NetdevStreamOptions', 'data': { 'addr': 'SocketAddress', '*server': 'bool', - '*reconnect': 'uint32' } } + '*reconnect': { 'type': 'int', 'features': [ 'deprecated' ] }, + '*reconnect-ms': 'int' } } =20 ## # @NetdevDgramOptions: diff --git a/qemu-options.hx b/qemu-options.hx index daae494147..bb228f6200 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2833,9 +2833,9 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, "-netdev socket,id=3Dstr[,fd=3Dh][,udp=3Dhost:port][,localaddr=3Dhost:= port]\n" " configure a network backend to connect to another net= work\n" " using an UDP tunnel\n" - "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dinet,addr.host= =3Dhost,addr.port=3Dport[,to=3Dmaxport][,numeric=3Don|off][,keep-alive=3Don= |off][,mptcp=3Don|off][,addr.ipv4=3Don|off][,addr.ipv6=3Don|off][,reconnect= =3Dseconds]\n" - "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dunix,addr.path= =3Dpath[,abstract=3Don|off][,tight=3Don|off][,reconnect=3Dseconds]\n" - "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dfd,addr.str=3Df= ile-descriptor[,reconnect=3Dseconds]\n" + "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dinet,addr.host= =3Dhost,addr.port=3Dport[,to=3Dmaxport][,numeric=3Don|off][,keep-alive=3Don= |off][,mptcp=3Don|off][,addr.ipv4=3Don|off][,addr.ipv6=3Don|off][,reconnect= -ms=3Dmilliseconds]\n" + "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dunix,addr.path= =3Dpath[,abstract=3Don|off][,tight=3Don|off][,reconnect-ms=3Dmilliseconds]\= n" + "-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dfd,addr.str=3Df= ile-descriptor[,reconnect-ms=3Dmilliseconds]\n" " configure a network backend to connect to another net= work\n" " using a socket connection in stream mode.\n" "-netdev dgram,id=3Dstr,remote.type=3Dinet,remote.host=3Dmaddr,remote.= port=3Dport[,local.type=3Dinet,local.host=3Daddr]\n" @@ -3291,7 +3291,7 @@ SRST -device e1000,netdev=3Dn1,mac=3D52:54:00:12:34:56= \\ -netdev socket,id=3Dn1,mcast=3D239.192.168.1:1102= ,localaddr=3D1.2.3.4 =20 -``-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dinet,addr.host=3Dh= ost,addr.port=3Dport[,to=3Dmaxport][,numeric=3Don|off][,keep-alive=3Don|off= ][,mptcp=3Don|off][,addr.ipv4=3Don|off][,addr.ipv6=3Don|off][,reconnect=3Ds= econds]`` +``-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dinet,addr.host=3Dh= ost,addr.port=3Dport[,to=3Dmaxport][,numeric=3Don|off][,keep-alive=3Don|off= ][,mptcp=3Don|off][,addr.ipv4=3Don|off][,addr.ipv6=3Don|off][,reconnect-ms= =3Dmilliseconds]`` Configure a network backend to connect to another QEMU virtual machine= or a proxy using a TCP/IP socket. =20 ``server=3Don|off`` @@ -3333,9 +3333,9 @@ SRST # second VM |qemu_system| linux.img \\ -device virtio-net,netdev=3Dnet0,mac=3D52:54:00:12:3= 4:57 \\ - -netdev stream,id=3Dnet0,server=3Doff,addr.type=3Din= et,addr.host=3Dlocalhost,addr.port=3D1234,reconnect=3D5 + -netdev stream,id=3Dnet0,server=3Doff,addr.type=3Din= et,addr.host=3Dlocalhost,addr.port=3D1234,reconnect-ms=3D5000 =20 -``-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dunix,addr.path=3Dp= ath[,abstract=3Don|off][,tight=3Don|off][,reconnect=3Dseconds]`` +``-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dunix,addr.path=3Dp= ath[,abstract=3Don|off][,tight=3Don|off][,reconnect-ms=3Dmilliseconds]`` Configure a network backend to connect to another QEMU virtual machine= or a proxy using a stream oriented unix domain socket. =20 ``server=3Don|off`` @@ -3350,8 +3350,8 @@ SRST ``tight=3Don|off`` if false, pad an abstract socket address with enough null bytes to= make it fill struct sockaddr_un member sun_path. =20 - ``reconnect=3Dseconds`` - for a client socket, if a socket is disconnected, then attempt a r= econnect after the given number of seconds. + ``reconnect-ms=3Dmilliseconds`` + for a client socket, if a socket is disconnected, then attempt a r= econnect after the given number of milliseconds. Setting this to zero disables this function. (default: 0) =20 Example (using passt as a replacement of -netdev user): @@ -3377,9 +3377,9 @@ SRST # second VM |qemu_system| linux.img \\ -device virtio-net,netdev=3Dnet0,mac=3D52:54:00:12:3= 4:57 \\ - -netdev stream,id=3Dnet0,server=3Doff,addr.type=3Dun= ix,addr.path=3D/tmp/qemu0,reconnect=3D5 + -netdev stream,id=3Dnet0,server=3Doff,addr.type=3Dun= ix,addr.path=3D/tmp/qemu0,reconnect-ms=3D5000 =20 -``-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dfd,addr.str=3Dfile= -descriptor[,reconnect=3Dseconds]`` +``-netdev stream,id=3Dstr[,server=3Don|off],addr.type=3Dfd,addr.str=3Dfile= -descriptor[,reconnect-ms=3Dmilliseconds]`` Configure a network backend to connect to another QEMU virtual machine= or a proxy using a stream oriented socket file descriptor. =20 ``server=3Don|off`` @@ -4390,14 +4390,14 @@ SRST ``telnet options:`` localhost 5555 =20 - ``tcp:[host]:port[,server=3Don|off][,wait=3Don|off][,nodelay=3Don|off]= [,reconnect=3Dseconds]`` + ``tcp:[host]:port[,server=3Don|off][,wait=3Don|off][,nodelay=3Don|off]= [,reconnect-ms=3Dmilliseconds]`` The TCP Net Console has two modes of operation. It can send the serial I/O to a location or wait for a connection from a location. By default the TCP Net Console is sent to host at the port. If you use the ``server=3Don`` option QEMU will wait for a c= lient socket application to connect to the port before continuing, unless the ``wait=3Don|off`` option was specified. The ``nodelay= =3Don|off`` - option disables the Nagle buffering algorithm. The ``reconnect=3Do= n`` + option disables the Nagle buffering algorithm. The ``reconnect-ms`` option only applies if ``server=3Dno`` is set, if the connection g= oes down it will attempt to reconnect at the given interval. If host is omitted, 0.0.0.0 is assumed. Only one TCP connection at a diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c index fc7d11961e..317af03817 100644 --- a/tests/qtest/netdev-socket.c +++ b/tests/qtest/netdev-socket.c @@ -204,7 +204,7 @@ static void test_stream_unix_reconnect(void) =20 qts1 =3D qtest_initf("-nodefaults -M none " "-netdev stream,server=3Dfalse,id=3Dst0,addr.type= =3Dunix," - "addr.path=3D%s,reconnect=3D1", path); + "addr.path=3D%s,reconnect-ms=3D1000", path); =20 wait_stream_connected(qts0, "st0", &addr); g_assert_cmpint(addr->type, =3D=3D, SOCKET_ADDRESS_TYPE_UNIX); --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189310; cv=none; d=zohomail.com; s=zohoarc; b=RqmH1f8VlID79thW7qpt07A3pcWgcIKFie7jK3z1aKnVfi/2GvXTvIJCnGsQa7OiL2ogDQQoyHVSv/I41caWFlAIINqWKxvyGtQrWEM7VEONhz17yGzYaK3pj9fJI7CoKRDC6jIpUQmxzk62r29vEKEnOKGWzN4UDXW9eASjYpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189310; 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=83qmr+KeO4ilJ6A4acIZ0fhA1JeMw3DwdEi4oQ6Mnqo=; b=Gs4eoFvxLWYVgUNvAJHpBqj6q1akdmj9uuqdcRoX35xJ5JZAa1gMI8FaRbUWzq1D9WJ4qcPDnytJgxkED1veygPXjAFGKf+/mt8tKxyCzlCsIj83SJK+kAmzU1AIVk57vzAOL1NczFGtuIyJTy5FV8grBUtX2U5xIDlPIYpbNsY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189310716730.3211483441509; Tue, 29 Oct 2024 01:08:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGg-0007Lp-VT; Tue, 29 Oct 2024 04:07:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGf-0007LE-Ls for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGd-0003z1-SH for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:07:57 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-443-5whvoLufPqWcHEXLQ03uRA-1; Tue, 29 Oct 2024 04:07:48 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47F491955DBF; Tue, 29 Oct 2024 08:07:47 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F0CC1956086; Tue, 29 Oct 2024 08:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=83qmr+KeO4ilJ6A4acIZ0fhA1JeMw3DwdEi4oQ6Mnqo=; b=YbHxeia+5zZSqC21Qx30ij+k5STt+S//YS4C0xHeSPP+UdLXawQFbVT9z1bbSr6swxp07y xG1q1hKTYxlt2ARAdHYA1xwllj5D72kDIWS0SG68c8Xrmy/Mk/LMfutRXgFuMrLmeLeLrF 8vGxYGzWvi36M3RRrydwnQr3oDew6QM= X-MC-Unique: 5whvoLufPqWcHEXLQ03uRA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Daniil Tatianin , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Jason Wang Subject: [PULL 10/14] chardev: finalize 'reconnect' deprecation Date: Tue, 29 Oct 2024 16:07:01 +0800 Message-ID: <20241029080705.3238-11-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189313104116600 From: Daniil Tatianin Change all related docs and tests to use the new 'reconnect-ms' option instead of the now deprecated 'reconnect'. Signed-off-by: Daniil Tatianin Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Jason Wang --- docs/COLO-FT.txt | 4 ++-- docs/system/ppc/powernv.rst | 2 +- qemu-options.hx | 22 +++++++++++----------- tests/qtest/ipmi-bt-test.c | 2 +- tests/qtest/vhost-user-test.c | 2 +- tests/unit/test-char.c | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/COLO-FT.txt b/docs/COLO-FT.txt index 2e760a4aee..2283a09c08 100644 --- a/docs/COLO-FT.txt +++ b/docs/COLO-FT.txt @@ -193,8 +193,8 @@ any IP's here, except for the $primary_ip variable. -device piix3-usb-uhci -device usb-tablet -name secondary \ -netdev tap,id=3Dhn0,vhost=3Doff,helper=3D/usr/lib/qemu/qemu-bridge-hel= per \ -device rtl8139,id=3De0,netdev=3Dhn0 \ - -chardev socket,id=3Dred0,host=3D$primary_ip,port=3D9003,reconnect=3D1 \ - -chardev socket,id=3Dred1,host=3D$primary_ip,port=3D9004,reconnect=3D1 \ + -chardev socket,id=3Dred0,host=3D$primary_ip,port=3D9003,reconnect-ms= =3D1000 \ + -chardev socket,id=3Dred1,host=3D$primary_ip,port=3D9004,reconnect-ms= =3D1000 \ -object filter-redirector,id=3Df1,netdev=3Dhn0,queue=3Dtx,indev=3Dred0 \ -object filter-redirector,id=3Df2,netdev=3Dhn0,queue=3Drx,outdev=3Dred1= \ -object filter-rewriter,id=3Drew0,netdev=3Dhn0,queue=3Dall \ diff --git a/docs/system/ppc/powernv.rst b/docs/system/ppc/powernv.rst index 09f3965858..de7a807ac7 100644 --- a/docs/system/ppc/powernv.rst +++ b/docs/system/ppc/powernv.rst @@ -181,7 +181,7 @@ connected to a remote QEMU machine acting as BMC, using= these options =20 .. code-block:: bash =20 - -chardev socket,id=3Dipmi0,host=3Dlocalhost,port=3D9002,reconnect=3D10 \ + -chardev socket,id=3Dipmi0,host=3Dlocalhost,port=3D9002,reconnect-ms=3D1= 0000 \ -device ipmi-bmc-extern,id=3Dbmc0,chardev=3Dipmi0 \ -device isa-ipmi-bt,bmc=3Dbmc0,irq=3D10 \ -nodefaults diff --git a/qemu-options.hx b/qemu-options.hx index bb228f6200..dacc9790a4 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1102,7 +1102,7 @@ SRST external entity that provides the IPMI services. =20 A connection is made to an external BMC simulator. If you do this, - it is strongly recommended that you use the "reconnect=3D" chardev + it is strongly recommended that you use the "reconnect-ms=3D" chardev option to reconnect to the simulator if the connection is lost. Note that if this is not used carefully, it can be a security issue, as the interface has the ability to send resets, NMIs, and power off @@ -3318,8 +3318,8 @@ SRST ``ipv6=3Don|off`` whether to accept IPv6 addresses, default to try both IPv4 and IPv6 =20 - ``reconnect=3Dseconds`` - for a client socket, if a socket is disconnected, then attempt a r= econnect after the given number of seconds. + ``reconnect-ms=3Dmilliseconds`` + for a client socket, if a socket is disconnected, then attempt a r= econnect after the given number of milliseconds. Setting this to zero disables this function. (default: 0) =20 Example (two guests connected using a TCP/IP socket): @@ -3388,8 +3388,8 @@ SRST ``addr.str=3Dfile-descriptor`` file descriptor number to use as a socket =20 - ``reconnect=3Dseconds`` - for a client socket, if a socket is disconnected, then attempt a r= econnect after the given number of seconds. + ``reconnect-ms=3Dmilliseconds`` + for a client socket, if a socket is disconnected, then attempt a r= econnect after the given number of milliseconds. Setting this to zero disables this function. (default: 0) =20 ``-netdev dgram,id=3Dstr,remote.type=3Dinet,remote.host=3Dmaddr,remote.por= t=3Dport[,local.type=3Dinet,local.host=3Daddr]`` @@ -3679,9 +3679,9 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, "-chardev help\n" "-chardev null,id=3Did[,mux=3Don|off][,logfile=3DPATH][,logappend=3Don= |off]\n" "-chardev socket,id=3Did[,host=3Dhost],port=3Dport[,to=3Dto][,ipv4=3Do= n|off][,ipv6=3Don|off][,nodelay=3Don|off]\n" - " [,server=3Don|off][,wait=3Don|off][,telnet=3Don|off][,websoc= ket=3Don|off][,reconnect=3Dseconds][,mux=3Don|off]\n" + " [,server=3Don|off][,wait=3Don|off][,telnet=3Don|off][,websoc= ket=3Don|off][,reconnect-ms=3Dmilliseconds][,mux=3Don|off]\n" " [,logfile=3DPATH][,logappend=3Don|off][,tls-creds=3DID][,tls= -authz=3DID] (tcp)\n" - "-chardev socket,id=3Did,path=3Dpath[,server=3Don|off][,wait=3Don|off]= [,telnet=3Don|off][,websocket=3Don|off][,reconnect=3Dseconds]\n" + "-chardev socket,id=3Did,path=3Dpath[,server=3Don|off][,wait=3Don|off]= [,telnet=3Don|off][,websocket=3Don|off][,reconnect-ms=3Dmilliseconds]\n" " [,mux=3Don|off][,logfile=3DPATH][,logappend=3Don|off][,abstr= act=3Don|off][,tight=3Don|off] (unix)\n" "-chardev udp,id=3Did[,host=3Dhost],port=3Dport[,localaddr=3Dlocaladdr= ]\n" " [,localport=3Dlocalport][,ipv4=3Don|off][,ipv6=3Don|off][,mu= x=3Don|off]\n" @@ -3792,7 +3792,7 @@ The available backends are: A void device. This device will not emit any data, and will drop any data it receives. The null backend does not take any options. =20 -``-chardev socket,id=3Did[,TCP options or unix options][,server=3Don|off][= ,wait=3Don|off][,telnet=3Don|off][,websocket=3Don|off][,reconnect=3Dseconds= ][,tls-creds=3Did][,tls-authz=3Did]`` +``-chardev socket,id=3Did[,TCP options or unix options][,server=3Don|off][= ,wait=3Don|off][,telnet=3Don|off][,websocket=3Don|off][,reconnect-ms=3Dmill= iseconds][,tls-creds=3Did][,tls-authz=3Did]`` Create a two-way stream socket, which can be either a TCP or a unix socket. A unix socket will be created if ``path`` is specified. Behaviour is undefined if TCP options are specified for a unix @@ -3809,9 +3809,9 @@ The available backends are: ``websocket=3Don|off`` specifies that the socket uses WebSocket protoc= ol for communication. =20 - ``reconnect`` sets the timeout for reconnecting on non-server + ``reconnect-ms`` sets the timeout for reconnecting on non-server sockets when the remote end goes away. qemu will delay this many - seconds and then attempt to reconnect. Zero disables reconnecting, + milliseconds and then attempt to reconnect. Zero disables reconnecting, and is the default. =20 ``tls-creds`` requests enablement of the TLS protocol for @@ -4427,7 +4427,7 @@ SRST The WebSocket protocol is used instead of raw tcp socket. The port acts as a WebSocket server. Client mode is not supported. =20 - ``unix:path[,server=3Don|off][,wait=3Don|off][,reconnect=3Dseconds]`` + ``unix:path[,server=3Don|off][,wait=3Don|off][,reconnect-ms=3Dmillisec= onds]`` A unix domain socket is used instead of a tcp socket. The option works the same as if you had specified ``-serial tcp`` except the unix domain socket path is used for connections. diff --git a/tests/qtest/ipmi-bt-test.c b/tests/qtest/ipmi-bt-test.c index 13f7c841f5..637732fd5a 100644 --- a/tests/qtest/ipmi-bt-test.c +++ b/tests/qtest/ipmi-bt-test.c @@ -411,7 +411,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 global_qtest =3D qtest_initf( - " -chardev socket,id=3Dipmi0,host=3D127.0.0.1,port=3D%d,reconnect= =3D10" + " -chardev socket,id=3Dipmi0,host=3D127.0.0.1,port=3D%d,reconnect-= ms=3D10000" " -device ipmi-bmc-extern,chardev=3Dipmi0,id=3Dbmc0" " -device isa-ipmi-bt,bmc=3Dbmc0", emu_port); qtest_irq_intercept_in(global_qtest, "ioapic"); diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d6075001e7..8948fb81ef 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -920,7 +920,7 @@ static void wait_for_rings_started(TestServer *s, size_= t count) =20 static inline void test_server_connect(TestServer *server) { - test_server_create_chr(server, ",reconnect=3D1"); + test_server_create_chr(server, ",reconnect-ms=3D1000"); } =20 static gboolean diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c index a1c6bb874c..a6e8753e1c 100644 --- a/tests/unit/test-char.c +++ b/tests/unit/test-char.c @@ -1545,18 +1545,18 @@ int main(int argc, char **argv) static CharSocketClientTestConfig client2 ## name =3D \ { addr, NULL, true, false, char_socket_event }; \ static CharSocketClientTestConfig client3 ## name =3D \ - { addr, ",reconnect=3D1", false, false, char_socket_event }; \ + { addr, ",reconnect-ms=3D1000", false, false, char_socket_event };= \ static CharSocketClientTestConfig client4 ## name =3D \ - { addr, ",reconnect=3D1", true, false, char_socket_event }; \ + { addr, ",reconnect-ms=3D1000", true, false, char_socket_event }; \ static CharSocketClientTestConfig client5 ## name =3D \ { addr, NULL, false, true, char_socket_event }; \ static CharSocketClientTestConfig client6 ## name =3D \ { addr, NULL, true, true, char_socket_event }; \ static CharSocketClientTestConfig client7 ## name =3D \ - { addr, ",reconnect=3D1", true, false, \ + { addr, ",reconnect-ms=3D1000", true, false, \ char_socket_event_with_error }; \ static CharSocketClientTestConfig client8 ## name =3D \ - { addr, ",reconnect=3D1", false, false, char_socket_event }; \ + { addr, ",reconnect-ms=3D1000", false, false, char_socket_event };\ g_test_add_data_func("/char/socket/client/mainloop/" # name, \ &client1 ##name, char_socket_client_test); \ g_test_add_data_func("/char/socket/client/wait-conn/" # name, \ --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189310; cv=none; d=zohomail.com; s=zohoarc; b=e7cBAGrkeqO0DTPi3ai2olV2eaBEreL3amlO2up/TVBSq8tEmRQu2TBTgjYlG/bW0MXr9+fRusNOUKEPclfHEVoPuTMdGGO8AdQ5qkr+YPppNv+/JI+tshiaBmB7wqnHrJISjtLxgQZzdBWKycj4b4uVfvzZ0iwHmbCvb957rHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189310; 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=pmBl+PlUk+WLhosQ/iw737LCHOPlPsBsjyy9DE6lu7Q=; b=SCey6WK11RXEP8LNPDczLiVMMrSb5vdUOwZ1TNPmc2mB6ojeo9NyeOZ7irGT+AxRv3KMpTUl2tqOnvdiTXMe1+szhPG3rJCpQvOQhJRIJJ7fE8OdCqWiEL9+ctPLSoA7MMOmWezFLpCDj0OXKE4Jig3TTymhGKQawlc5tv/D7bE= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189310295234.41983366445027; Tue, 29 Oct 2024 01:08:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGl-0007Na-Ni; Tue, 29 Oct 2024 04:08:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGj-0007MV-GS for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGh-0003zt-Eb for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:01 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-482-u2WQqTEVMlCFJlzrGtm9lA-1; Tue, 29 Oct 2024 04:07:55 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1FC4019560AF; Tue, 29 Oct 2024 08:07:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2E0411956086; Tue, 29 Oct 2024 08:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pmBl+PlUk+WLhosQ/iw737LCHOPlPsBsjyy9DE6lu7Q=; b=gM0bnBqtf2+pls+i4pt47s9T3uZYjxrqhA7oihFiQtGsQV6Gyy/NCG2fefsBiubSFi34DP j47zNxGfTtIyhwbUZZDFaV5XUc/KoAjirkWPqn6XQJSvh7G0bUZdDvhvY8/BtppklRg/a5 Bq03/Sq+2ZGXpQe6AgUxtSqOw5ilcNU= X-MC-Unique: u2WQqTEVMlCFJlzrGtm9lA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Bernhard Beschow , qemu-stable@nongnu.org, Michael Tokarev , Pierrick Bouvier , Jason Wang Subject: [PULL 11/14] net/tap-win32: Fix gcc 14 format truncation errors Date: Tue, 29 Oct 2024 16:07:02 +0800 Message-ID: <20241029080705.3238-12-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 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 @redhat.com) X-ZM-MESSAGEID: 1730189310956116600 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow The patch fixes the following errors generated by GCC 14.2: ../src/net/tap-win32.c:343:19: error: '%s' directive output may be truncate= d writing up to 255 bytes into a region of size 176 [-Werror=3Dformat-trunc= ation=3D] 343 | "%s\\%s\\Connection", | ^~ 344 | NETWORK_CONNECTIONS_KEY, enum_name); | ~~~~~~~~~ ../src/net/tap-win32.c:341:9: note: 'snprintf' output between 92 and 347 by= tes into a destination of size 256 341 | snprintf(connection_string, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 342 | sizeof(connection_string), | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 343 | "%s\\%s\\Connection", | ~~~~~~~~~~~~~~~~~~~~~ 344 | NETWORK_CONNECTIONS_KEY, enum_name); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/net/tap-win32.c:242:58: error: '%s' directive output may be truncate= d writing up to 255 bytes into a region of size 178 [-Werror=3Dformat-trunc= ation=3D] 242 | snprintf (unit_string, sizeof(unit_string), "%s\\%s", | ^~ 243 | ADAPTER_KEY, enum_name); | ~~~~~~~~~ ../src/net/tap-win32.c:242:9: note: 'snprintf' output between 79 and 334 by= tes into a destination of size 256 242 | snprintf (unit_string, sizeof(unit_string), "%s\\%s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 243 | ADAPTER_KEY, enum_name); | ~~~~~~~~~~~~~~~~~~~~~~~ ../src/net/tap-win32.c:620:52: error: '%s' directive output may be truncate= d writing up to 255 bytes into a region of size 245 [-Werror=3Dformat-trunc= ation=3D] 620 | snprintf (device_path, sizeof(device_path), "%s%s%s", | ^~ 621 | USERMODEDEVICEDIR, 622 | device_guid, | ~~~~~~~~~~~ ../src/net/tap-win32.c:620:5: note: 'snprintf' output between 16 and 271 by= tes into a destination of size 256 620 | snprintf (device_path, sizeof(device_path), "%s%s%s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 621 | USERMODEDEVICEDIR, | ~~~~~~~~~~~~~~~~~~ 622 | device_guid, | ~~~~~~~~~~~~ 623 | TAPSUFFIX); | ~~~~~~~~~~ Signed-off-by: Bernhard Beschow Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2607 Cc: qemu-stable@nongnu.org Reviewed-by: Michael Tokarev Reviewed-by: Pierrick Bouvier Signed-off-by: Jason Wang --- net/tap-win32.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/tap-win32.c b/net/tap-win32.c index 7edbd71633..671dee970f 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -214,7 +214,7 @@ static int is_tap_win32_dev(const char *guid) =20 for (;;) { char enum_name[256]; - char unit_string[256]; + g_autofree char *unit_string =3D NULL; HKEY unit_key; char component_id_string[] =3D "ComponentId"; char component_id[256]; @@ -239,8 +239,7 @@ static int is_tap_win32_dev(const char *guid) return FALSE; } =20 - snprintf (unit_string, sizeof(unit_string), "%s\\%s", - ADAPTER_KEY, enum_name); + unit_string =3D g_strdup_printf("%s\\%s", ADAPTER_KEY, enum_name); =20 status =3D RegOpenKeyEx( HKEY_LOCAL_MACHINE, @@ -315,7 +314,7 @@ static int get_device_guid( while (!stop) { char enum_name[256]; - char connection_string[256]; + g_autofree char *connection_string =3D NULL; HKEY connection_key; char name_data[256]; DWORD name_type; @@ -338,9 +337,7 @@ static int get_device_guid( return -1; } =20 - snprintf(connection_string, - sizeof(connection_string), - "%s\\%s\\Connection", + connection_string =3D g_strdup_printf("%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, enum_name); =20 status =3D RegOpenKeyEx( @@ -595,7 +592,7 @@ static void tap_win32_free_buffer(tap_win32_overlapped_= t *overlapped, static int tap_win32_open(tap_win32_overlapped_t **phandle, const char *preferred_name) { - char device_path[256]; + g_autofree char *device_path =3D NULL; char device_guid[0x100]; int rc; HANDLE handle; @@ -617,7 +614,7 @@ static int tap_win32_open(tap_win32_overlapped_t **phan= dle, if (rc) return -1; =20 - snprintf (device_path, sizeof(device_path), "%s%s%s", + device_path =3D g_strdup_printf("%s%s%s", USERMODEDEVICEDIR, device_guid, TAPSUFFIX); --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189488; cv=none; d=zohomail.com; s=zohoarc; b=DKDV01ulaua1yHZ+P1TOhQozBJyHBXkVNiXw4Ju6nsCS4JiOZNQYahplNMvdsHI8nxD9ErThuLZL8ZzUIqSUSeJqvNQRbqXmLJu5tFTC/AABDpNmDR7Mjo30FITrwi9sRyvVISXCY5aTCbrkpjP7+DQkn1K8C3IbIa9C6+AQ6to= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189488; 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=fAvv9XNNJhFe4zC4W2nXz+46R6JXObO+qkbJ7dmgx8M=; b=Ka0++lhH/4I299w+mjqDSyxyn7FIyNPwPDqoEZ8iqSZQ2EOJT0Y08qfYUBLiIiazNzB+K6gYHge3SzpEN0TTpJGFktshBmdVBHtUSr0PhMCARmhjpYNeA+0R53G6aBzF1awaQPps8hXrmY9INMtBOUBjBhGT/M2RGmabEaQE15M= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189488019234.18631854554712; Tue, 29 Oct 2024 01:11:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGm-0007Nb-2n; Tue, 29 Oct 2024 04:08:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGl-0007N8-8Q for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGj-000406-Rt for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:03 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471-EDljVR1_Pi6LClXQS764pQ-1; Tue, 29 Oct 2024 04:07:59 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2E40F1955F69; Tue, 29 Oct 2024 08:07:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1CE2F1956088; Tue, 29 Oct 2024 08:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fAvv9XNNJhFe4zC4W2nXz+46R6JXObO+qkbJ7dmgx8M=; b=gi+eIApsDh5c7I/7dhgD2OMyO0Z3agJGDesFFJP4nkhdVb0jRHetlkkwRTELVAeYnzg+pJ m6tE0LVjjfjQVX4cFWxF8wTRteWTxXbWoCyj9QHhsl42b/XxPqQgois+/zC7iUr2QdDAH+ KZUjzhbozJMUvL4iD/eECplHqOwvnEw= X-MC-Unique: EDljVR1_Pi6LClXQS764pQ-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Akihiko Odaki , qemu-stable@nongnu.org, Jonathan Cameron , "Michael S . Tsirkin" , Jason Wang Subject: [PULL 12/14] net: Check if nc is NULL in qemu_get_vnet_hdr_len() Date: Tue, 29 Oct 2024 16:07:03 +0800 Message-ID: <20241029080705.3238-13-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189489437116600 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki A netdev may not have a peer specified, resulting in NULL. We should make it behave like /dev/null in such a case instead of letting it cause segmentatin fault. Fixes: 4b52d63249a5 ("tap: Remove qemu_using_vnet_hdr()") Cc: qemu-stable@nongnu.org Reported-by: Jonathan Cameron Signed-off-by: Akihiko Odaki Tested-by; Jonathan Cameron Acked-by: Michael S. Tsirkin Signed-off-by: Jason Wang Tested-by; Jonathan Cameron --- net/net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/net.c b/net/net.c index d9b23a8f8c..7ef6885876 100644 --- a/net/net.c +++ b/net/net.c @@ -542,6 +542,10 @@ void qemu_set_offload(NetClientState *nc, int csum, in= t tso4, int tso6, =20 int qemu_get_vnet_hdr_len(NetClientState *nc) { + if (!nc) { + return 0; + } + return nc->vnet_hdr_len; } =20 --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189430; cv=none; d=zohomail.com; s=zohoarc; b=DaVqD3DXnatmj3+PxePG4qEr5IkXN3qn2c2atYHpvK9S4JmUUTBZD8B42ABnGUMjRyzkmJ88HRM1yko13ZdzGXnPwS77nD+PsZ/MknGS8cEvYcUtmdso19aJltia26twAm404ggQax5vkaDsV3Q3tI4nY2QklTkvgtMTH3qk6Lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189430; 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=ZBBmtqtTKH4d7OHrzObTmIJ4MV6c5JVpaNlUUe+FMpA=; b=DCppg+t5XlZDT0THJW+J7mhC5ypbhfrD88BSZfXGGDlhlptTRDkNx0fTU9ZpXr0W4BoRj5wul9b0j8LDvIltdelrlC5A36E3u7goXH4al1iJvlen8DhUbQp1A/FwJ3DHTXV411SC2RP2DFjtLK/Kz2yvNXXVXqmGY/tt3d+5/v4= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189430330313.4648946656929; Tue, 29 Oct 2024 01:10:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGx-00089T-4R; Tue, 29 Oct 2024 04:08:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGv-000822-IX for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGu-00040l-1S for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:13 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-o3rpijPDNCiA_F5eTujXrw-1; Tue, 29 Oct 2024 04:08:03 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 90B6E1955F69; Tue, 29 Oct 2024 08:08:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 209F21956086; Tue, 29 Oct 2024 08:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZBBmtqtTKH4d7OHrzObTmIJ4MV6c5JVpaNlUUe+FMpA=; b=FXF7zWoUQidPOXMlHBFJfxzYcteNATlTCa0QWQenk9aAyLTkAS0jueNg162hvh1OYivTNq fuJEMgATEIE+Xl9gudWzGIlkwUAMsY5fHpVXWrF5alMh/qi+FHva7blIHVAmXcHyQS+eZt tZkcx2oTH51s580TFmHhaQW3qLJZGs4= X-MC-Unique: o3rpijPDNCiA_F5eTujXrw-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Stefan Weil , qemu-stable@nongnu.org, Zhang Chen , Jason Wang Subject: [PULL 13/14] Fix calculation of minimum in colo_compare_tcp Date: Tue, 29 Oct 2024 16:07:04 +0800 Message-ID: <20241029080705.3238-14-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189431369116600 Content-Type: text/plain; charset="utf-8" From: Stefan Weil GitHub's CodeQL reports a critical error which is fixed by using the MIN ma= cro: Unsigned difference expression compared to zero Signed-off-by: Stefan Weil Cc: qemu-stable@nongnu.org Reviewed-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index c4ad0ab71f..39f90c4065 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -412,8 +412,7 @@ static void colo_compare_tcp(CompareState *s, Connectio= n *conn) * can ensure that the packet's payload is acknowledged by * primary and secondary. */ - uint32_t min_ack =3D conn->pack - conn->sack > 0 ? - conn->sack : conn->pack; + uint32_t min_ack =3D MIN(conn->pack, conn->sack); =20 pri: if (g_queue_is_empty(&conn->primary_list)) { --=20 2.42.0 From nobody Sat Nov 23 17:56:29 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730189392; cv=none; d=zohomail.com; s=zohoarc; b=mU1ilvzpFie6U6VCwcsvgfRRXa0rMSzQjQMCBE8HsrMXI5iPfggv8dgmEns3rAIfshgmJcBSvVP8h6gnLyYRG39DdBaiZrA5pLfA0+erNVRbC84d7ITPyl7x279BSci3t3io012qjerkp3EOtit9npWjxB9kNGbVLiFhPhnIU1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730189392; 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=Cg9TwerykTSJbPE6c3qr1RPsNckTMzBJY7S+3A7WOzM=; b=LHU9hMs6kRzAYdXFjLJHc2f0E4aAXz8N+fAnu7po99XCUxZ7Fpa6uVHJrX+67EDx4iL/qNRy0QcRpM9ILDni8pAHmkwDsyH/4jddXAeelVjtuUfm/Mn2eD0YYCM6Cc1OjhwSrDYWdZTq3r2/HKqZbcDqR1pGIF+fMDUf/J09QMg= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730189392985392.5160829290453; Tue, 29 Oct 2024 01:09:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5hGz-0008FG-Di; Tue, 29 Oct 2024 04:08:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGw-000898-Nq for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5hGu-00040w-JV for qemu-devel@nongnu.org; Tue, 29 Oct 2024 04:08:14 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-xsIMiUBzP5ONoQjT7yiPJw-1; Tue, 29 Oct 2024 04:08:06 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B8B1E19560BE; Tue, 29 Oct 2024 08:08:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.72.112.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6A7791956086; Tue, 29 Oct 2024 08:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730189292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cg9TwerykTSJbPE6c3qr1RPsNckTMzBJY7S+3A7WOzM=; b=i1C4nwbN4EAyedUThZUpA/lfVR2IVM7E1X2QqCupM0JfXiLdkqksE7SHom/ykOvKlAyMnC zaz+6nizLYinkBWKO+zcpnDJcJT10YT/DxLeTF95dfsScfoFN/2BFwizRd/sqjnkx3XH7I P+BHvouy8Afs+5nSl+qo1tFaHGcqvLM= X-MC-Unique: xsIMiUBzP5ONoQjT7yiPJw-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Jason Wang Subject: [PULL 14/14] virtio-net: Avoid indirection_table_mask overflow Date: Tue, 29 Oct 2024 16:07:05 +0800 Message-ID: <20241029080705.3238-15-jasowang@redhat.com> In-Reply-To: <20241029080705.3238-1-jasowang@redhat.com> References: <20241029080705.3238-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730189395074116600 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki We computes indirections_len by adding 1 to indirection_table_mask, but it may overflow indirection_table_mask is UINT16_MAX. Check if indirection_table_mask is small enough before adding 1. Fixes: 590790297c0d ("virtio-net: implement RSS configuration command") Signed-off-by: Akihiko Odaki Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 60e19bffcb..f2104ed364 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1406,17 +1406,17 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, n->rss_data.hash_types =3D virtio_ldl_p(vdev, &cfg.hash_types); n->rss_data.indirections_len =3D virtio_lduw_p(vdev, &cfg.indirection_table_mask); - n->rss_data.indirections_len++; if (!do_rss) { - n->rss_data.indirections_len =3D 1; + n->rss_data.indirections_len =3D 0; } - if (!is_power_of_2(n->rss_data.indirections_len)) { - err_msg =3D "Invalid size of indirection table"; + if (n->rss_data.indirections_len >=3D VIRTIO_NET_RSS_MAX_TABLE_LEN) { + err_msg =3D "Too large indirection table"; err_value =3D n->rss_data.indirections_len; goto error; } - if (n->rss_data.indirections_len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { - err_msg =3D "Too large indirection table"; + n->rss_data.indirections_len++; + if (!is_power_of_2(n->rss_data.indirections_len)) { + err_msg =3D "Invalid size of indirection table"; err_value =3D n->rss_data.indirections_len; goto error; } --=20 2.42.0