From patchwork Fri Feb 8 19:19:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 1038929 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=fb.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=fb.com header.i=@fb.com header.b="Kxfr0Iep"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43x4kc0xVNz9sNJ for ; Sat, 9 Feb 2019 06:19:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727569AbfBHTTt (ORCPT ); Fri, 8 Feb 2019 14:19:49 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:45536 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727543AbfBHTTs (ORCPT ); Fri, 8 Feb 2019 14:19:48 -0500 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x18JJjeY018197 for ; Fri, 8 Feb 2019 11:19:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=zViycISuyayz7kWIspqr9FNy6B26/y6qYEcVhwnw9nM=; b=Kxfr0IeplMYgFj4wW6Cj5JxyOkr2VDmdq2RPQzeh/FHiNRX4HK+600LBt+7RghZfibAN 1YPKgrCDH7/d2FpHJFhsJhn8bWe8pAKop1E7f1io0hTV7RcvTrO57/3bjmgO39yqb10B fT3+jVDvdxOwg7+B6FfeRFWksZvEyODEhFU= Received: from maileast.thefacebook.com ([199.201.65.23]) by m0001303.ppops.net with ESMTP id 2qhc81gsgw-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 08 Feb 2019 11:19:47 -0800 Received: from mx-out.facebook.com (2620:10d:c0a1:3::13) by mail.thefacebook.com (2620:10d:c021:18::175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1531.3; Fri, 8 Feb 2019 11:19:43 -0800 Received: by devvm7221.prn2.facebook.com (Postfix, from userid 137359) id DA642A5EB7E5; Fri, 8 Feb 2019 11:19:41 -0800 (PST) Smtp-Origin-Hostprefix: devvm From: Andrii Nakryiko Smtp-Origin-Hostname: devvm7221.prn2.facebook.com To: , , , , , , , , , CC: Andrii Nakryiko Smtp-Origin-Cluster: prn2c23 Subject: [PATCH v4 bpf-next 0/4] tools/btf: extend libbpf APIs to work with btf w/o kernel Date: Fri, 8 Feb 2019 11:19:35 -0800 Message-ID: <20190208191939.3105592-1-andriin@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-08_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patchset introduces a set of new APIs that make it possible to work with BTF more effectively (and without involving kernel) for applications like pahole that need to manipulate .BTF and .BTF.ext data. Patch #1 changes existing btf__new() API call to only load and initialize struct btf, while exposing new btf__load() API to attempt to load and validate BTF in kernel. Patch #2 adds btf__get_raw_data() API allowing to get access to raw BTF data from struct btf. Patch #3 adds similar btf_ext__get_raw_data() API for working with struct btf_ext. Patch #4 removes not-yet-stable btf__get_strings() API which was added to be able to test contents of struct btf for btf__dedup(). It's now superseded by raw APIs. v3->v4: - formatting fixes - renamed btf_ext functions/structs to use "setup" language instead of "copy" - removed btf__get_strings from libbpf.map v2->v3: - const void* variants of btf__get_raw_data() - added btf_ext__get_raw_data() - removed btf__get_strings() and adapted test_btf.c to use btf__get_raw_data() v1->v2: - btf_load() returns just error, not fd - fix ordering in libbpf.map Andrii Nakryiko (4): btf: separate btf creation and loading btf: expose API to work with raw btf data btf: expose API to work with raw btf_ext data tools/bpf: remove btf__get_strings() superseded by raw data API tools/lib/bpf/btf.c | 163 +++++++++++++------------ tools/lib/bpf/btf.h | 6 +- tools/lib/bpf/libbpf.c | 2 +- tools/lib/bpf/libbpf.map | 4 +- tools/testing/selftests/bpf/test_btf.c | 39 ++++-- 5 files changed, 121 insertions(+), 93 deletions(-)