From nobody Fri Mar 27 05:09:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1771446602; cv=none; d=zohomail.com; s=zohoarc; b=dtYcrBJkDXeEpTin2u3xqd9NJrrHv3BHdyZ8NTZXAzeke+37LnePFzZtngyH6n9do9+H/Vh5kuapDhPencD78YOUaFZnXTH6Z7alYjd90L9IClwyupyjeQLTT6rZ2pbtmaz2G/cfj2bDJFFrBZJn4yotdFYg0lh5HKh+JSn4rZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771446602; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QLIq9qTK9Px46zQ/r9TYIEuLmijBWLAAX7/DLfF+Jdw=; b=faA3mjw6C9E6rf/OHjijc6FETSel/6cHAHFQFpdLtEo5XeTt+fWdvCEd0ppeDiktwVibtvQdjzoBUVuWHbZDw5/61QGKEgGlOR2ig3M0VkgCxUOuVtL3corKJfk4y2WAlJfUOGHucqGAp3TIKbszvIKB4PzYZHncJ4afmAFA/0U= 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 1771446602973794.753796231955; Wed, 18 Feb 2026 12:30:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsoAV-0007HH-Jm; Wed, 18 Feb 2026 15:29:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsoA3-00074X-Ui for qemu-devel@nongnu.org; Wed, 18 Feb 2026 15:28:40 -0500 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsoA0-0007rg-KK for qemu-devel@nongnu.org; Wed, 18 Feb 2026 15:28:38 -0500 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 9D28CC038A; Wed, 18 Feb 2026 23:28:33 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:53d::1:1b]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id VShB144A8iE0-fCZ88J6v; Wed, 18 Feb 2026 23:28:33 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1771446513; bh=QLIq9qTK9Px46zQ/r9TYIEuLmijBWLAAX7/DLfF+Jdw=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=GRkQdGs82gbuWUzk+LWaoqTP/Kx7DlRkW9AyS6Y+jjEO3E4JjxhQZNGD0PVNnOKes 7+eDEdzKQ25UOaac88AcEl0dN5wRcbAdyZ3iW/2N72dVraJUAOpkKbirTRbkcbabqF 3gR9qCy0TbQoPwJHHl0cxAVAc+X1zRWCpMlYbFvo= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, bchaney@akamai.com, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, davydov-max@yandex-team.ru, vsementsov@yandex-team.ru, Ilya Maximets Subject: [PATCH v3 01/12] net/af-xdp: fix type overflow Date: Wed, 18 Feb 2026 23:28:17 +0300 Message-ID: <20260218202829.1322088-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260218202829.1322088-1-vsementsov@yandex-team.ru> References: <20260218202829.1322088-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_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 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1771446605741154100 Content-Type: text/plain; charset="utf-8" In for-loop in net_init_af_xdp, we do nc->queue_index =3D i, where is is int64_t for 0 to queues-1, and nc->queue_index is unsigned int. Also in parse_socket_fds, g_strv_length() returns guint which is equivalent to unsigned int. Let's simply use int type for queues, and update the check appropriately. It could be unsigned int, but in future commits we'll share with net/tap.c the common function which will return number of queues or negative error. So, let's simply use int for queues-related variables, that simplifies things. Signed-off-by: Vladimir Sementsov-Ogievskiy --- net/af-xdp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/af-xdp.c b/net/af-xdp.c index 14f302ea21..ff1cb30a98 100644 --- a/net/af-xdp.c +++ b/net/af-xdp.c @@ -442,14 +442,14 @@ static NetClientInfo net_af_xdp_info =3D { }; =20 static int *parse_socket_fds(const char *sock_fds_str, - int64_t n_expected, Error **errp) + int n_expected, Error **errp) { gchar **substrings =3D g_strsplit(sock_fds_str, ":", -1); - int64_t i, n_sock_fds =3D g_strv_length(substrings); + int i, n_sock_fds =3D g_strv_length(substrings); int *sock_fds =3D NULL; =20 if (n_sock_fds !=3D n_expected) { - error_setg(errp, "expected %"PRIi64" socket fds, got %"PRIi64, + error_setg(errp, "expected %d socket fds, got %d", n_expected, n_sock_fds); goto exit; } @@ -484,7 +484,7 @@ int net_init_af_xdp(const Netdev *netdev, unsigned int ifindex; uint32_t prog_id =3D 0; g_autofree int *sock_fds =3D NULL; - int64_t i, queues; + int i, queues; Error *err =3D NULL; AFXDPState *s; bool inhibit; @@ -496,13 +496,14 @@ int net_init_af_xdp(const Netdev *netdev, return -1; } =20 - queues =3D opts->has_queues ? opts->queues : 1; - if (queues < 1) { + if (opts->has_queues && (opts->queues < 1 || opts->queues > INT_MAX)) { error_setg(errp, "invalid number of queues (%" PRIi64 ") for '%s'", - queues, opts->ifname); + opts->queues, opts->ifname); return -1; } =20 + queues =3D opts->has_queues ? opts->queues : 1; + inhibit =3D opts->has_inhibit && opts->inhibit; if (inhibit && !opts->sock_fds && !opts->map_path) { error_setg(errp, "'inhibit=3Don' requires 'sock-fds' or 'map-path'= "); @@ -537,7 +538,7 @@ int net_init_af_xdp(const Netdev *netdev, =20 for (i =3D 0; i < queues; i++) { nc =3D qemu_new_net_client(&net_af_xdp_info, peer, "af-xdp", name); - qemu_set_info_str(nc, "af-xdp%"PRIi64" to %s", i, opts->ifname); + qemu_set_info_str(nc, "af-xdp%d to %s", i, opts->ifname); nc->queue_index =3D i; =20 if (!nc0) { --=20 2.52.0