github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/internal/sys/types.go (about) 1 // Code generated by internal/cmd/gentypes; DO NOT EDIT. 2 3 package sys 4 5 import ( 6 "unsafe" 7 ) 8 9 type AdjRoomMode uint32 10 11 const ( 12 BPF_ADJ_ROOM_NET AdjRoomMode = 0 13 BPF_ADJ_ROOM_MAC AdjRoomMode = 1 14 ) 15 16 type AttachType uint32 17 18 const ( 19 BPF_CGROUP_INET_INGRESS AttachType = 0 20 BPF_CGROUP_INET_EGRESS AttachType = 1 21 BPF_CGROUP_INET_SOCK_CREATE AttachType = 2 22 BPF_CGROUP_SOCK_OPS AttachType = 3 23 BPF_SK_SKB_STREAM_PARSER AttachType = 4 24 BPF_SK_SKB_STREAM_VERDICT AttachType = 5 25 BPF_CGROUP_DEVICE AttachType = 6 26 BPF_SK_MSG_VERDICT AttachType = 7 27 BPF_CGROUP_INET4_BIND AttachType = 8 28 BPF_CGROUP_INET6_BIND AttachType = 9 29 BPF_CGROUP_INET4_CONNECT AttachType = 10 30 BPF_CGROUP_INET6_CONNECT AttachType = 11 31 BPF_CGROUP_INET4_POST_BIND AttachType = 12 32 BPF_CGROUP_INET6_POST_BIND AttachType = 13 33 BPF_CGROUP_UDP4_SENDMSG AttachType = 14 34 BPF_CGROUP_UDP6_SENDMSG AttachType = 15 35 BPF_LIRC_MODE2 AttachType = 16 36 BPF_FLOW_DISSECTOR AttachType = 17 37 BPF_CGROUP_SYSCTL AttachType = 18 38 BPF_CGROUP_UDP4_RECVMSG AttachType = 19 39 BPF_CGROUP_UDP6_RECVMSG AttachType = 20 40 BPF_CGROUP_GETSOCKOPT AttachType = 21 41 BPF_CGROUP_SETSOCKOPT AttachType = 22 42 BPF_TRACE_RAW_TP AttachType = 23 43 BPF_TRACE_FENTRY AttachType = 24 44 BPF_TRACE_FEXIT AttachType = 25 45 BPF_MODIFY_RETURN AttachType = 26 46 BPF_LSM_MAC AttachType = 27 47 BPF_TRACE_ITER AttachType = 28 48 BPF_CGROUP_INET4_GETPEERNAME AttachType = 29 49 BPF_CGROUP_INET6_GETPEERNAME AttachType = 30 50 BPF_CGROUP_INET4_GETSOCKNAME AttachType = 31 51 BPF_CGROUP_INET6_GETSOCKNAME AttachType = 32 52 BPF_XDP_DEVMAP AttachType = 33 53 BPF_CGROUP_INET_SOCK_RELEASE AttachType = 34 54 BPF_XDP_CPUMAP AttachType = 35 55 BPF_SK_LOOKUP AttachType = 36 56 BPF_XDP AttachType = 37 57 BPF_SK_SKB_VERDICT AttachType = 38 58 BPF_SK_REUSEPORT_SELECT AttachType = 39 59 BPF_SK_REUSEPORT_SELECT_OR_MIGRATE AttachType = 40 60 BPF_PERF_EVENT AttachType = 41 61 BPF_TRACE_KPROBE_MULTI AttachType = 42 62 BPF_LSM_CGROUP AttachType = 43 63 BPF_STRUCT_OPS AttachType = 44 64 BPF_NETFILTER AttachType = 45 65 BPF_TCX_INGRESS AttachType = 46 66 BPF_TCX_EGRESS AttachType = 47 67 BPF_TRACE_UPROBE_MULTI AttachType = 48 68 BPF_CGROUP_UNIX_CONNECT AttachType = 49 69 BPF_CGROUP_UNIX_SENDMSG AttachType = 50 70 BPF_CGROUP_UNIX_RECVMSG AttachType = 51 71 BPF_CGROUP_UNIX_GETPEERNAME AttachType = 52 72 BPF_CGROUP_UNIX_GETSOCKNAME AttachType = 53 73 BPF_NETKIT_PRIMARY AttachType = 54 74 BPF_NETKIT_PEER AttachType = 55 75 __MAX_BPF_ATTACH_TYPE AttachType = 56 76 ) 77 78 type Cmd uint32 79 80 const ( 81 BPF_MAP_CREATE Cmd = 0 82 BPF_MAP_LOOKUP_ELEM Cmd = 1 83 BPF_MAP_UPDATE_ELEM Cmd = 2 84 BPF_MAP_DELETE_ELEM Cmd = 3 85 BPF_MAP_GET_NEXT_KEY Cmd = 4 86 BPF_PROG_LOAD Cmd = 5 87 BPF_OBJ_PIN Cmd = 6 88 BPF_OBJ_GET Cmd = 7 89 BPF_PROG_ATTACH Cmd = 8 90 BPF_PROG_DETACH Cmd = 9 91 BPF_PROG_TEST_RUN Cmd = 10 92 BPF_PROG_RUN Cmd = 10 93 BPF_PROG_GET_NEXT_ID Cmd = 11 94 BPF_MAP_GET_NEXT_ID Cmd = 12 95 BPF_PROG_GET_FD_BY_ID Cmd = 13 96 BPF_MAP_GET_FD_BY_ID Cmd = 14 97 BPF_OBJ_GET_INFO_BY_FD Cmd = 15 98 BPF_PROG_QUERY Cmd = 16 99 BPF_RAW_TRACEPOINT_OPEN Cmd = 17 100 BPF_BTF_LOAD Cmd = 18 101 BPF_BTF_GET_FD_BY_ID Cmd = 19 102 BPF_TASK_FD_QUERY Cmd = 20 103 BPF_MAP_LOOKUP_AND_DELETE_ELEM Cmd = 21 104 BPF_MAP_FREEZE Cmd = 22 105 BPF_BTF_GET_NEXT_ID Cmd = 23 106 BPF_MAP_LOOKUP_BATCH Cmd = 24 107 BPF_MAP_LOOKUP_AND_DELETE_BATCH Cmd = 25 108 BPF_MAP_UPDATE_BATCH Cmd = 26 109 BPF_MAP_DELETE_BATCH Cmd = 27 110 BPF_LINK_CREATE Cmd = 28 111 BPF_LINK_UPDATE Cmd = 29 112 BPF_LINK_GET_FD_BY_ID Cmd = 30 113 BPF_LINK_GET_NEXT_ID Cmd = 31 114 BPF_ENABLE_STATS Cmd = 32 115 BPF_ITER_CREATE Cmd = 33 116 BPF_LINK_DETACH Cmd = 34 117 BPF_PROG_BIND_MAP Cmd = 35 118 ) 119 120 type FunctionId uint32 121 122 const ( 123 BPF_FUNC_unspec FunctionId = 0 124 BPF_FUNC_map_lookup_elem FunctionId = 1 125 BPF_FUNC_map_update_elem FunctionId = 2 126 BPF_FUNC_map_delete_elem FunctionId = 3 127 BPF_FUNC_probe_read FunctionId = 4 128 BPF_FUNC_ktime_get_ns FunctionId = 5 129 BPF_FUNC_trace_printk FunctionId = 6 130 BPF_FUNC_get_prandom_u32 FunctionId = 7 131 BPF_FUNC_get_smp_processor_id FunctionId = 8 132 BPF_FUNC_skb_store_bytes FunctionId = 9 133 BPF_FUNC_l3_csum_replace FunctionId = 10 134 BPF_FUNC_l4_csum_replace FunctionId = 11 135 BPF_FUNC_tail_call FunctionId = 12 136 BPF_FUNC_clone_redirect FunctionId = 13 137 BPF_FUNC_get_current_pid_tgid FunctionId = 14 138 BPF_FUNC_get_current_uid_gid FunctionId = 15 139 BPF_FUNC_get_current_comm FunctionId = 16 140 BPF_FUNC_get_cgroup_classid FunctionId = 17 141 BPF_FUNC_skb_vlan_push FunctionId = 18 142 BPF_FUNC_skb_vlan_pop FunctionId = 19 143 BPF_FUNC_skb_get_tunnel_key FunctionId = 20 144 BPF_FUNC_skb_set_tunnel_key FunctionId = 21 145 BPF_FUNC_perf_event_read FunctionId = 22 146 BPF_FUNC_redirect FunctionId = 23 147 BPF_FUNC_get_route_realm FunctionId = 24 148 BPF_FUNC_perf_event_output FunctionId = 25 149 BPF_FUNC_skb_load_bytes FunctionId = 26 150 BPF_FUNC_get_stackid FunctionId = 27 151 BPF_FUNC_csum_diff FunctionId = 28 152 BPF_FUNC_skb_get_tunnel_opt FunctionId = 29 153 BPF_FUNC_skb_set_tunnel_opt FunctionId = 30 154 BPF_FUNC_skb_change_proto FunctionId = 31 155 BPF_FUNC_skb_change_type FunctionId = 32 156 BPF_FUNC_skb_under_cgroup FunctionId = 33 157 BPF_FUNC_get_hash_recalc FunctionId = 34 158 BPF_FUNC_get_current_task FunctionId = 35 159 BPF_FUNC_probe_write_user FunctionId = 36 160 BPF_FUNC_current_task_under_cgroup FunctionId = 37 161 BPF_FUNC_skb_change_tail FunctionId = 38 162 BPF_FUNC_skb_pull_data FunctionId = 39 163 BPF_FUNC_csum_update FunctionId = 40 164 BPF_FUNC_set_hash_invalid FunctionId = 41 165 BPF_FUNC_get_numa_node_id FunctionId = 42 166 BPF_FUNC_skb_change_head FunctionId = 43 167 BPF_FUNC_xdp_adjust_head FunctionId = 44 168 BPF_FUNC_probe_read_str FunctionId = 45 169 BPF_FUNC_get_socket_cookie FunctionId = 46 170 BPF_FUNC_get_socket_uid FunctionId = 47 171 BPF_FUNC_set_hash FunctionId = 48 172 BPF_FUNC_setsockopt FunctionId = 49 173 BPF_FUNC_skb_adjust_room FunctionId = 50 174 BPF_FUNC_redirect_map FunctionId = 51 175 BPF_FUNC_sk_redirect_map FunctionId = 52 176 BPF_FUNC_sock_map_update FunctionId = 53 177 BPF_FUNC_xdp_adjust_meta FunctionId = 54 178 BPF_FUNC_perf_event_read_value FunctionId = 55 179 BPF_FUNC_perf_prog_read_value FunctionId = 56 180 BPF_FUNC_getsockopt FunctionId = 57 181 BPF_FUNC_override_return FunctionId = 58 182 BPF_FUNC_sock_ops_cb_flags_set FunctionId = 59 183 BPF_FUNC_msg_redirect_map FunctionId = 60 184 BPF_FUNC_msg_apply_bytes FunctionId = 61 185 BPF_FUNC_msg_cork_bytes FunctionId = 62 186 BPF_FUNC_msg_pull_data FunctionId = 63 187 BPF_FUNC_bind FunctionId = 64 188 BPF_FUNC_xdp_adjust_tail FunctionId = 65 189 BPF_FUNC_skb_get_xfrm_state FunctionId = 66 190 BPF_FUNC_get_stack FunctionId = 67 191 BPF_FUNC_skb_load_bytes_relative FunctionId = 68 192 BPF_FUNC_fib_lookup FunctionId = 69 193 BPF_FUNC_sock_hash_update FunctionId = 70 194 BPF_FUNC_msg_redirect_hash FunctionId = 71 195 BPF_FUNC_sk_redirect_hash FunctionId = 72 196 BPF_FUNC_lwt_push_encap FunctionId = 73 197 BPF_FUNC_lwt_seg6_store_bytes FunctionId = 74 198 BPF_FUNC_lwt_seg6_adjust_srh FunctionId = 75 199 BPF_FUNC_lwt_seg6_action FunctionId = 76 200 BPF_FUNC_rc_repeat FunctionId = 77 201 BPF_FUNC_rc_keydown FunctionId = 78 202 BPF_FUNC_skb_cgroup_id FunctionId = 79 203 BPF_FUNC_get_current_cgroup_id FunctionId = 80 204 BPF_FUNC_get_local_storage FunctionId = 81 205 BPF_FUNC_sk_select_reuseport FunctionId = 82 206 BPF_FUNC_skb_ancestor_cgroup_id FunctionId = 83 207 BPF_FUNC_sk_lookup_tcp FunctionId = 84 208 BPF_FUNC_sk_lookup_udp FunctionId = 85 209 BPF_FUNC_sk_release FunctionId = 86 210 BPF_FUNC_map_push_elem FunctionId = 87 211 BPF_FUNC_map_pop_elem FunctionId = 88 212 BPF_FUNC_map_peek_elem FunctionId = 89 213 BPF_FUNC_msg_push_data FunctionId = 90 214 BPF_FUNC_msg_pop_data FunctionId = 91 215 BPF_FUNC_rc_pointer_rel FunctionId = 92 216 BPF_FUNC_spin_lock FunctionId = 93 217 BPF_FUNC_spin_unlock FunctionId = 94 218 BPF_FUNC_sk_fullsock FunctionId = 95 219 BPF_FUNC_tcp_sock FunctionId = 96 220 BPF_FUNC_skb_ecn_set_ce FunctionId = 97 221 BPF_FUNC_get_listener_sock FunctionId = 98 222 BPF_FUNC_skc_lookup_tcp FunctionId = 99 223 BPF_FUNC_tcp_check_syncookie FunctionId = 100 224 BPF_FUNC_sysctl_get_name FunctionId = 101 225 BPF_FUNC_sysctl_get_current_value FunctionId = 102 226 BPF_FUNC_sysctl_get_new_value FunctionId = 103 227 BPF_FUNC_sysctl_set_new_value FunctionId = 104 228 BPF_FUNC_strtol FunctionId = 105 229 BPF_FUNC_strtoul FunctionId = 106 230 BPF_FUNC_sk_storage_get FunctionId = 107 231 BPF_FUNC_sk_storage_delete FunctionId = 108 232 BPF_FUNC_send_signal FunctionId = 109 233 BPF_FUNC_tcp_gen_syncookie FunctionId = 110 234 BPF_FUNC_skb_output FunctionId = 111 235 BPF_FUNC_probe_read_user FunctionId = 112 236 BPF_FUNC_probe_read_kernel FunctionId = 113 237 BPF_FUNC_probe_read_user_str FunctionId = 114 238 BPF_FUNC_probe_read_kernel_str FunctionId = 115 239 BPF_FUNC_tcp_send_ack FunctionId = 116 240 BPF_FUNC_send_signal_thread FunctionId = 117 241 BPF_FUNC_jiffies64 FunctionId = 118 242 BPF_FUNC_read_branch_records FunctionId = 119 243 BPF_FUNC_get_ns_current_pid_tgid FunctionId = 120 244 BPF_FUNC_xdp_output FunctionId = 121 245 BPF_FUNC_get_netns_cookie FunctionId = 122 246 BPF_FUNC_get_current_ancestor_cgroup_id FunctionId = 123 247 BPF_FUNC_sk_assign FunctionId = 124 248 BPF_FUNC_ktime_get_boot_ns FunctionId = 125 249 BPF_FUNC_seq_printf FunctionId = 126 250 BPF_FUNC_seq_write FunctionId = 127 251 BPF_FUNC_sk_cgroup_id FunctionId = 128 252 BPF_FUNC_sk_ancestor_cgroup_id FunctionId = 129 253 BPF_FUNC_ringbuf_output FunctionId = 130 254 BPF_FUNC_ringbuf_reserve FunctionId = 131 255 BPF_FUNC_ringbuf_submit FunctionId = 132 256 BPF_FUNC_ringbuf_discard FunctionId = 133 257 BPF_FUNC_ringbuf_query FunctionId = 134 258 BPF_FUNC_csum_level FunctionId = 135 259 BPF_FUNC_skc_to_tcp6_sock FunctionId = 136 260 BPF_FUNC_skc_to_tcp_sock FunctionId = 137 261 BPF_FUNC_skc_to_tcp_timewait_sock FunctionId = 138 262 BPF_FUNC_skc_to_tcp_request_sock FunctionId = 139 263 BPF_FUNC_skc_to_udp6_sock FunctionId = 140 264 BPF_FUNC_get_task_stack FunctionId = 141 265 BPF_FUNC_load_hdr_opt FunctionId = 142 266 BPF_FUNC_store_hdr_opt FunctionId = 143 267 BPF_FUNC_reserve_hdr_opt FunctionId = 144 268 BPF_FUNC_inode_storage_get FunctionId = 145 269 BPF_FUNC_inode_storage_delete FunctionId = 146 270 BPF_FUNC_d_path FunctionId = 147 271 BPF_FUNC_copy_from_user FunctionId = 148 272 BPF_FUNC_snprintf_btf FunctionId = 149 273 BPF_FUNC_seq_printf_btf FunctionId = 150 274 BPF_FUNC_skb_cgroup_classid FunctionId = 151 275 BPF_FUNC_redirect_neigh FunctionId = 152 276 BPF_FUNC_per_cpu_ptr FunctionId = 153 277 BPF_FUNC_this_cpu_ptr FunctionId = 154 278 BPF_FUNC_redirect_peer FunctionId = 155 279 BPF_FUNC_task_storage_get FunctionId = 156 280 BPF_FUNC_task_storage_delete FunctionId = 157 281 BPF_FUNC_get_current_task_btf FunctionId = 158 282 BPF_FUNC_bprm_opts_set FunctionId = 159 283 BPF_FUNC_ktime_get_coarse_ns FunctionId = 160 284 BPF_FUNC_ima_inode_hash FunctionId = 161 285 BPF_FUNC_sock_from_file FunctionId = 162 286 BPF_FUNC_check_mtu FunctionId = 163 287 BPF_FUNC_for_each_map_elem FunctionId = 164 288 BPF_FUNC_snprintf FunctionId = 165 289 BPF_FUNC_sys_bpf FunctionId = 166 290 BPF_FUNC_btf_find_by_name_kind FunctionId = 167 291 BPF_FUNC_sys_close FunctionId = 168 292 BPF_FUNC_timer_init FunctionId = 169 293 BPF_FUNC_timer_set_callback FunctionId = 170 294 BPF_FUNC_timer_start FunctionId = 171 295 BPF_FUNC_timer_cancel FunctionId = 172 296 BPF_FUNC_get_func_ip FunctionId = 173 297 BPF_FUNC_get_attach_cookie FunctionId = 174 298 BPF_FUNC_task_pt_regs FunctionId = 175 299 BPF_FUNC_get_branch_snapshot FunctionId = 176 300 BPF_FUNC_trace_vprintk FunctionId = 177 301 BPF_FUNC_skc_to_unix_sock FunctionId = 178 302 BPF_FUNC_kallsyms_lookup_name FunctionId = 179 303 BPF_FUNC_find_vma FunctionId = 180 304 BPF_FUNC_loop FunctionId = 181 305 BPF_FUNC_strncmp FunctionId = 182 306 BPF_FUNC_get_func_arg FunctionId = 183 307 BPF_FUNC_get_func_ret FunctionId = 184 308 BPF_FUNC_get_func_arg_cnt FunctionId = 185 309 BPF_FUNC_get_retval FunctionId = 186 310 BPF_FUNC_set_retval FunctionId = 187 311 BPF_FUNC_xdp_get_buff_len FunctionId = 188 312 BPF_FUNC_xdp_load_bytes FunctionId = 189 313 BPF_FUNC_xdp_store_bytes FunctionId = 190 314 BPF_FUNC_copy_from_user_task FunctionId = 191 315 BPF_FUNC_skb_set_tstamp FunctionId = 192 316 BPF_FUNC_ima_file_hash FunctionId = 193 317 BPF_FUNC_kptr_xchg FunctionId = 194 318 BPF_FUNC_map_lookup_percpu_elem FunctionId = 195 319 BPF_FUNC_skc_to_mptcp_sock FunctionId = 196 320 BPF_FUNC_dynptr_from_mem FunctionId = 197 321 BPF_FUNC_ringbuf_reserve_dynptr FunctionId = 198 322 BPF_FUNC_ringbuf_submit_dynptr FunctionId = 199 323 BPF_FUNC_ringbuf_discard_dynptr FunctionId = 200 324 BPF_FUNC_dynptr_read FunctionId = 201 325 BPF_FUNC_dynptr_write FunctionId = 202 326 BPF_FUNC_dynptr_data FunctionId = 203 327 BPF_FUNC_tcp_raw_gen_syncookie_ipv4 FunctionId = 204 328 BPF_FUNC_tcp_raw_gen_syncookie_ipv6 FunctionId = 205 329 BPF_FUNC_tcp_raw_check_syncookie_ipv4 FunctionId = 206 330 BPF_FUNC_tcp_raw_check_syncookie_ipv6 FunctionId = 207 331 BPF_FUNC_ktime_get_tai_ns FunctionId = 208 332 BPF_FUNC_user_ringbuf_drain FunctionId = 209 333 BPF_FUNC_cgrp_storage_get FunctionId = 210 334 BPF_FUNC_cgrp_storage_delete FunctionId = 211 335 __BPF_FUNC_MAX_ID FunctionId = 212 336 ) 337 338 type HdrStartOff uint32 339 340 const ( 341 BPF_HDR_START_MAC HdrStartOff = 0 342 BPF_HDR_START_NET HdrStartOff = 1 343 ) 344 345 type LinkType uint32 346 347 const ( 348 BPF_LINK_TYPE_UNSPEC LinkType = 0 349 BPF_LINK_TYPE_RAW_TRACEPOINT LinkType = 1 350 BPF_LINK_TYPE_TRACING LinkType = 2 351 BPF_LINK_TYPE_CGROUP LinkType = 3 352 BPF_LINK_TYPE_ITER LinkType = 4 353 BPF_LINK_TYPE_NETNS LinkType = 5 354 BPF_LINK_TYPE_XDP LinkType = 6 355 BPF_LINK_TYPE_PERF_EVENT LinkType = 7 356 BPF_LINK_TYPE_KPROBE_MULTI LinkType = 8 357 BPF_LINK_TYPE_STRUCT_OPS LinkType = 9 358 BPF_LINK_TYPE_NETFILTER LinkType = 10 359 BPF_LINK_TYPE_TCX LinkType = 11 360 BPF_LINK_TYPE_UPROBE_MULTI LinkType = 12 361 BPF_LINK_TYPE_NETKIT LinkType = 13 362 __MAX_BPF_LINK_TYPE LinkType = 14 363 ) 364 365 type MapType uint32 366 367 const ( 368 BPF_MAP_TYPE_UNSPEC MapType = 0 369 BPF_MAP_TYPE_HASH MapType = 1 370 BPF_MAP_TYPE_ARRAY MapType = 2 371 BPF_MAP_TYPE_PROG_ARRAY MapType = 3 372 BPF_MAP_TYPE_PERF_EVENT_ARRAY MapType = 4 373 BPF_MAP_TYPE_PERCPU_HASH MapType = 5 374 BPF_MAP_TYPE_PERCPU_ARRAY MapType = 6 375 BPF_MAP_TYPE_STACK_TRACE MapType = 7 376 BPF_MAP_TYPE_CGROUP_ARRAY MapType = 8 377 BPF_MAP_TYPE_LRU_HASH MapType = 9 378 BPF_MAP_TYPE_LRU_PERCPU_HASH MapType = 10 379 BPF_MAP_TYPE_LPM_TRIE MapType = 11 380 BPF_MAP_TYPE_ARRAY_OF_MAPS MapType = 12 381 BPF_MAP_TYPE_HASH_OF_MAPS MapType = 13 382 BPF_MAP_TYPE_DEVMAP MapType = 14 383 BPF_MAP_TYPE_SOCKMAP MapType = 15 384 BPF_MAP_TYPE_CPUMAP MapType = 16 385 BPF_MAP_TYPE_XSKMAP MapType = 17 386 BPF_MAP_TYPE_SOCKHASH MapType = 18 387 BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED MapType = 19 388 BPF_MAP_TYPE_CGROUP_STORAGE MapType = 19 389 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY MapType = 20 390 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED MapType = 21 391 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE MapType = 21 392 BPF_MAP_TYPE_QUEUE MapType = 22 393 BPF_MAP_TYPE_STACK MapType = 23 394 BPF_MAP_TYPE_SK_STORAGE MapType = 24 395 BPF_MAP_TYPE_DEVMAP_HASH MapType = 25 396 BPF_MAP_TYPE_STRUCT_OPS MapType = 26 397 BPF_MAP_TYPE_RINGBUF MapType = 27 398 BPF_MAP_TYPE_INODE_STORAGE MapType = 28 399 BPF_MAP_TYPE_TASK_STORAGE MapType = 29 400 BPF_MAP_TYPE_BLOOM_FILTER MapType = 30 401 BPF_MAP_TYPE_USER_RINGBUF MapType = 31 402 BPF_MAP_TYPE_CGRP_STORAGE MapType = 32 403 ) 404 405 type PerfEventType uint32 406 407 const ( 408 BPF_PERF_EVENT_UNSPEC PerfEventType = 0 409 BPF_PERF_EVENT_UPROBE PerfEventType = 1 410 BPF_PERF_EVENT_URETPROBE PerfEventType = 2 411 BPF_PERF_EVENT_KPROBE PerfEventType = 3 412 BPF_PERF_EVENT_KRETPROBE PerfEventType = 4 413 BPF_PERF_EVENT_TRACEPOINT PerfEventType = 5 414 BPF_PERF_EVENT_EVENT PerfEventType = 6 415 ) 416 417 type ProgType uint32 418 419 const ( 420 BPF_PROG_TYPE_UNSPEC ProgType = 0 421 BPF_PROG_TYPE_SOCKET_FILTER ProgType = 1 422 BPF_PROG_TYPE_KPROBE ProgType = 2 423 BPF_PROG_TYPE_SCHED_CLS ProgType = 3 424 BPF_PROG_TYPE_SCHED_ACT ProgType = 4 425 BPF_PROG_TYPE_TRACEPOINT ProgType = 5 426 BPF_PROG_TYPE_XDP ProgType = 6 427 BPF_PROG_TYPE_PERF_EVENT ProgType = 7 428 BPF_PROG_TYPE_CGROUP_SKB ProgType = 8 429 BPF_PROG_TYPE_CGROUP_SOCK ProgType = 9 430 BPF_PROG_TYPE_LWT_IN ProgType = 10 431 BPF_PROG_TYPE_LWT_OUT ProgType = 11 432 BPF_PROG_TYPE_LWT_XMIT ProgType = 12 433 BPF_PROG_TYPE_SOCK_OPS ProgType = 13 434 BPF_PROG_TYPE_SK_SKB ProgType = 14 435 BPF_PROG_TYPE_CGROUP_DEVICE ProgType = 15 436 BPF_PROG_TYPE_SK_MSG ProgType = 16 437 BPF_PROG_TYPE_RAW_TRACEPOINT ProgType = 17 438 BPF_PROG_TYPE_CGROUP_SOCK_ADDR ProgType = 18 439 BPF_PROG_TYPE_LWT_SEG6LOCAL ProgType = 19 440 BPF_PROG_TYPE_LIRC_MODE2 ProgType = 20 441 BPF_PROG_TYPE_SK_REUSEPORT ProgType = 21 442 BPF_PROG_TYPE_FLOW_DISSECTOR ProgType = 22 443 BPF_PROG_TYPE_CGROUP_SYSCTL ProgType = 23 444 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE ProgType = 24 445 BPF_PROG_TYPE_CGROUP_SOCKOPT ProgType = 25 446 BPF_PROG_TYPE_TRACING ProgType = 26 447 BPF_PROG_TYPE_STRUCT_OPS ProgType = 27 448 BPF_PROG_TYPE_EXT ProgType = 28 449 BPF_PROG_TYPE_LSM ProgType = 29 450 BPF_PROG_TYPE_SK_LOOKUP ProgType = 30 451 BPF_PROG_TYPE_SYSCALL ProgType = 31 452 BPF_PROG_TYPE_NETFILTER ProgType = 32 453 ) 454 455 type RetCode uint32 456 457 const ( 458 BPF_OK RetCode = 0 459 BPF_DROP RetCode = 2 460 BPF_REDIRECT RetCode = 7 461 BPF_LWT_REROUTE RetCode = 128 462 BPF_FLOW_DISSECTOR_CONTINUE RetCode = 129 463 ) 464 465 type SkAction uint32 466 467 const ( 468 SK_DROP SkAction = 0 469 SK_PASS SkAction = 1 470 ) 471 472 type StackBuildIdStatus uint32 473 474 const ( 475 BPF_STACK_BUILD_ID_EMPTY StackBuildIdStatus = 0 476 BPF_STACK_BUILD_ID_VALID StackBuildIdStatus = 1 477 BPF_STACK_BUILD_ID_IP StackBuildIdStatus = 2 478 ) 479 480 type StatsType uint32 481 482 const ( 483 BPF_STATS_RUN_TIME StatsType = 0 484 ) 485 486 type TcxActionBase int32 487 488 const ( 489 TCX_NEXT TcxActionBase = -1 490 TCX_PASS TcxActionBase = 0 491 TCX_DROP TcxActionBase = 2 492 TCX_REDIRECT TcxActionBase = 7 493 ) 494 495 type XdpAction uint32 496 497 const ( 498 XDP_ABORTED XdpAction = 0 499 XDP_DROP XdpAction = 1 500 XDP_PASS XdpAction = 2 501 XDP_TX XdpAction = 3 502 XDP_REDIRECT XdpAction = 4 503 ) 504 505 type BtfInfo struct { 506 Btf Pointer 507 BtfSize uint32 508 Id BTFID 509 Name Pointer 510 NameLen uint32 511 KernelBtf uint32 512 } 513 514 type FuncInfo struct { 515 InsnOff uint32 516 TypeId uint32 517 } 518 519 type LineInfo struct { 520 InsnOff uint32 521 FileNameOff uint32 522 LineOff uint32 523 LineCol uint32 524 } 525 526 type LinkInfo struct { 527 Type LinkType 528 Id LinkID 529 ProgId uint32 530 _ [4]byte 531 Extra [48]uint8 532 } 533 534 type MapInfo struct { 535 Type uint32 536 Id uint32 537 KeySize uint32 538 ValueSize uint32 539 MaxEntries uint32 540 MapFlags MapFlags 541 Name ObjName 542 Ifindex uint32 543 BtfVmlinuxValueTypeId TypeID 544 NetnsDev uint64 545 NetnsIno uint64 546 BtfId uint32 547 BtfKeyTypeId TypeID 548 BtfValueTypeId TypeID 549 _ [4]byte 550 MapExtra uint64 551 } 552 553 type ProgInfo struct { 554 Type uint32 555 Id uint32 556 Tag [8]uint8 557 JitedProgLen uint32 558 XlatedProgLen uint32 559 JitedProgInsns uint64 560 XlatedProgInsns Pointer 561 LoadTime uint64 562 CreatedByUid uint32 563 NrMapIds uint32 564 MapIds Pointer 565 Name ObjName 566 Ifindex uint32 567 _ [4]byte /* unsupported bitfield */ 568 NetnsDev uint64 569 NetnsIno uint64 570 NrJitedKsyms uint32 571 NrJitedFuncLens uint32 572 JitedKsyms uint64 573 JitedFuncLens uint64 574 BtfId BTFID 575 FuncInfoRecSize uint32 576 FuncInfo Pointer 577 NrFuncInfo uint32 578 NrLineInfo uint32 579 LineInfo Pointer 580 JitedLineInfo uint64 581 NrJitedLineInfo uint32 582 LineInfoRecSize uint32 583 JitedLineInfoRecSize uint32 584 NrProgTags uint32 585 ProgTags uint64 586 RunTimeNs uint64 587 RunCnt uint64 588 RecursionMisses uint64 589 VerifiedInsns uint32 590 AttachBtfObjId BTFID 591 AttachBtfId TypeID 592 _ [4]byte 593 } 594 595 type SkLookup struct { 596 Cookie uint64 597 Family uint32 598 Protocol uint32 599 RemoteIp4 [4]uint8 600 RemoteIp6 [16]uint8 601 RemotePort uint16 602 _ [2]byte 603 LocalIp4 [4]uint8 604 LocalIp6 [16]uint8 605 LocalPort uint32 606 IngressIfindex uint32 607 _ [4]byte 608 } 609 610 type XdpMd struct { 611 Data uint32 612 DataEnd uint32 613 DataMeta uint32 614 IngressIfindex uint32 615 RxQueueIndex uint32 616 EgressIfindex uint32 617 } 618 619 type BtfGetFdByIdAttr struct{ Id uint32 } 620 621 func BtfGetFdById(attr *BtfGetFdByIdAttr) (*FD, error) { 622 fd, err := BPF(BPF_BTF_GET_FD_BY_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 623 if err != nil { 624 return nil, err 625 } 626 return NewFD(int(fd)) 627 } 628 629 type BtfGetNextIdAttr struct { 630 Id BTFID 631 NextId BTFID 632 } 633 634 func BtfGetNextId(attr *BtfGetNextIdAttr) error { 635 _, err := BPF(BPF_BTF_GET_NEXT_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 636 return err 637 } 638 639 type BtfLoadAttr struct { 640 Btf Pointer 641 BtfLogBuf Pointer 642 BtfSize uint32 643 BtfLogSize uint32 644 BtfLogLevel uint32 645 BtfLogTrueSize uint32 646 } 647 648 func BtfLoad(attr *BtfLoadAttr) (*FD, error) { 649 fd, err := BPF(BPF_BTF_LOAD, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 650 if err != nil { 651 return nil, err 652 } 653 return NewFD(int(fd)) 654 } 655 656 type EnableStatsAttr struct{ Type uint32 } 657 658 func EnableStats(attr *EnableStatsAttr) (*FD, error) { 659 fd, err := BPF(BPF_ENABLE_STATS, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 660 if err != nil { 661 return nil, err 662 } 663 return NewFD(int(fd)) 664 } 665 666 type IterCreateAttr struct { 667 LinkFd uint32 668 Flags uint32 669 } 670 671 func IterCreate(attr *IterCreateAttr) (*FD, error) { 672 fd, err := BPF(BPF_ITER_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 673 if err != nil { 674 return nil, err 675 } 676 return NewFD(int(fd)) 677 } 678 679 type LinkCreateAttr struct { 680 ProgFd uint32 681 TargetFd uint32 682 AttachType AttachType 683 Flags uint32 684 TargetBtfId TypeID 685 _ [44]byte 686 } 687 688 func LinkCreate(attr *LinkCreateAttr) (*FD, error) { 689 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 690 if err != nil { 691 return nil, err 692 } 693 return NewFD(int(fd)) 694 } 695 696 type LinkCreateIterAttr struct { 697 ProgFd uint32 698 TargetFd uint32 699 AttachType AttachType 700 Flags uint32 701 IterInfo Pointer 702 IterInfoLen uint32 703 _ [36]byte 704 } 705 706 func LinkCreateIter(attr *LinkCreateIterAttr) (*FD, error) { 707 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 708 if err != nil { 709 return nil, err 710 } 711 return NewFD(int(fd)) 712 } 713 714 type LinkCreateKprobeMultiAttr struct { 715 ProgFd uint32 716 TargetFd uint32 717 AttachType AttachType 718 Flags uint32 719 KprobeMultiFlags uint32 720 Count uint32 721 Syms Pointer 722 Addrs Pointer 723 Cookies Pointer 724 _ [16]byte 725 } 726 727 func LinkCreateKprobeMulti(attr *LinkCreateKprobeMultiAttr) (*FD, error) { 728 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 729 if err != nil { 730 return nil, err 731 } 732 return NewFD(int(fd)) 733 } 734 735 type LinkCreateNetfilterAttr struct { 736 ProgFd uint32 737 TargetFd uint32 738 AttachType AttachType 739 Flags uint32 740 Pf uint32 741 Hooknum uint32 742 Priority int32 743 NetfilterFlags uint32 744 _ [32]byte 745 } 746 747 func LinkCreateNetfilter(attr *LinkCreateNetfilterAttr) (*FD, error) { 748 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 749 if err != nil { 750 return nil, err 751 } 752 return NewFD(int(fd)) 753 } 754 755 type LinkCreateNetkitAttr struct { 756 ProgFd uint32 757 TargetIfindex uint32 758 AttachType AttachType 759 Flags uint32 760 RelativeFdOrId uint32 761 _ [4]byte 762 ExpectedRevision uint64 763 _ [32]byte 764 } 765 766 func LinkCreateNetkit(attr *LinkCreateNetkitAttr) (*FD, error) { 767 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 768 if err != nil { 769 return nil, err 770 } 771 return NewFD(int(fd)) 772 } 773 774 type LinkCreatePerfEventAttr struct { 775 ProgFd uint32 776 TargetFd uint32 777 AttachType AttachType 778 Flags uint32 779 BpfCookie uint64 780 _ [40]byte 781 } 782 783 func LinkCreatePerfEvent(attr *LinkCreatePerfEventAttr) (*FD, error) { 784 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 785 if err != nil { 786 return nil, err 787 } 788 return NewFD(int(fd)) 789 } 790 791 type LinkCreateTcxAttr struct { 792 ProgFd uint32 793 TargetIfindex uint32 794 AttachType AttachType 795 Flags uint32 796 RelativeFdOrId uint32 797 _ [4]byte 798 ExpectedRevision uint64 799 _ [32]byte 800 } 801 802 func LinkCreateTcx(attr *LinkCreateTcxAttr) (*FD, error) { 803 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 804 if err != nil { 805 return nil, err 806 } 807 return NewFD(int(fd)) 808 } 809 810 type LinkCreateTracingAttr struct { 811 ProgFd uint32 812 TargetFd uint32 813 AttachType AttachType 814 Flags uint32 815 TargetBtfId BTFID 816 _ [4]byte 817 Cookie uint64 818 _ [32]byte 819 } 820 821 func LinkCreateTracing(attr *LinkCreateTracingAttr) (*FD, error) { 822 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 823 if err != nil { 824 return nil, err 825 } 826 return NewFD(int(fd)) 827 } 828 829 type LinkCreateUprobeMultiAttr struct { 830 ProgFd uint32 831 TargetFd uint32 832 AttachType AttachType 833 Flags uint32 834 Path Pointer 835 Offsets Pointer 836 RefCtrOffsets Pointer 837 Cookies Pointer 838 Count uint32 839 UprobeMultiFlags uint32 840 Pid uint32 841 _ [4]byte 842 } 843 844 func LinkCreateUprobeMulti(attr *LinkCreateUprobeMultiAttr) (*FD, error) { 845 fd, err := BPF(BPF_LINK_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 846 if err != nil { 847 return nil, err 848 } 849 return NewFD(int(fd)) 850 } 851 852 type LinkGetFdByIdAttr struct{ Id LinkID } 853 854 func LinkGetFdById(attr *LinkGetFdByIdAttr) (*FD, error) { 855 fd, err := BPF(BPF_LINK_GET_FD_BY_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 856 if err != nil { 857 return nil, err 858 } 859 return NewFD(int(fd)) 860 } 861 862 type LinkGetNextIdAttr struct { 863 Id LinkID 864 NextId LinkID 865 } 866 867 func LinkGetNextId(attr *LinkGetNextIdAttr) error { 868 _, err := BPF(BPF_LINK_GET_NEXT_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 869 return err 870 } 871 872 type LinkUpdateAttr struct { 873 LinkFd uint32 874 NewProgFd uint32 875 Flags uint32 876 OldProgFd uint32 877 } 878 879 func LinkUpdate(attr *LinkUpdateAttr) error { 880 _, err := BPF(BPF_LINK_UPDATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 881 return err 882 } 883 884 type MapCreateAttr struct { 885 MapType MapType 886 KeySize uint32 887 ValueSize uint32 888 MaxEntries uint32 889 MapFlags MapFlags 890 InnerMapFd uint32 891 NumaNode uint32 892 MapName ObjName 893 MapIfindex uint32 894 BtfFd uint32 895 BtfKeyTypeId TypeID 896 BtfValueTypeId TypeID 897 BtfVmlinuxValueTypeId TypeID 898 MapExtra uint64 899 } 900 901 func MapCreate(attr *MapCreateAttr) (*FD, error) { 902 fd, err := BPF(BPF_MAP_CREATE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 903 if err != nil { 904 return nil, err 905 } 906 return NewFD(int(fd)) 907 } 908 909 type MapDeleteBatchAttr struct { 910 InBatch Pointer 911 OutBatch Pointer 912 Keys Pointer 913 Values Pointer 914 Count uint32 915 MapFd uint32 916 ElemFlags uint64 917 Flags uint64 918 } 919 920 func MapDeleteBatch(attr *MapDeleteBatchAttr) error { 921 _, err := BPF(BPF_MAP_DELETE_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 922 return err 923 } 924 925 type MapDeleteElemAttr struct { 926 MapFd uint32 927 _ [4]byte 928 Key Pointer 929 Value Pointer 930 Flags uint64 931 } 932 933 func MapDeleteElem(attr *MapDeleteElemAttr) error { 934 _, err := BPF(BPF_MAP_DELETE_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 935 return err 936 } 937 938 type MapFreezeAttr struct{ MapFd uint32 } 939 940 func MapFreeze(attr *MapFreezeAttr) error { 941 _, err := BPF(BPF_MAP_FREEZE, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 942 return err 943 } 944 945 type MapGetFdByIdAttr struct{ Id uint32 } 946 947 func MapGetFdById(attr *MapGetFdByIdAttr) (*FD, error) { 948 fd, err := BPF(BPF_MAP_GET_FD_BY_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 949 if err != nil { 950 return nil, err 951 } 952 return NewFD(int(fd)) 953 } 954 955 type MapGetNextIdAttr struct { 956 Id uint32 957 NextId uint32 958 } 959 960 func MapGetNextId(attr *MapGetNextIdAttr) error { 961 _, err := BPF(BPF_MAP_GET_NEXT_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 962 return err 963 } 964 965 type MapGetNextKeyAttr struct { 966 MapFd uint32 967 _ [4]byte 968 Key Pointer 969 NextKey Pointer 970 } 971 972 func MapGetNextKey(attr *MapGetNextKeyAttr) error { 973 _, err := BPF(BPF_MAP_GET_NEXT_KEY, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 974 return err 975 } 976 977 type MapLookupAndDeleteBatchAttr struct { 978 InBatch Pointer 979 OutBatch Pointer 980 Keys Pointer 981 Values Pointer 982 Count uint32 983 MapFd uint32 984 ElemFlags uint64 985 Flags uint64 986 } 987 988 func MapLookupAndDeleteBatch(attr *MapLookupAndDeleteBatchAttr) error { 989 _, err := BPF(BPF_MAP_LOOKUP_AND_DELETE_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 990 return err 991 } 992 993 type MapLookupAndDeleteElemAttr struct { 994 MapFd uint32 995 _ [4]byte 996 Key Pointer 997 Value Pointer 998 Flags uint64 999 } 1000 1001 func MapLookupAndDeleteElem(attr *MapLookupAndDeleteElemAttr) error { 1002 _, err := BPF(BPF_MAP_LOOKUP_AND_DELETE_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1003 return err 1004 } 1005 1006 type MapLookupBatchAttr struct { 1007 InBatch Pointer 1008 OutBatch Pointer 1009 Keys Pointer 1010 Values Pointer 1011 Count uint32 1012 MapFd uint32 1013 ElemFlags uint64 1014 Flags uint64 1015 } 1016 1017 func MapLookupBatch(attr *MapLookupBatchAttr) error { 1018 _, err := BPF(BPF_MAP_LOOKUP_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1019 return err 1020 } 1021 1022 type MapLookupElemAttr struct { 1023 MapFd uint32 1024 _ [4]byte 1025 Key Pointer 1026 Value Pointer 1027 Flags uint64 1028 } 1029 1030 func MapLookupElem(attr *MapLookupElemAttr) error { 1031 _, err := BPF(BPF_MAP_LOOKUP_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1032 return err 1033 } 1034 1035 type MapUpdateBatchAttr struct { 1036 InBatch Pointer 1037 OutBatch Pointer 1038 Keys Pointer 1039 Values Pointer 1040 Count uint32 1041 MapFd uint32 1042 ElemFlags uint64 1043 Flags uint64 1044 } 1045 1046 func MapUpdateBatch(attr *MapUpdateBatchAttr) error { 1047 _, err := BPF(BPF_MAP_UPDATE_BATCH, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1048 return err 1049 } 1050 1051 type MapUpdateElemAttr struct { 1052 MapFd uint32 1053 _ [4]byte 1054 Key Pointer 1055 Value Pointer 1056 Flags uint64 1057 } 1058 1059 func MapUpdateElem(attr *MapUpdateElemAttr) error { 1060 _, err := BPF(BPF_MAP_UPDATE_ELEM, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1061 return err 1062 } 1063 1064 type ObjGetAttr struct { 1065 Pathname Pointer 1066 BpfFd uint32 1067 FileFlags uint32 1068 PathFd int32 1069 _ [4]byte 1070 } 1071 1072 func ObjGet(attr *ObjGetAttr) (*FD, error) { 1073 fd, err := BPF(BPF_OBJ_GET, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1074 if err != nil { 1075 return nil, err 1076 } 1077 return NewFD(int(fd)) 1078 } 1079 1080 type ObjGetInfoByFdAttr struct { 1081 BpfFd uint32 1082 InfoLen uint32 1083 Info Pointer 1084 } 1085 1086 func ObjGetInfoByFd(attr *ObjGetInfoByFdAttr) error { 1087 _, err := BPF(BPF_OBJ_GET_INFO_BY_FD, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1088 return err 1089 } 1090 1091 type ObjPinAttr struct { 1092 Pathname Pointer 1093 BpfFd uint32 1094 FileFlags uint32 1095 PathFd int32 1096 _ [4]byte 1097 } 1098 1099 func ObjPin(attr *ObjPinAttr) error { 1100 _, err := BPF(BPF_OBJ_PIN, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1101 return err 1102 } 1103 1104 type ProgAttachAttr struct { 1105 TargetFdOrIfindex uint32 1106 AttachBpfFd uint32 1107 AttachType uint32 1108 AttachFlags uint32 1109 ReplaceBpfFd uint32 1110 RelativeFdOrId uint32 1111 ExpectedRevision uint64 1112 } 1113 1114 func ProgAttach(attr *ProgAttachAttr) error { 1115 _, err := BPF(BPF_PROG_ATTACH, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1116 return err 1117 } 1118 1119 type ProgBindMapAttr struct { 1120 ProgFd uint32 1121 MapFd uint32 1122 Flags uint32 1123 } 1124 1125 func ProgBindMap(attr *ProgBindMapAttr) error { 1126 _, err := BPF(BPF_PROG_BIND_MAP, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1127 return err 1128 } 1129 1130 type ProgDetachAttr struct { 1131 TargetFdOrIfindex uint32 1132 AttachBpfFd uint32 1133 AttachType uint32 1134 AttachFlags uint32 1135 _ [4]byte 1136 RelativeFdOrId uint32 1137 ExpectedRevision uint64 1138 } 1139 1140 func ProgDetach(attr *ProgDetachAttr) error { 1141 _, err := BPF(BPF_PROG_DETACH, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1142 return err 1143 } 1144 1145 type ProgGetFdByIdAttr struct{ Id uint32 } 1146 1147 func ProgGetFdById(attr *ProgGetFdByIdAttr) (*FD, error) { 1148 fd, err := BPF(BPF_PROG_GET_FD_BY_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1149 if err != nil { 1150 return nil, err 1151 } 1152 return NewFD(int(fd)) 1153 } 1154 1155 type ProgGetNextIdAttr struct { 1156 Id uint32 1157 NextId uint32 1158 } 1159 1160 func ProgGetNextId(attr *ProgGetNextIdAttr) error { 1161 _, err := BPF(BPF_PROG_GET_NEXT_ID, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1162 return err 1163 } 1164 1165 type ProgLoadAttr struct { 1166 ProgType ProgType 1167 InsnCnt uint32 1168 Insns Pointer 1169 License Pointer 1170 LogLevel LogLevel 1171 LogSize uint32 1172 LogBuf Pointer 1173 KernVersion uint32 1174 ProgFlags uint32 1175 ProgName ObjName 1176 ProgIfindex uint32 1177 ExpectedAttachType AttachType 1178 ProgBtfFd uint32 1179 FuncInfoRecSize uint32 1180 FuncInfo Pointer 1181 FuncInfoCnt uint32 1182 LineInfoRecSize uint32 1183 LineInfo Pointer 1184 LineInfoCnt uint32 1185 AttachBtfId TypeID 1186 AttachBtfObjFd uint32 1187 CoreReloCnt uint32 1188 FdArray Pointer 1189 CoreRelos Pointer 1190 CoreReloRecSize uint32 1191 LogTrueSize uint32 1192 } 1193 1194 func ProgLoad(attr *ProgLoadAttr) (*FD, error) { 1195 fd, err := BPF(BPF_PROG_LOAD, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1196 if err != nil { 1197 return nil, err 1198 } 1199 return NewFD(int(fd)) 1200 } 1201 1202 type ProgQueryAttr struct { 1203 TargetFdOrIfindex uint32 1204 AttachType AttachType 1205 QueryFlags uint32 1206 AttachFlags uint32 1207 ProgIds Pointer 1208 Count uint32 1209 _ [4]byte 1210 ProgAttachFlags Pointer 1211 LinkIds Pointer 1212 LinkAttachFlags Pointer 1213 Revision uint64 1214 } 1215 1216 func ProgQuery(attr *ProgQueryAttr) error { 1217 _, err := BPF(BPF_PROG_QUERY, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1218 return err 1219 } 1220 1221 type ProgRunAttr struct { 1222 ProgFd uint32 1223 Retval uint32 1224 DataSizeIn uint32 1225 DataSizeOut uint32 1226 DataIn Pointer 1227 DataOut Pointer 1228 Repeat uint32 1229 Duration uint32 1230 CtxSizeIn uint32 1231 CtxSizeOut uint32 1232 CtxIn Pointer 1233 CtxOut Pointer 1234 Flags uint32 1235 Cpu uint32 1236 BatchSize uint32 1237 _ [4]byte 1238 } 1239 1240 func ProgRun(attr *ProgRunAttr) error { 1241 _, err := BPF(BPF_PROG_TEST_RUN, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1242 return err 1243 } 1244 1245 type RawTracepointOpenAttr struct { 1246 Name Pointer 1247 ProgFd uint32 1248 _ [4]byte 1249 } 1250 1251 func RawTracepointOpen(attr *RawTracepointOpenAttr) (*FD, error) { 1252 fd, err := BPF(BPF_RAW_TRACEPOINT_OPEN, unsafe.Pointer(attr), unsafe.Sizeof(*attr)) 1253 if err != nil { 1254 return nil, err 1255 } 1256 return NewFD(int(fd)) 1257 } 1258 1259 type CgroupLinkInfo struct { 1260 Type LinkType 1261 Id LinkID 1262 ProgId uint32 1263 _ [4]byte 1264 CgroupId uint64 1265 AttachType AttachType 1266 _ [36]byte 1267 } 1268 1269 type IterLinkInfo struct { 1270 Type LinkType 1271 Id LinkID 1272 ProgId uint32 1273 _ [4]byte 1274 TargetName Pointer 1275 TargetNameLen uint32 1276 } 1277 1278 type KprobeLinkInfo struct { 1279 Type LinkType 1280 Id LinkID 1281 ProgId uint32 1282 _ [4]byte 1283 PerfEventType PerfEventType 1284 _ [4]byte 1285 FuncName Pointer 1286 NameLen uint32 1287 Offset uint32 1288 Addr uint64 1289 Missed uint64 1290 _ [8]byte 1291 } 1292 1293 type KprobeMultiLinkInfo struct { 1294 Type LinkType 1295 Id LinkID 1296 ProgId uint32 1297 _ [4]byte 1298 Addrs Pointer 1299 Count uint32 1300 Flags uint32 1301 Missed uint64 1302 _ [24]byte 1303 } 1304 1305 type NetNsLinkInfo struct { 1306 Type LinkType 1307 Id LinkID 1308 ProgId uint32 1309 _ [4]byte 1310 NetnsIno uint32 1311 AttachType AttachType 1312 _ [40]byte 1313 } 1314 1315 type NetfilterLinkInfo struct { 1316 Type LinkType 1317 Id LinkID 1318 ProgId uint32 1319 _ [4]byte 1320 Pf uint32 1321 Hooknum uint32 1322 Priority int32 1323 Flags uint32 1324 _ [32]byte 1325 } 1326 1327 type NetkitLinkInfo struct { 1328 Type LinkType 1329 Id LinkID 1330 ProgId uint32 1331 _ [4]byte 1332 Ifindex uint32 1333 AttachType AttachType 1334 _ [40]byte 1335 } 1336 1337 type PerfEventLinkInfo struct { 1338 Type LinkType 1339 Id LinkID 1340 ProgId uint32 1341 _ [4]byte 1342 PerfEventType PerfEventType 1343 } 1344 1345 type RawTracepointLinkInfo struct { 1346 Type LinkType 1347 Id LinkID 1348 ProgId uint32 1349 _ [4]byte 1350 TpName Pointer 1351 TpNameLen uint32 1352 _ [36]byte 1353 } 1354 1355 type TcxLinkInfo struct { 1356 Type LinkType 1357 Id LinkID 1358 ProgId uint32 1359 _ [4]byte 1360 Ifindex uint32 1361 AttachType AttachType 1362 _ [40]byte 1363 } 1364 1365 type TracingLinkInfo struct { 1366 Type LinkType 1367 Id LinkID 1368 ProgId uint32 1369 _ [4]byte 1370 AttachType AttachType 1371 TargetObjId uint32 1372 TargetBtfId TypeID 1373 _ [36]byte 1374 } 1375 1376 type XDPLinkInfo struct { 1377 Type LinkType 1378 Id LinkID 1379 ProgId uint32 1380 _ [4]byte 1381 Ifindex uint32 1382 _ [44]byte 1383 }