xref: /linux/tools/testing/selftests/bpf/progs/bpf_iter.h (revision ace6d6ec9e9e167047b6c8ca462a0830220640c2)
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
102767c977SYonghong Song #define bpf_iter__tcp bpf_iter__tcp___not_used
112767c977SYonghong Song #define tcp6_sock tcp6_sock___not_used
12*ace6d6ecSYonghong Song #define bpf_iter__udp bpf_iter__udp___not_used
13*ace6d6ecSYonghong Song #define udp6_sock udp6_sock___not_used
1484544f56SYonghong Song #include "vmlinux.h"
1584544f56SYonghong Song #undef bpf_iter_meta
1684544f56SYonghong Song #undef bpf_iter__bpf_map
1784544f56SYonghong Song #undef bpf_iter__ipv6_route
1884544f56SYonghong Song #undef bpf_iter__netlink
1984544f56SYonghong Song #undef bpf_iter__task
2084544f56SYonghong Song #undef bpf_iter__task_file
212767c977SYonghong Song #undef bpf_iter__tcp
222767c977SYonghong Song #undef tcp6_sock
23*ace6d6ecSYonghong Song #undef bpf_iter__udp
24*ace6d6ecSYonghong Song #undef udp6_sock
2584544f56SYonghong Song 
2684544f56SYonghong Song struct bpf_iter_meta {
2784544f56SYonghong Song 	struct seq_file *seq;
2884544f56SYonghong Song 	__u64 session_id;
2984544f56SYonghong Song 	__u64 seq_num;
3084544f56SYonghong Song } __attribute__((preserve_access_index));
3184544f56SYonghong Song 
3284544f56SYonghong Song struct bpf_iter__ipv6_route {
3384544f56SYonghong Song 	struct bpf_iter_meta *meta;
3484544f56SYonghong Song 	struct fib6_info *rt;
3584544f56SYonghong Song } __attribute__((preserve_access_index));
3684544f56SYonghong Song 
3784544f56SYonghong Song struct bpf_iter__netlink {
3884544f56SYonghong Song 	struct bpf_iter_meta *meta;
3984544f56SYonghong Song 	struct netlink_sock *sk;
4084544f56SYonghong Song } __attribute__((preserve_access_index));
4184544f56SYonghong Song 
4284544f56SYonghong Song struct bpf_iter__task {
4384544f56SYonghong Song 	struct bpf_iter_meta *meta;
4484544f56SYonghong Song 	struct task_struct *task;
4584544f56SYonghong Song } __attribute__((preserve_access_index));
4684544f56SYonghong Song 
4784544f56SYonghong Song struct bpf_iter__task_file {
4884544f56SYonghong Song 	struct bpf_iter_meta *meta;
4984544f56SYonghong Song 	struct task_struct *task;
5084544f56SYonghong Song 	__u32 fd;
5184544f56SYonghong Song 	struct file *file;
5284544f56SYonghong Song } __attribute__((preserve_access_index));
5384544f56SYonghong Song 
5484544f56SYonghong Song struct bpf_iter__bpf_map {
5584544f56SYonghong Song 	struct bpf_iter_meta *meta;
5684544f56SYonghong Song 	struct bpf_map *map;
5784544f56SYonghong Song } __attribute__((preserve_access_index));
582767c977SYonghong Song 
592767c977SYonghong Song struct bpf_iter__tcp {
602767c977SYonghong Song 	struct bpf_iter_meta *meta;
612767c977SYonghong Song 	struct sock_common *sk_common;
622767c977SYonghong Song 	uid_t uid;
632767c977SYonghong Song } __attribute__((preserve_access_index));
642767c977SYonghong Song 
652767c977SYonghong Song struct tcp6_sock {
662767c977SYonghong Song 	struct tcp_sock	tcp;
672767c977SYonghong Song 	struct ipv6_pinfo inet6;
682767c977SYonghong Song } __attribute__((preserve_access_index));
69*ace6d6ecSYonghong Song 
70*ace6d6ecSYonghong Song struct bpf_iter__udp {
71*ace6d6ecSYonghong Song 	struct bpf_iter_meta *meta;
72*ace6d6ecSYonghong Song 	struct udp_sock *udp_sk;
73*ace6d6ecSYonghong Song 	uid_t uid __attribute__((aligned(8)));
74*ace6d6ecSYonghong Song 	int bucket __attribute__((aligned(8)));
75*ace6d6ecSYonghong Song } __attribute__((preserve_access_index));
76*ace6d6ecSYonghong Song 
77*ace6d6ecSYonghong Song struct udp6_sock {
78*ace6d6ecSYonghong Song 	struct udp_sock	udp;
79*ace6d6ecSYonghong Song 	struct ipv6_pinfo inet6;
80*ace6d6ecSYonghong Song } __attribute__((preserve_access_index));
81