-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/bpf: Move newer bpf_iter_* type redefining to a new header …
…file Commit b9f4c01 ("selftest/bpf: Make bpf_iter selftest compilable against old vmlinux.h") and Commit dda18a5 ("selftests/bpf: Convert bpf_iter_test_kern{3, 4}.c to define own bpf_iter_meta") redefined newly introduced types in bpf programs so the bpf program can still compile properly with old kernels although loading may fail. Since this patch set introduced new types and the same workaround is needed, so let us move the workaround to a separate header file so they do not clutter bpf programs. Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200623230816.3988656-1-yhs@fb.com
- Loading branch information
Yonghong Song
authored and
Alexei Starovoitov
committed
Jun 25, 2020
1 parent
0d4fad3
commit 84544f5
Showing
9 changed files
with
57 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) 2020 Facebook */ | ||
/* "undefine" structs in vmlinux.h, because we "override" them below */ | ||
#define bpf_iter_meta bpf_iter_meta___not_used | ||
#define bpf_iter__bpf_map bpf_iter__bpf_map___not_used | ||
#define bpf_iter__ipv6_route bpf_iter__ipv6_route___not_used | ||
#define bpf_iter__netlink bpf_iter__netlink___not_used | ||
#define bpf_iter__task bpf_iter__task___not_used | ||
#define bpf_iter__task_file bpf_iter__task_file___not_used | ||
#include "vmlinux.h" | ||
#undef bpf_iter_meta | ||
#undef bpf_iter__bpf_map | ||
#undef bpf_iter__ipv6_route | ||
#undef bpf_iter__netlink | ||
#undef bpf_iter__task | ||
#undef bpf_iter__task_file | ||
|
||
struct bpf_iter_meta { | ||
struct seq_file *seq; | ||
__u64 session_id; | ||
__u64 seq_num; | ||
} __attribute__((preserve_access_index)); | ||
|
||
struct bpf_iter__ipv6_route { | ||
struct bpf_iter_meta *meta; | ||
struct fib6_info *rt; | ||
} __attribute__((preserve_access_index)); | ||
|
||
struct bpf_iter__netlink { | ||
struct bpf_iter_meta *meta; | ||
struct netlink_sock *sk; | ||
} __attribute__((preserve_access_index)); | ||
|
||
struct bpf_iter__task { | ||
struct bpf_iter_meta *meta; | ||
struct task_struct *task; | ||
} __attribute__((preserve_access_index)); | ||
|
||
struct bpf_iter__task_file { | ||
struct bpf_iter_meta *meta; | ||
struct task_struct *task; | ||
__u32 fd; | ||
struct file *file; | ||
} __attribute__((preserve_access_index)); | ||
|
||
struct bpf_iter__bpf_map { | ||
struct bpf_iter_meta *meta; | ||
struct bpf_map *map; | ||
} __attribute__((preserve_access_index)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 1 addition & 17 deletions
18
tools/testing/selftests/bpf/progs/bpf_iter_test_kern_common.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters