1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2020 Facebook */
3 /* "undefine" structs in vmlinux.h, because we "override" them below */
4 #define bpf_iter_meta bpf_iter_meta___not_used
5 #define bpf_iter__bpf_map bpf_iter__bpf_map___not_used
6 #define bpf_iter__ipv6_route bpf_iter__ipv6_route___not_used
7 #define bpf_iter__netlink bpf_iter__netlink___not_used
8 #define bpf_iter__task bpf_iter__task___not_used
9 #define bpf_iter__task_file bpf_iter__task_file___not_used
10 #define bpf_iter__tcp bpf_iter__tcp___not_used
11 #define tcp6_sock tcp6_sock___not_used
12 #define bpf_iter__udp bpf_iter__udp___not_used
13 #define udp6_sock udp6_sock___not_used
14 #define bpf_iter__bpf_map_elem bpf_iter__bpf_map_elem___not_used
15 #define bpf_iter__bpf_sk_storage_map bpf_iter__bpf_sk_storage_map___not_used
16 #define bpf_iter__sockmap bpf_iter__sockmap___not_used
17 #define btf_ptr btf_ptr___not_used
18 #define BTF_F_COMPACT BTF_F_COMPACT___not_used
19 #define BTF_F_NONAME BTF_F_NONAME___not_used
20 #define BTF_F_PTR_RAW BTF_F_PTR_RAW___not_used
21 #define BTF_F_ZERO BTF_F_ZERO___not_used
22 #include "vmlinux.h"
23 #undef bpf_iter_meta
24 #undef bpf_iter__bpf_map
25 #undef bpf_iter__ipv6_route
26 #undef bpf_iter__netlink
27 #undef bpf_iter__task
28 #undef bpf_iter__task_file
29 #undef bpf_iter__tcp
30 #undef tcp6_sock
31 #undef bpf_iter__udp
32 #undef udp6_sock
33 #undef bpf_iter__bpf_map_elem
34 #undef bpf_iter__bpf_sk_storage_map
35 #undef bpf_iter__sockmap
36 #undef btf_ptr
37 #undef BTF_F_COMPACT
38 #undef BTF_F_NONAME
39 #undef BTF_F_PTR_RAW
40 #undef BTF_F_ZERO
41 
42 struct bpf_iter_meta {
43 	struct seq_file *seq;
44 	__u64 session_id;
45 	__u64 seq_num;
46 } __attribute__((preserve_access_index));
47 
48 struct bpf_iter__ipv6_route {
49 	struct bpf_iter_meta *meta;
50 	struct fib6_info *rt;
51 } __attribute__((preserve_access_index));
52 
53 struct bpf_iter__netlink {
54 	struct bpf_iter_meta *meta;
55 	struct netlink_sock *sk;
56 } __attribute__((preserve_access_index));
57 
58 struct bpf_iter__task {
59 	struct bpf_iter_meta *meta;
60 	struct task_struct *task;
61 } __attribute__((preserve_access_index));
62 
63 struct bpf_iter__task_file {
64 	struct bpf_iter_meta *meta;
65 	struct task_struct *task;
66 	__u32 fd;
67 	struct file *file;
68 } __attribute__((preserve_access_index));
69 
70 struct bpf_iter__bpf_map {
71 	struct bpf_iter_meta *meta;
72 	struct bpf_map *map;
73 } __attribute__((preserve_access_index));
74 
75 struct bpf_iter__tcp {
76 	struct bpf_iter_meta *meta;
77 	struct sock_common *sk_common;
78 	uid_t uid;
79 } __attribute__((preserve_access_index));
80 
81 struct tcp6_sock {
82 	struct tcp_sock	tcp;
83 	struct ipv6_pinfo inet6;
84 } __attribute__((preserve_access_index));
85 
86 struct bpf_iter__udp {
87 	struct bpf_iter_meta *meta;
88 	struct udp_sock *udp_sk;
89 	uid_t uid __attribute__((aligned(8)));
90 	int bucket __attribute__((aligned(8)));
91 } __attribute__((preserve_access_index));
92 
93 struct udp6_sock {
94 	struct udp_sock	udp;
95 	struct ipv6_pinfo inet6;
96 } __attribute__((preserve_access_index));
97 
98 struct bpf_iter__bpf_map_elem {
99 	struct bpf_iter_meta *meta;
100 	struct bpf_map *map;
101 	void *key;
102 	void *value;
103 };
104 
105 struct bpf_iter__bpf_sk_storage_map {
106 	struct bpf_iter_meta *meta;
107 	struct bpf_map *map;
108 	struct sock *sk;
109 	void *value;
110 };
111 
112 struct bpf_iter__sockmap {
113 	struct bpf_iter_meta *meta;
114 	struct bpf_map *map;
115 	void *key;
116 	struct sock *sk;
117 };
118 
119 struct btf_ptr {
120 	void *ptr;
121 	__u32 type_id;
122 	__u32 flags;
123 };
124 
125 enum {
126 	BTF_F_COMPACT	=	(1ULL << 0),
127 	BTF_F_NONAME	=	(1ULL << 1),
128 	BTF_F_PTR_RAW	=	(1ULL << 2),
129 	BTF_F_ZERO	=	(1ULL << 3),
130 };
131