xref: /linux/tools/testing/selftests/bpf/progs/bpf_iter.h (revision 84544f5637ff3501876ba96bd48ca900317e08fb)
1*84544f56SYonghong Song /* SPDX-License-Identifier: GPL-2.0 */
2*84544f56SYonghong Song /* Copyright (c) 2020 Facebook */
3*84544f56SYonghong Song /* "undefine" structs in vmlinux.h, because we "override" them below */
4*84544f56SYonghong Song #define bpf_iter_meta bpf_iter_meta___not_used
5*84544f56SYonghong Song #define bpf_iter__bpf_map bpf_iter__bpf_map___not_used
6*84544f56SYonghong Song #define bpf_iter__ipv6_route bpf_iter__ipv6_route___not_used
7*84544f56SYonghong Song #define bpf_iter__netlink bpf_iter__netlink___not_used
8*84544f56SYonghong Song #define bpf_iter__task bpf_iter__task___not_used
9*84544f56SYonghong Song #define bpf_iter__task_file bpf_iter__task_file___not_used
10*84544f56SYonghong Song #include "vmlinux.h"
11*84544f56SYonghong Song #undef bpf_iter_meta
12*84544f56SYonghong Song #undef bpf_iter__bpf_map
13*84544f56SYonghong Song #undef bpf_iter__ipv6_route
14*84544f56SYonghong Song #undef bpf_iter__netlink
15*84544f56SYonghong Song #undef bpf_iter__task
16*84544f56SYonghong Song #undef bpf_iter__task_file
17*84544f56SYonghong Song 
18*84544f56SYonghong Song struct bpf_iter_meta {
19*84544f56SYonghong Song 	struct seq_file *seq;
20*84544f56SYonghong Song 	__u64 session_id;
21*84544f56SYonghong Song 	__u64 seq_num;
22*84544f56SYonghong Song } __attribute__((preserve_access_index));
23*84544f56SYonghong Song 
24*84544f56SYonghong Song struct bpf_iter__ipv6_route {
25*84544f56SYonghong Song 	struct bpf_iter_meta *meta;
26*84544f56SYonghong Song 	struct fib6_info *rt;
27*84544f56SYonghong Song } __attribute__((preserve_access_index));
28*84544f56SYonghong Song 
29*84544f56SYonghong Song struct bpf_iter__netlink {
30*84544f56SYonghong Song 	struct bpf_iter_meta *meta;
31*84544f56SYonghong Song 	struct netlink_sock *sk;
32*84544f56SYonghong Song } __attribute__((preserve_access_index));
33*84544f56SYonghong Song 
34*84544f56SYonghong Song struct bpf_iter__task {
35*84544f56SYonghong Song 	struct bpf_iter_meta *meta;
36*84544f56SYonghong Song 	struct task_struct *task;
37*84544f56SYonghong Song } __attribute__((preserve_access_index));
38*84544f56SYonghong Song 
39*84544f56SYonghong Song struct bpf_iter__task_file {
40*84544f56SYonghong Song 	struct bpf_iter_meta *meta;
41*84544f56SYonghong Song 	struct task_struct *task;
42*84544f56SYonghong Song 	__u32 fd;
43*84544f56SYonghong Song 	struct file *file;
44*84544f56SYonghong Song } __attribute__((preserve_access_index));
45*84544f56SYonghong Song 
46*84544f56SYonghong Song struct bpf_iter__bpf_map {
47*84544f56SYonghong Song 	struct bpf_iter_meta *meta;
48*84544f56SYonghong Song 	struct bpf_map *map;
49*84544f56SYonghong Song } __attribute__((preserve_access_index));
50