184544f56SYonghong Song /* SPDX-License-Identifier: GPL-2.0 */
284544f56SYonghong Song /* Copyright (c) 2020 Facebook */
384544f56SYonghong Song /* "undefine" structs in vmlinux.h, because we "override" them below */
484544f56SYonghong Song #define bpf_iter_meta bpf_iter_meta___not_used
584544f56SYonghong Song #define bpf_iter__bpf_map bpf_iter__bpf_map___not_used
684544f56SYonghong Song #define bpf_iter__ipv6_route bpf_iter__ipv6_route___not_used
784544f56SYonghong Song #define bpf_iter__netlink bpf_iter__netlink___not_used
884544f56SYonghong Song #define bpf_iter__task bpf_iter__task___not_used
984544f56SYonghong Song #define bpf_iter__task_file bpf_iter__task_file___not_used
10e8168840SSong Liu #define bpf_iter__task_vma bpf_iter__task_vma___not_used
112767c977SYonghong Song #define bpf_iter__tcp bpf_iter__tcp___not_used
122767c977SYonghong Song #define tcp6_sock tcp6_sock___not_used
13ace6d6ecSYonghong Song #define bpf_iter__udp bpf_iter__udp___not_used
14ace6d6ecSYonghong Song #define udp6_sock udp6_sock___not_used
1504e92818SKuniyuki Iwashima #define bpf_iter__unix bpf_iter__unix___not_used
16363885d7SAndrii Nakryiko #define bpf_iter__bpf_map_elem bpf_iter__bpf_map_elem___not_used
17363885d7SAndrii Nakryiko #define bpf_iter__bpf_sk_storage_map bpf_iter__bpf_sk_storage_map___not_used
182f7de986SLorenz Bauer #define bpf_iter__sockmap bpf_iter__sockmap___not_used
195a9b8e2cSDmitrii Dolgov #define bpf_iter__bpf_link bpf_iter__bpf_link___not_used
20*fe0dd9d4SHao Luo #define bpf_iter__cgroup bpf_iter__cgroup___not_used
21cfe77683SAlan Maguire #define btf_ptr btf_ptr___not_used
22cfe77683SAlan Maguire #define BTF_F_COMPACT BTF_F_COMPACT___not_used
23cfe77683SAlan Maguire #define BTF_F_NONAME BTF_F_NONAME___not_used
24cfe77683SAlan Maguire #define BTF_F_PTR_RAW BTF_F_PTR_RAW___not_used
25cfe77683SAlan Maguire #define BTF_F_ZERO BTF_F_ZERO___not_used
26a9d2fae8SAlan Maguire #define bpf_iter__ksym bpf_iter__ksym___not_used
2784544f56SYonghong Song #include "vmlinux.h"
2884544f56SYonghong Song #undef bpf_iter_meta
2984544f56SYonghong Song #undef bpf_iter__bpf_map
3084544f56SYonghong Song #undef bpf_iter__ipv6_route
3184544f56SYonghong Song #undef bpf_iter__netlink
3284544f56SYonghong Song #undef bpf_iter__task
3384544f56SYonghong Song #undef bpf_iter__task_file
34e8168840SSong Liu #undef bpf_iter__task_vma
352767c977SYonghong Song #undef bpf_iter__tcp
362767c977SYonghong Song #undef tcp6_sock
37ace6d6ecSYonghong Song #undef bpf_iter__udp
38ace6d6ecSYonghong Song #undef udp6_sock
3904e92818SKuniyuki Iwashima #undef bpf_iter__unix
40363885d7SAndrii Nakryiko #undef bpf_iter__bpf_map_elem
41363885d7SAndrii Nakryiko #undef bpf_iter__bpf_sk_storage_map
422f7de986SLorenz Bauer #undef bpf_iter__sockmap
435a9b8e2cSDmitrii Dolgov #undef bpf_iter__bpf_link
44*fe0dd9d4SHao Luo #undef bpf_iter__cgroup
45cfe77683SAlan Maguire #undef btf_ptr
46cfe77683SAlan Maguire #undef BTF_F_COMPACT
47cfe77683SAlan Maguire #undef BTF_F_NONAME
48cfe77683SAlan Maguire #undef BTF_F_PTR_RAW
49cfe77683SAlan Maguire #undef BTF_F_ZERO
50a9d2fae8SAlan Maguire #undef bpf_iter__ksym
5184544f56SYonghong Song 
5284544f56SYonghong Song struct bpf_iter_meta {
5384544f56SYonghong Song 	struct seq_file *seq;
5484544f56SYonghong Song 	__u64 session_id;
5584544f56SYonghong Song 	__u64 seq_num;
5684544f56SYonghong Song } __attribute__((preserve_access_index));
5784544f56SYonghong Song 
5884544f56SYonghong Song struct bpf_iter__ipv6_route {
5984544f56SYonghong Song 	struct bpf_iter_meta *meta;
6084544f56SYonghong Song 	struct fib6_info *rt;
6184544f56SYonghong Song } __attribute__((preserve_access_index));
6284544f56SYonghong Song 
6384544f56SYonghong Song struct bpf_iter__netlink {
6484544f56SYonghong Song 	struct bpf_iter_meta *meta;
6584544f56SYonghong Song 	struct netlink_sock *sk;
6684544f56SYonghong Song } __attribute__((preserve_access_index));
6784544f56SYonghong Song 
6884544f56SYonghong Song struct bpf_iter__task {
6984544f56SYonghong Song 	struct bpf_iter_meta *meta;
7084544f56SYonghong Song 	struct task_struct *task;
7184544f56SYonghong Song } __attribute__((preserve_access_index));
7284544f56SYonghong Song 
7384544f56SYonghong Song struct bpf_iter__task_file {
7484544f56SYonghong Song 	struct bpf_iter_meta *meta;
7584544f56SYonghong Song 	struct task_struct *task;
7684544f56SYonghong Song 	__u32 fd;
7784544f56SYonghong Song 	struct file *file;
7884544f56SYonghong Song } __attribute__((preserve_access_index));
7984544f56SYonghong Song 
80e8168840SSong Liu struct bpf_iter__task_vma {
81e8168840SSong Liu 	struct bpf_iter_meta *meta;
82e8168840SSong Liu 	struct task_struct *task;
83e8168840SSong Liu 	struct vm_area_struct *vma;
84e8168840SSong Liu } __attribute__((preserve_access_index));
85e8168840SSong Liu 
8684544f56SYonghong Song struct bpf_iter__bpf_map {
8784544f56SYonghong Song 	struct bpf_iter_meta *meta;
8884544f56SYonghong Song 	struct bpf_map *map;
8984544f56SYonghong Song } __attribute__((preserve_access_index));
902767c977SYonghong Song 
912767c977SYonghong Song struct bpf_iter__tcp {
922767c977SYonghong Song 	struct bpf_iter_meta *meta;
932767c977SYonghong Song 	struct sock_common *sk_common;
942767c977SYonghong Song 	uid_t uid;
952767c977SYonghong Song } __attribute__((preserve_access_index));
962767c977SYonghong Song 
972767c977SYonghong Song struct tcp6_sock {
982767c977SYonghong Song 	struct tcp_sock	tcp;
992767c977SYonghong Song 	struct ipv6_pinfo inet6;
1002767c977SYonghong Song } __attribute__((preserve_access_index));
101ace6d6ecSYonghong Song 
102ace6d6ecSYonghong Song struct bpf_iter__udp {
103ace6d6ecSYonghong Song 	struct bpf_iter_meta *meta;
104ace6d6ecSYonghong Song 	struct udp_sock *udp_sk;
105ace6d6ecSYonghong Song 	uid_t uid __attribute__((aligned(8)));
106ace6d6ecSYonghong Song 	int bucket __attribute__((aligned(8)));
107ace6d6ecSYonghong Song } __attribute__((preserve_access_index));
108ace6d6ecSYonghong Song 
109ace6d6ecSYonghong Song struct udp6_sock {
110ace6d6ecSYonghong Song 	struct udp_sock	udp;
111ace6d6ecSYonghong Song 	struct ipv6_pinfo inet6;
112ace6d6ecSYonghong Song } __attribute__((preserve_access_index));
113363885d7SAndrii Nakryiko 
11404e92818SKuniyuki Iwashima struct bpf_iter__unix {
11504e92818SKuniyuki Iwashima 	struct bpf_iter_meta *meta;
11604e92818SKuniyuki Iwashima 	struct unix_sock *unix_sk;
11704e92818SKuniyuki Iwashima 	uid_t uid;
11804e92818SKuniyuki Iwashima } __attribute__((preserve_access_index));
11904e92818SKuniyuki Iwashima 
120363885d7SAndrii Nakryiko struct bpf_iter__bpf_map_elem {
121363885d7SAndrii Nakryiko 	struct bpf_iter_meta *meta;
122363885d7SAndrii Nakryiko 	struct bpf_map *map;
123363885d7SAndrii Nakryiko 	void *key;
124363885d7SAndrii Nakryiko 	void *value;
125363885d7SAndrii Nakryiko };
126363885d7SAndrii Nakryiko 
127363885d7SAndrii Nakryiko struct bpf_iter__bpf_sk_storage_map {
128363885d7SAndrii Nakryiko 	struct bpf_iter_meta *meta;
129363885d7SAndrii Nakryiko 	struct bpf_map *map;
130363885d7SAndrii Nakryiko 	struct sock *sk;
131363885d7SAndrii Nakryiko 	void *value;
132363885d7SAndrii Nakryiko };
1332f7de986SLorenz Bauer 
1342f7de986SLorenz Bauer struct bpf_iter__sockmap {
1352f7de986SLorenz Bauer 	struct bpf_iter_meta *meta;
1362f7de986SLorenz Bauer 	struct bpf_map *map;
1372f7de986SLorenz Bauer 	void *key;
1382f7de986SLorenz Bauer 	struct sock *sk;
1392f7de986SLorenz Bauer };
140cfe77683SAlan Maguire 
1415a9b8e2cSDmitrii Dolgov struct bpf_iter__bpf_link {
1425a9b8e2cSDmitrii Dolgov 	struct bpf_iter_meta *meta;
1435a9b8e2cSDmitrii Dolgov 	struct bpf_link *link;
1445a9b8e2cSDmitrii Dolgov };
1455a9b8e2cSDmitrii Dolgov 
146*fe0dd9d4SHao Luo struct bpf_iter__cgroup {
147*fe0dd9d4SHao Luo 	struct bpf_iter_meta *meta;
148*fe0dd9d4SHao Luo 	struct cgroup *cgroup;
149*fe0dd9d4SHao Luo } __attribute__((preserve_access_index));
150*fe0dd9d4SHao Luo 
151cfe77683SAlan Maguire struct btf_ptr {
152cfe77683SAlan Maguire 	void *ptr;
153cfe77683SAlan Maguire 	__u32 type_id;
154cfe77683SAlan Maguire 	__u32 flags;
155cfe77683SAlan Maguire };
156cfe77683SAlan Maguire 
157cfe77683SAlan Maguire enum {
158cfe77683SAlan Maguire 	BTF_F_COMPACT	=	(1ULL << 0),
159cfe77683SAlan Maguire 	BTF_F_NONAME	=	(1ULL << 1),
160cfe77683SAlan Maguire 	BTF_F_PTR_RAW	=	(1ULL << 2),
161cfe77683SAlan Maguire 	BTF_F_ZERO	=	(1ULL << 3),
162cfe77683SAlan Maguire };
163a9d2fae8SAlan Maguire 
164a9d2fae8SAlan Maguire struct bpf_iter__ksym {
165a9d2fae8SAlan Maguire 	struct bpf_iter_meta *meta;
166a9d2fae8SAlan Maguire 	struct kallsym_iter *ksym;
167a9d2fae8SAlan Maguire };
168