Skip to content

Commit

Permalink
Merge branch 'selftests/bpf: BTF-based kernel data display'
Browse files Browse the repository at this point in the history
Alan Maguire says:

====================
Resolve issues in bpf selftests introduced with BTF-based kernel data
display selftests; these are

- a warning introduced in snprintf_btf.c; and
- compilation failures with old kernels vmlinux.h
====================

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Alexei Starovoitov committed Sep 29, 2020
2 parents 00e8c44 + cfe7768 commit 3aae4a3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/prog_tests/snprintf_btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void test_snprintf_btf(void)
goto cleanup;

/* generate receive event */
system("ping -c 1 127.0.0.1 > /dev/null");
(void) system("ping -c 1 127.0.0.1 > /dev/null");

if (bss->skip) {
printf("%s:SKIP:no __builtin_btf_type_id\n", __func__);
Expand Down
23 changes: 23 additions & 0 deletions tools/testing/selftests/bpf/progs/bpf_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#define bpf_iter__bpf_map_elem bpf_iter__bpf_map_elem___not_used
#define bpf_iter__bpf_sk_storage_map bpf_iter__bpf_sk_storage_map___not_used
#define bpf_iter__sockmap bpf_iter__sockmap___not_used
#define btf_ptr btf_ptr___not_used
#define BTF_F_COMPACT BTF_F_COMPACT___not_used
#define BTF_F_NONAME BTF_F_NONAME___not_used
#define BTF_F_PTR_RAW BTF_F_PTR_RAW___not_used
#define BTF_F_ZERO BTF_F_ZERO___not_used
#include "vmlinux.h"
#undef bpf_iter_meta
#undef bpf_iter__bpf_map
Expand All @@ -28,6 +33,11 @@
#undef bpf_iter__bpf_map_elem
#undef bpf_iter__bpf_sk_storage_map
#undef bpf_iter__sockmap
#undef btf_ptr
#undef BTF_F_COMPACT
#undef BTF_F_NONAME
#undef BTF_F_PTR_RAW
#undef BTF_F_ZERO

struct bpf_iter_meta {
struct seq_file *seq;
Expand Down Expand Up @@ -105,3 +115,16 @@ struct bpf_iter__sockmap {
void *key;
struct sock *sk;
};

struct btf_ptr {
void *ptr;
__u32 type_id;
__u32 flags;
};

enum {
BTF_F_COMPACT = (1ULL << 0),
BTF_F_NONAME = (1ULL << 1),
BTF_F_PTR_RAW = (1ULL << 2),
BTF_F_ZERO = (1ULL << 3),
};
27 changes: 27 additions & 0 deletions tools/testing/selftests/bpf/progs/btf_ptr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2020, Oracle and/or its affiliates. */
/* "undefine" structs in vmlinux.h, because we "override" them below */
#define btf_ptr btf_ptr___not_used
#define BTF_F_COMPACT BTF_F_COMPACT___not_used
#define BTF_F_NONAME BTF_F_NONAME___not_used
#define BTF_F_PTR_RAW BTF_F_PTR_RAW___not_used
#define BTF_F_ZERO BTF_F_ZERO___not_used
#include "vmlinux.h"
#undef btf_ptr
#undef BTF_F_COMPACT
#undef BTF_F_NONAME
#undef BTF_F_PTR_RAW
#undef BTF_F_ZERO

struct btf_ptr {
void *ptr;
__u32 type_id;
__u32 flags;
};

enum {
BTF_F_COMPACT = (1ULL << 0),
BTF_F_NONAME = (1ULL << 1),
BTF_F_PTR_RAW = (1ULL << 2),
BTF_F_ZERO = (1ULL << 3),
};
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/netif_receive_skb.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2020, Oracle and/or its affiliates. */

#include "vmlinux.h"
#include "btf_ptr.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
Expand Down

0 comments on commit 3aae4a3

Please sign in to comment.