From patchwork Thu Feb 24 12:09:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Kuohai X-Patchwork-Id: 12758433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB201C433EF for ; Thu, 24 Feb 2022 11:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232939AbiBXL7k (ORCPT ); Thu, 24 Feb 2022 06:59:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231683AbiBXL7j (ORCPT ); Thu, 24 Feb 2022 06:59:39 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30D19488A3 for ; Thu, 24 Feb 2022 03:59:10 -0800 (PST) Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4K4BHS050tzdZf0; Thu, 24 Feb 2022 19:57:55 +0800 (CST) Received: from huawei.com (10.67.174.197) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 24 Feb 2022 19:59:07 +0800 From: Xu Kuohai To: CC: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Yonghong Song , Shuah Khan , Martin KaFai Lau , Song Liu Subject: [PATCH bpf-next v3 0/2] Fix btf dump error caused by declaration Date: Thu, 24 Feb 2022 07:09:41 -0500 Message-ID: <20220224120943.1169985-1-xukuohai@huawei.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Originating-IP: [10.67.174.197] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500013.china.huawei.com (7.221.188.120) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net This series fixes a btf dump error caused by forward declaration. Currently if a declaration appears in the BTF before the definition, the definition is dumped as a conflicting name, eg: $ bpftool btf dump file vmlinux format raw | grep "'unix_sock'" [81287] FWD 'unix_sock' fwd_kind=struct [89336] STRUCT 'unix_sock' size=1024 vlen=14 $ bpftool btf dump file vmlinux format c | grep "struct unix_sock" struct unix_sock; struct unix_sock___2 { <--- conflict, the "___2" is unexpected struct unix_sock___2 *unix_sk; This causes a "definition not found" compilation error if the dump output is used as a header file. Xu Kuohai (2): libbpf: Skip forward declaration when counting duplicated type names selftests/bpf: Update btf_dump case for conflicting names tools/lib/bpf/btf_dump.c | 5 ++ .../selftests/bpf/prog_tests/btf_dump.c | 54 ++++++++++++++----- 2 files changed, 46 insertions(+), 13 deletions(-)