Received: by 2002:a05:6358:7583:b0:c2:e7cc:3b64 with SMTP id x3csp60563rwf; Fri, 16 Sep 2022 14:02:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wqREHBU8h73zBTylP68oqGTusjmxRpau1x64nPl0p4NjNekysThSTOlQ9RYfIM566LAWz X-Received: by 2002:a17:903:4112:b0:178:29d8:6d56 with SMTP id r18-20020a170903411200b0017829d86d56mr1613864pld.143.1663362146588; Fri, 16 Sep 2022 14:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663362146; cv=none; d=google.com; s=arc-20160816; b=yQoUZvZwgPRA4bOeURiHGpdk5f3dBB3wKMDEI7ALpPVt0TlaNSq8RHwnUbVxEsTTTX USoQHm2ONd15p6vEl3ibcHfSthDY0/Mbbhd/wYoqPOcKLUcBXUz5SmvgHykREXv4+RI5 iQ4Zl9jXjgY+0AmGqNv4yJIuLMLtjyPgGNtjmlPIvwGwNMsEs447izHM7oRynoJq831v ZEVvuTTA7/xuBbOVOTrj3rG+AOwC/Wpoi82RzcGhH9t5wkKY6vJurbCujUtjx+JXOHSm 2Ub7yNT+w4Ts6tGOmLbLu7zWxZv+ZrDLwem5iqC+Aer8jMeUOynFxC+JgwcBSDdWC8kg v1Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CjL7owck1dNbP/thPcZ5UQpXADCiYYzVUdGfT1CXMn8=; b=sJDNNjoQuJdBf55Y8zQ/lEJ2KrWj+mcdVVTmZoHHsmwLlFw7sYgHfOluzWOB3wqthJ mAIODp5jFPLzOHPEh+nhE6R7/hLxKDT0DV694XYF6yPv/VlmzKLV2hF1GU8iJ146Zgzo 2jQOO2dxq9PAq/Q/nUfUu5rOjCGt5hhxvUaZm/BFyCRy52Gsix3E0vsXTpxK7iCSZFJV 3QfrtXxDWvrdYHXKfoGQliUFPJR7oRE4psjxL/qt1uYDxGL9AcICbysOpwRf5J5rJAWV OSahtDUQAD9ZsKV4t3gWfxEXhIxn+UtMk/gKKqmWNiXuQtOFrIIrI/9zxkPuYiOvdjFa 8u6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TIxLJgD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170903228500b00178170100fasi24624858plh.337.2022.09.16.14.02.09; Fri, 16 Sep 2022 14:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TIxLJgD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbiIPU2Q (ORCPT + 99 others); Fri, 16 Sep 2022 16:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbiIPU2O (ORCPT ); Fri, 16 Sep 2022 16:28:14 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5BBA9C06; Fri, 16 Sep 2022 13:28:13 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 78so21330581pgb.13; Fri, 16 Sep 2022 13:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=CjL7owck1dNbP/thPcZ5UQpXADCiYYzVUdGfT1CXMn8=; b=TIxLJgD58yFPG1Vw5L8sUGiVdd+z5VsjexqSt2OTRNGD3zaVwGo6HMwzkt4pPhm2+w y+MPvW28JqWpVbvTAeB7FWQ8v2Lz0ROqVLNagiEeRAsA51W6dA7vfL+sKcVhUZ7vdnkj +/x/AxtU331P2T7tWUWKTU8rPeA44CwaCmnWkjRE0j5RgJT1WCHrcPLxQJQSHSjdMjja HYFAxFIe0XTO1UJl9vJL1bCFzNUldQWv8iYq7RLEnfZC0g2gH6r1b0n3VaigzjtKfNGP uZFNXp1drl6N/Z3nGkpJJKPU5WgVyWiLxJo7UG/xcvr6tjORYac13c/mODR53E1m7sFe XaxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=CjL7owck1dNbP/thPcZ5UQpXADCiYYzVUdGfT1CXMn8=; b=0Mud6s/E1DRXcVHDgaMIwW10DYr9/liz9fjE4Vu653TAkv+bcAYN+u5cA2/CXIaNr6 NRgVJU80KoZIHh/QEAN5bwlpZlnF172x/kr9qACs7mucKYyX82CCC4waZx7du8wsIj2p 30GDjkrE5xkP37Yzrei+W3w2oorQuZYV2KaRDyiI2K+w1jMsWytxHtuuhPzB733k9Z0f BvcQGE8DEA4obgEXqu7Tm+ETxi6p4rQgyXU6Hy4WOZPVRvwDuBSALRH0ERXBInnhN6Dv m+fDmHOoc229zN4cJxnLoS9b5jUaWaJERgidfNnCwmPxnzaN5snyjGwg474MxQtwV+8A 4J1g== X-Gm-Message-State: ACrzQf0bJKh11XdfZ0sB068ot+L8mUu8aIQSxxM04MBHF+NCCCVuPfWk rAnP9JCD7UVMeY4ri5nVqg== X-Received: by 2002:a05:6a00:d60:b0:53e:576e:bd8c with SMTP id n32-20020a056a000d6000b0053e576ebd8cmr6672425pfv.4.1663360092955; Fri, 16 Sep 2022 13:28:12 -0700 (PDT) Received: from bytedance.bytedance.net ([12.125.146.54]) by smtp.gmail.com with ESMTPSA id w1-20020a1709026f0100b00178650510f9sm5054515plk.160.2022.09.16.13.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 13:28:12 -0700 (PDT) From: Peilin Ye To: Martin KaFai Lau Cc: Peilin Ye , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Peilin Ye Subject: [PATCH bpf-next v2] bpf/btf: Use btf_type_str() whenever possible Date: Fri, 16 Sep 2022 13:28:00 -0700 Message-Id: <20220916202800.31421-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220914021328.17039-1-yepeilin.cs@gmail.com> References: <20220914021328.17039-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peilin Ye We have btf_type_str(). Use it whenever possible in btf.c, instead of "btf_kind_str[BTF_INFO_KIND(t->info)]". Signed-off-by: Peilin Ye --- change since v1: - rebase on bpf-next (Martin KaFai Lau) - also use btf_type_str() in __btf_verifier_log_type() kernel/bpf/btf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 98be25d13325..b3940c605aac 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -1397,7 +1397,6 @@ __printf(4, 5) static void __btf_verifier_log_type(struct btf_verifier_env *env, const char *fmt, ...) { struct bpf_verifier_log *log = &env->log; - u8 kind = BTF_INFO_KIND(t->info); struct btf *btf = env->btf; va_list args; @@ -1413,7 +1412,7 @@ __printf(4, 5) static void __btf_verifier_log_type(struct btf_verifier_env *env, __btf_verifier_log(log, "[%u] %s %s%s", env->log_type_id, - btf_kind_str[kind], + btf_type_str(t), __btf_name_by_offset(btf, t->name_off), log_details ? " " : ""); @@ -5427,7 +5426,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_small_int(t)) { bpf_log(log, "ret type %s not allowed for fmod_ret\n", - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } break; @@ -5454,7 +5453,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, "func '%s' arg%d '%s' has type %s. Only pointer access is allowed\n", tname, arg, __btf_name_by_offset(btf, t->name_off), - btf_kind_str[BTF_INFO_KIND(t->info)]); + btf_type_str(t)); return false; } @@ -5538,11 +5537,11 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, if (!btf_type_is_struct(t)) { bpf_log(log, "func '%s' arg%d type %s is not a struct\n", - tname, arg, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, arg, btf_type_str(t)); return false; } bpf_log(log, "func '%s' arg%d has btf_id %d type %s '%s'\n", - tname, arg, info->btf_id, btf_kind_str[BTF_INFO_KIND(t->info)], + tname, arg, info->btf_id, btf_type_str(t), __btf_name_by_offset(btf, t->name_off)); return true; } @@ -5950,7 +5949,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0 || __btf_type_is_struct(t)) { bpf_log(log, "The function %s return type %s is unsupported.\n", - tname, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, btf_type_str(t)); return -EINVAL; } m->ret_size = ret; @@ -5968,7 +5967,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, if (ret < 0 || ret > 16) { bpf_log(log, "The function %s arg%d type %s is unsupported.\n", - tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]); + tname, i, btf_type_str(t)); return -EINVAL; } if (ret == 0) { @@ -6727,7 +6726,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog, continue; } bpf_log(log, "Arg#%d type %s in %s() is not supported yet.\n", - i, btf_kind_str[BTF_INFO_KIND(t->info)], tname); + i, btf_type_str(t), tname); return -EINVAL; } return 0; -- 2.20.1