From nobody Wed Nov 27 20:28:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697378722; cv=none; d=zohomail.com; s=zohoarc; b=I9nRh4HlJsyI7/fdIocPHq45ERrfWZXtEDSKeI0v/ukdtn0tnqsMFZlPZJbUXThF4ogqr35ZqD1D+J5j3YvR+QJ7z/Z4EEa8vHbdkiPHTeupXnD/Jmo7e2p9zRfmmvLzIXlLk7vvchPPEZms9oTV9FaDWtP9PSQfntls+SBCYGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697378722; 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:Message-Id:Reply-To:To; bh=4suv/BvTtFCyaarl96M7QPK/UCb253pLYJ0sJd7urgg=; b=gXjmiU/R4MSgLxL7F/kSJBBd9lAWx0rotkyMRybQYZ4bIxDmGSAxVmAvTl90/zrNtxReU+iM65m3S90JK+ZTmgjv7E+6+pLpcuoCBK9QAa5P/ZENuhYFEqyr45easW9NhAmWRpOEAZUcljGEZ4FhnSPj898Jaof0e9GOcG1qLCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697378722544936.1874180165548; Sun, 15 Oct 2023 07:05:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qs1iv-0002P0-U5; Sun, 15 Oct 2023 10:04:06 -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 1qs1iu-0002EC-A5 for qemu-devel@nongnu.org; Sun, 15 Oct 2023 10:04:04 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qs1is-0007oT-ND for qemu-devel@nongnu.org; Sun, 15 Oct 2023 10:04:04 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-27d5fe999caso257602a91.1 for ; Sun, 15 Oct 2023 07:04:02 -0700 (PDT) Received: from localhost ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with UTF8SMTPSA id 30-20020a17090a199e00b0027d15bd9fa2sm3388696pji.35.2023.10.15.07.03.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 Oct 2023 07:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697378641; x=1697983441; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4suv/BvTtFCyaarl96M7QPK/UCb253pLYJ0sJd7urgg=; b=Lpphr74cdK2DDU6qG2+OLsPXAst/QZRjl5iG5xtiEraNhVrAVHp9dTut5EHn5RbSGG JuXhFPXJE8ZunlroF+KQzuxCtSLpraDWRRCCqY1qtnacRR8/C5ikmdCyuPB4ElpkPjdV qt/jJ7ibIPqlDl/CGn+oVANWgvH3NXNt1qqGZsnPpo4os9W//x7LkwUEDCFGGeQNILKX 80VUHba2uLwlC45c944FToehXxIE4iTO0cfGXyH7s0oboQ2XiU/3lheqlLToidnakerR gbNQ/Q7JBA10C5vEKkXIpX73d5x6MXopFacJkc80c9xyiVy6n7J8sGd4J/5SPuo+cEoR vCow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697378641; x=1697983441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4suv/BvTtFCyaarl96M7QPK/UCb253pLYJ0sJd7urgg=; b=d4UdC9n8K0UnFe5A9HE2jfMOHVf3SMbhlNC5GtsDGZI6bl/RmjgtvfyGxQAhTreJMv KJslN6TrLJ2cT0x7RK1puYJGCgn0xxhdO2a+MKEijPAjMh7pln8coDsGTHPNybp95KrZ 0fGOewJ9zy8edPnA/B51Jg3y39rVK2FmWZ4xf2aVNuERysegMRbRdjD++MnLtyDQni4f TS9TN9hxpgvy2NCFvxmS7CVDPfT9RCKR1HHpKDGU6QqPp6IsIvVZtorU48TVjzux/B93 zbcIpuputN/Fz7kn0g5rS7DmMW89nug89VTeX4XVhH30Vho9PLhMbp/Xm61qHO3H9laA Up/Q== X-Gm-Message-State: AOJu0YxxEL03A0A6xWyDOkJ41ytKF8GO7S+ZMi8qA/dQbveFZ8cFY1VT d6MLkFvN1YbXmTP3h2G2hWcAPfZZ17HR/PCVGHVjFA== X-Google-Smtp-Source: AGHT+IHoNnZYdZQEDPPcNMteL0Ys2gU1mn7pchSzsKeXJPgukbviNud1EoBx2HHa14X85OkvtHAS6g== X-Received: by 2002:a17:90b:1194:b0:27d:2e5b:55ca with SMTP id gk20-20020a17090b119400b0027d2e5b55camr5791270pjb.26.1697378641409; Sun, 15 Oct 2023 07:04:01 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Akihiko Odaki Subject: [PATCH v4 15/20] ebpf: Fix RSS error handling Date: Sun, 15 Oct 2023 23:02:47 +0900 Message-ID: <20231015140259.259434-16-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231015140259.259434-1-akihiko.odaki@daynix.com> References: <20231015140259.259434-1-akihiko.odaki@daynix.com> 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: none client-ip=2607:f8b0:4864:20::1035; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1697378724253100003 Content-Type: text/plain; charset="utf-8" calculate_rss_hash() was using hash value 0 to tell if it calculated a hash, but the hash value may be 0 on a rare occasion. Have a distinct bool value for correctness. Fixes: f3fa412de2 ("ebpf: Added eBPF RSS program.") Signed-off-by: Akihiko Odaki --- tools/ebpf/rss.bpf.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c index 20f227e2ac..667ea6899e 100644 --- a/tools/ebpf/rss.bpf.c +++ b/tools/ebpf/rss.bpf.c @@ -377,18 +377,19 @@ error: return err; } =20 -static inline __u32 calculate_rss_hash(struct __sk_buff *skb, - struct rss_config_t *config, struct toeplitz_key_data_t *toe) +static inline bool calculate_rss_hash(struct __sk_buff *skb, + struct rss_config_t *config, + struct toeplitz_key_data_t *toe, + __u32 *result) { __u8 rss_input[HASH_CALCULATION_BUFFER_SIZE] =3D {}; size_t bytes_written =3D 0; - __u32 result =3D 0; int err =3D 0; struct packet_hash_info_t packet_info =3D {}; =20 err =3D parse_packet(skb, &packet_info); if (err) { - return 0; + return false; } =20 if (packet_info.is_ipv4) { @@ -521,11 +522,13 @@ static inline __u32 calculate_rss_hash(struct __sk_bu= ff *skb, } } =20 - if (bytes_written) { - net_toeplitz_add(&result, rss_input, bytes_written, toe); + if (!bytes_written) { + return false; } =20 - return result; + net_toeplitz_add(result, rss_input, bytes_written, toe); + + return true; } =20 SEC("tun_rss_steering") @@ -546,8 +549,7 @@ int tun_rss_steering_prog(struct __sk_buff *skb) return config->default_queue; } =20 - hash =3D calculate_rss_hash(skb, config, toe); - if (hash) { + if (calculate_rss_hash(skb, config, toe, &hash)) { __u32 table_idx =3D hash % config->indirections_len; __u16 *queue =3D 0; =20 --=20 2.42.0