Commit 35ffb1d9 authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

Merge branch 'clean-up bpftool from legacy support'



Sahid Orentino Ferdjaoui says:

====================

As part of commit 93b8952d ("libbpf: deprecate legacy BPF map
definitions") and commit bd054102 ("libbpf: enforce strict libbpf
1.0 behaviors") The --legacy option is not relevant anymore. #1 is
removing it. #4 is cleaning the code from using libbpf_get_error().

About patches #2 and #3 They are changes discovered while working on
this series (credits to Quentin Monnet). #2 is cleaning-up usage of an
unnecessary PTR_ERR(NULL), finally #3 is fixing an invalid value
passed to strerror().

v1 -> v2:
   - Addressed review comments from Yonghong Song on patch #4
   - Added a patch #5 that removes unwanted function noticed by
     Yonghong Song
v2 -> v3
   - Addressed review comments from Andrii Nakryiko on patch #2, #3, #4
     * clean-up usage of libbpf_get_error() (#2, #3)
     * fix possible return of an uninitialized local variable err
     * fix returned errors using errno
v3 -> v4
   - Addressed review comments from Quentin Monnet
     * fix line moved from patch #2 to patch #3
     * fix missing returned errors using errno
     * fix some returned values to errno instead of -1
====================

Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 99429b22 52df1a8a
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -23,12 +23,3 @@
	  Print all logs available, even debug-level information. This includes
	  logs from libbpf as well as from the verifier, when attempting to
	  load programs.

-l, --legacy
	  Use legacy libbpf mode which has more relaxed BPF program
	  requirements. By default, bpftool has more strict requirements
	  about section names, changes pinning logic and doesn't support
	  some of the older non-BTF map declarations.

	  See https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0
	  for details.
+1 −1
Original line number Diff line number Diff line
.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

.. |COMMON_OPTIONS| replace:: { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } | { **-l** | **--legacy** }
.. |COMMON_OPTIONS| replace:: { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** }
+1 −1
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ _bpftool()
    # Deal with options
    if [[ ${words[cword]} == -* ]]; then
        local c='--version --json --pretty --bpffs --mapcompat --debug \
	       --use-loader --base-btf --legacy'
	       --use-loader --base-btf'
        COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
        return 0
    fi
+8 −11
Original line number Diff line number Diff line
@@ -467,9 +467,8 @@ static int dump_btf_c(const struct btf *btf,
	int err = 0, i;

	d = btf_dump__new(btf, btf_dump_printf, NULL, NULL);
	err = libbpf_get_error(d);
	if (err)
		return err;
	if (!d)
		return -errno;

	printf("#ifndef __VMLINUX_H__\n");
	printf("#define __VMLINUX_H__\n");
@@ -512,11 +511,9 @@ static struct btf *get_vmlinux_btf_from_sysfs(void)
	struct btf *base;

	base = btf__parse(sysfs_vmlinux, NULL);
	if (libbpf_get_error(base)) {
		p_err("failed to parse vmlinux BTF at '%s': %ld\n",
		      sysfs_vmlinux, libbpf_get_error(base));
		base = NULL;
	}
	if (!base)
		p_err("failed to parse vmlinux BTF at '%s': %d\n",
		      sysfs_vmlinux, -errno);

	return base;
}
@@ -559,7 +556,7 @@ static int do_dump(int argc, char **argv)
	__u32 btf_id = -1;
	const char *src;
	int fd = -1;
	int err;
	int err = 0;

	if (!REQ_ARGS(2)) {
		usage();
@@ -634,8 +631,8 @@ static int do_dump(int argc, char **argv)
			base = get_vmlinux_btf_from_sysfs();

		btf = btf__parse_split(*argv, base ?: base_btf);
		err = libbpf_get_error(btf);
		if (!btf) {
			err = -errno;
			p_err("failed to load BTF from %s: %s",
			      *argv, strerror(errno));
			goto done;
@@ -681,8 +678,8 @@ static int do_dump(int argc, char **argv)
		}

		btf = btf__load_from_kernel_by_id_split(btf_id, base_btf);
		err = libbpf_get_error(btf);
		if (!btf) {
			err = -errno;
			p_err("get btf by id (%u): %s", btf_id, strerror(errno));
			goto done;
		}
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ static int dump_prog_id_as_func_ptr(const struct btf_dumper *d,
		goto print;

	prog_btf = btf__load_from_kernel_by_id(info.btf_id);
	if (libbpf_get_error(prog_btf))
	if (!prog_btf)
		goto print;
	func_type = btf__type_by_id(prog_btf, finfo.type_id);
	if (!func_type || !btf_is_func(func_type))
Loading