From patchwork Fri Feb 8 02:55:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 1038439 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="VWw004pn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43wfvS47j7z9sML for ; Fri, 8 Feb 2019 13:56:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbfBHC4C (ORCPT ); Thu, 7 Feb 2019 21:56:02 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:36680 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726911AbfBHC4B (ORCPT ); Thu, 7 Feb 2019 21:56:01 -0500 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x182mZ0b003305 for ; Thu, 7 Feb 2019 18:56:00 -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=GA5fazJQwkQeRthduGUVbAOcgyyROeho4KaKTwckjrU=; b=VWw004pnk2Xdz65VTFn1STolmV0Iy5fiWj5naMf+gi8jK56GoifqwHGbUw/f/p8FPxF0 sHFpLKoWq2f4QQw8Z7LqF16FslZlDIoUY7nyts/ADAwMMKRrBFU5uTJ76QEBAPTtBcxk v6MFR0ZNDzoM7aoIum3Qe0NBbsVldklFnhE= Received: from mail.thefacebook.com ([199.201.64.23]) by m0089730.ppops.net with ESMTP id 2qgx7krj3w-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 07 Feb 2019 18:56:00 -0800 Received: from mx-out.facebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1531.3; Thu, 7 Feb 2019 18:55:58 -0800 Received: by devvm7221.prn2.facebook.com (Postfix, from userid 137359) id 461FFA556D5D; Thu, 7 Feb 2019 18:55:58 -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 v3 bpf-next 0/4] tools/btf: extend libbpf APIs to work with btf w/o kernel Date: Thu, 7 Feb 2019 18:55:51 -0800 Message-ID: <20190208025555.4027769-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_01:, , 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. v2->v3: - const void* variants of btf__get_raw_data() - added btf_ext__get_raw_data() - removed btf__get_strings() and adapated 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 | 145 +++++++++++++------------ tools/lib/bpf/btf.h | 6 +- tools/lib/bpf/libbpf.c | 2 +- tools/lib/bpf/libbpf.map | 3 + tools/testing/selftests/bpf/test_btf.c | 39 ++++--- 5 files changed, 110 insertions(+), 85 deletions(-)