From patchwork Thu Jan 17 15:27:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 1026736 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=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="zJHeTVPc"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43gSdT6CcHz9sDB for ; Fri, 18 Jan 2019 02:28:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728607AbfAQP2N (ORCPT ); Thu, 17 Jan 2019 10:28:13 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50229 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbfAQP2M (ORCPT ); Thu, 17 Jan 2019 10:28:12 -0500 Received: by mail-wm1-f66.google.com with SMTP id n190so1508245wmd.0 for ; Thu, 17 Jan 2019 07:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=3/0kkYCuTYYGdxGS8JGEm+ucB/fQTlzMaahe3yyg8nw=; b=zJHeTVPcojYkuwDEeCRfnpj1oMvHd00mrWf0lr2AN+Z/U0cgsKyCRO+BIHT81MV2zV UEor7ktCywNq0G9lm+AZfPLLNWVCMTpA0zlLEnYlEuJ4sNF+R8RmRrH130PhGY5lBLmx ZHCItCXgz8U/zwdxXwnJmHPWmEQJdDq5hdLVIEqdfm3wbFMYgJO8nvtPwBeSsozYvQE2 FfNW9Q8+axRXNnC/Ctf2MUn1AI78+tKwIL35+2JAW3+ZjiEuV/P21ZIIA1kWRq0Fxjhd SonxrZxI65oFxhbD4x1UbQMs8hdKaQzREi1QvEhFQulQYKPGbgiPOgYeuJ0575df+1Yi uyTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3/0kkYCuTYYGdxGS8JGEm+ucB/fQTlzMaahe3yyg8nw=; b=aUJe1f+F4/DjueHAzeXRGbip7iBc3W1xUvN/gJ7zAaQZ81mnVmJ53fUc2JbIGsffeS EntMbnuxx+gkXYgZjzn+/s1jb9KlA3cFFl7/go7+1lDQ3jwk2YYC8+YCc2hGv/DmTl/V S+BRYDi9dIZLzUdAfzqQ7scQOOVtttamvLBw5n1rQhWLX6zBpGvPeT3abegqw0a5Yrll S+fodoi2gHe7rZBv2WaoiCVP2US8cmz/l7ej5gbruBt67zar/BjK0/UCxEzl6TLW8zOH 4z3TWCTJ57q8Qyp+pFdT1R/iZI0j/yr3RGkQ3O6k1YVSzkXaFB55JTzam6oJ6y7qWZ46 3ekA== X-Gm-Message-State: AJcUukdTOslFiHBzem+TONZPUyth0mdNf2EH7yDzxXXrXT05UBCmMyUd KgWxpzGILi2WINC/K1+lWbW+TA== X-Google-Smtp-Source: ALg8bN7q1qaEzQm8PLUcoe9xCAwwm8HPUnZw4Tf8kYnqvd0SW3SLo1HF0DMSbiLg8v0/UZVV3eljcw== X-Received: by 2002:a1c:b70b:: with SMTP id h11mr12662718wmf.72.1547738888576; Thu, 17 Jan 2019 07:28:08 -0800 (PST) Received: from cbtest32.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id v132sm41513486wme.20.2019.01.17.07.28.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 07:28:07 -0800 (PST) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, Quentin Monnet , Arnaldo Carvalho de Melo , Jesper Dangaard Brouer , Stanislav Fomichev Subject: [PATCH bpf-next v5 0/9] tools: bpftool: add probes for system and device Date: Thu, 17 Jan 2019 15:27:49 +0000 Message-Id: <20190117152758.14883-1-quentin.monnet@netronome.com> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi, This set adds a new command to bpftool in order to dump a list of eBPF-related parameters for the system (or for a specific network device) to the console. Once again, this is based on a suggestion from Daniel. At this time, output includes: - Availability of bpf() system call - Availability of bpf() system call for unprivileged users - JIT status (enabled or not, with or without debugging traces) - JIT hardening status - JIT kallsyms exports status - Global memory limit for JIT compiler for unprivileged users - Status of kernel compilation options related to BPF features - Availability of known eBPF program types - Availability of known eBPF map types - Availability of known eBPF helper functions There are three different ways to dump this information at this time: - Plain output dumps probe results in plain text. It is the most flexible options for providing descriptive output to the user, but should not be relied upon for parsing the output. - JSON output is supported. - A third mode, available through the "macros" keyword appended to the command line, dumps some of those parameters (not all) as a series of "#define" directives, that can be included into a C header file for example. Probes for supported program and map types, and supported helpers, are directly added to libbpf, so that other applications (or selftests) can reuse them as necessary. If the user does not have root privileges (or more precisely, the CAP_SYS_ADMIN capability) detection will be erroneous for most parameters. Therefore, forbid non-root users to run the command. v5: - Move exported symbols to a new LIBBPF_0.0.2 section in libbpf.map (patches 4 to 6). - Minor fixes on patches 3 and 4. v4: - Probe bpf_jit_limit parameter (patch 2). - Probe some additional kernel config options (patch 3). - Minor fixes on patch 6. v3: - Do not probe kernel version in bpftool (just retrieve it to probe support for kprobes in libbpf). - Change the way results for helper support is displayed: now one list of compatible helpers for each program type (and C-style output gets a HAVE_PROG_TYPE_HELPER(prog_type, helper) macro to help with tests. See patches 6, 7. - Address other comments from feedback from v2 (please refer to individual patches' history). v2 (please also refer to individual patches' history): - Move probes for prog/map types, helpers, from bpftool to libbpf. - Move C-style output as a separate patch, and restrict it to a subset of collected information (bpf() availability, prog/map types, helpers). - Now probe helpers with all supported program types, and display a list of compatible program types (as supported on the system) for each helper. - NOT addressed: grouping compilation options for kernel into subsections (patch 3) (I don't see an easy way of grouping them at the moment, please see also the discussion on v1 thread). Cc: Arnaldo Carvalho de Melo Cc: Jesper Dangaard Brouer Cc: Stanislav Fomichev Quentin Monnet (9): tools: bpftool: add basic probe capability, probe syscall availability tools: bpftool: add probes for /proc/ eBPF parameters tools: bpftool: add probes for kernel configuration options tools: bpftool: add probes for eBPF program types tools: bpftool: add probes for eBPF map types tools: bpftool: add probes for eBPF helper functions tools: bpftool: add C-style "#define" output for probes tools: bpftool: add probes for a network device tools: bpftool: add bash completion for bpftool probes .../bpftool/Documentation/bpftool-cgroup.rst | 1 + .../bpftool/Documentation/bpftool-feature.rst | 85 ++ .../bpf/bpftool/Documentation/bpftool-map.rst | 1 + .../bpf/bpftool/Documentation/bpftool-net.rst | 1 + .../bpftool/Documentation/bpftool-perf.rst | 1 + .../bpftool/Documentation/bpftool-prog.rst | 1 + tools/bpf/bpftool/Documentation/bpftool.rst | 1 + tools/bpf/bpftool/bash-completion/bpftool | 19 + tools/bpf/bpftool/feature.c | 764 ++++++++++++++++++ tools/bpf/bpftool/main.c | 3 +- tools/bpf/bpftool/main.h | 4 + tools/bpf/bpftool/map.c | 4 +- tools/lib/bpf/Build | 2 +- tools/lib/bpf/libbpf.h | 14 + tools/lib/bpf/libbpf.map | 9 + tools/lib/bpf/libbpf_probes.c | 242 ++++++ 16 files changed, 1149 insertions(+), 3 deletions(-) create mode 100644 tools/bpf/bpftool/Documentation/bpftool-feature.rst create mode 100644 tools/bpf/bpftool/feature.c create mode 100644 tools/lib/bpf/libbpf_probes.c