at v4.12 21 kB view raw
1/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com 2 * 3 * This program is free software; you can redistribute it and/or 4 * modify it under the terms of version 2 of the GNU General Public 5 * License as published by the Free Software Foundation. 6 */ 7#ifndef _UAPI__LINUX_BPF_H__ 8#define _UAPI__LINUX_BPF_H__ 9 10#include <linux/types.h> 11#include <linux/bpf_common.h> 12 13/* Extended instruction set based on top of classic BPF */ 14 15/* instruction classes */ 16#define BPF_ALU64 0x07 /* alu mode in double word width */ 17 18/* ld/ldx fields */ 19#define BPF_DW 0x18 /* double word */ 20#define BPF_XADD 0xc0 /* exclusive add */ 21 22/* alu/jmp fields */ 23#define BPF_MOV 0xb0 /* mov reg to reg */ 24#define BPF_ARSH 0xc0 /* sign extending arithmetic shift right */ 25 26/* change endianness of a register */ 27#define BPF_END 0xd0 /* flags for endianness conversion: */ 28#define BPF_TO_LE 0x00 /* convert to little-endian */ 29#define BPF_TO_BE 0x08 /* convert to big-endian */ 30#define BPF_FROM_LE BPF_TO_LE 31#define BPF_FROM_BE BPF_TO_BE 32 33#define BPF_JNE 0x50 /* jump != */ 34#define BPF_JSGT 0x60 /* SGT is signed '>', GT in x86 */ 35#define BPF_JSGE 0x70 /* SGE is signed '>=', GE in x86 */ 36#define BPF_CALL 0x80 /* function call */ 37#define BPF_EXIT 0x90 /* function return */ 38 39/* Register numbers */ 40enum { 41 BPF_REG_0 = 0, 42 BPF_REG_1, 43 BPF_REG_2, 44 BPF_REG_3, 45 BPF_REG_4, 46 BPF_REG_5, 47 BPF_REG_6, 48 BPF_REG_7, 49 BPF_REG_8, 50 BPF_REG_9, 51 BPF_REG_10, 52 __MAX_BPF_REG, 53}; 54 55/* BPF has 10 general purpose 64-bit registers and stack frame. */ 56#define MAX_BPF_REG __MAX_BPF_REG 57 58struct bpf_insn { 59 __u8 code; /* opcode */ 60 __u8 dst_reg:4; /* dest register */ 61 __u8 src_reg:4; /* source register */ 62 __s16 off; /* signed offset */ 63 __s32 imm; /* signed immediate constant */ 64}; 65 66/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */ 67struct bpf_lpm_trie_key { 68 __u32 prefixlen; /* up to 32 for AF_INET, 128 for AF_INET6 */ 69 __u8 data[0]; /* Arbitrary size */ 70}; 71 72/* BPF syscall commands, see bpf(2) man-page for details. */ 73enum bpf_cmd { 74 BPF_MAP_CREATE, 75 BPF_MAP_LOOKUP_ELEM, 76 BPF_MAP_UPDATE_ELEM, 77 BPF_MAP_DELETE_ELEM, 78 BPF_MAP_GET_NEXT_KEY, 79 BPF_PROG_LOAD, 80 BPF_OBJ_PIN, 81 BPF_OBJ_GET, 82 BPF_PROG_ATTACH, 83 BPF_PROG_DETACH, 84 BPF_PROG_TEST_RUN, 85}; 86 87enum bpf_map_type { 88 BPF_MAP_TYPE_UNSPEC, 89 BPF_MAP_TYPE_HASH, 90 BPF_MAP_TYPE_ARRAY, 91 BPF_MAP_TYPE_PROG_ARRAY, 92 BPF_MAP_TYPE_PERF_EVENT_ARRAY, 93 BPF_MAP_TYPE_PERCPU_HASH, 94 BPF_MAP_TYPE_PERCPU_ARRAY, 95 BPF_MAP_TYPE_STACK_TRACE, 96 BPF_MAP_TYPE_CGROUP_ARRAY, 97 BPF_MAP_TYPE_LRU_HASH, 98 BPF_MAP_TYPE_LRU_PERCPU_HASH, 99 BPF_MAP_TYPE_LPM_TRIE, 100 BPF_MAP_TYPE_ARRAY_OF_MAPS, 101 BPF_MAP_TYPE_HASH_OF_MAPS, 102}; 103 104enum bpf_prog_type { 105 BPF_PROG_TYPE_UNSPEC, 106 BPF_PROG_TYPE_SOCKET_FILTER, 107 BPF_PROG_TYPE_KPROBE, 108 BPF_PROG_TYPE_SCHED_CLS, 109 BPF_PROG_TYPE_SCHED_ACT, 110 BPF_PROG_TYPE_TRACEPOINT, 111 BPF_PROG_TYPE_XDP, 112 BPF_PROG_TYPE_PERF_EVENT, 113 BPF_PROG_TYPE_CGROUP_SKB, 114 BPF_PROG_TYPE_CGROUP_SOCK, 115 BPF_PROG_TYPE_LWT_IN, 116 BPF_PROG_TYPE_LWT_OUT, 117 BPF_PROG_TYPE_LWT_XMIT, 118}; 119 120enum bpf_attach_type { 121 BPF_CGROUP_INET_INGRESS, 122 BPF_CGROUP_INET_EGRESS, 123 BPF_CGROUP_INET_SOCK_CREATE, 124 __MAX_BPF_ATTACH_TYPE 125}; 126 127#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE 128 129/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command 130 * to the given target_fd cgroup the descendent cgroup will be able to 131 * override effective bpf program that was inherited from this cgroup 132 */ 133#define BPF_F_ALLOW_OVERRIDE (1U << 0) 134 135/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the 136 * verifier will perform strict alignment checking as if the kernel 137 * has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set, 138 * and NET_IP_ALIGN defined to 2. 139 */ 140#define BPF_F_STRICT_ALIGNMENT (1U << 0) 141 142#define BPF_PSEUDO_MAP_FD 1 143 144/* flags for BPF_MAP_UPDATE_ELEM command */ 145#define BPF_ANY 0 /* create new element or update existing */ 146#define BPF_NOEXIST 1 /* create new element if it didn't exist */ 147#define BPF_EXIST 2 /* update existing element */ 148 149#define BPF_F_NO_PREALLOC (1U << 0) 150/* Instead of having one common LRU list in the 151 * BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list 152 * which can scale and perform better. 153 * Note, the LRU nodes (including free nodes) cannot be moved 154 * across different LRU lists. 155 */ 156#define BPF_F_NO_COMMON_LRU (1U << 1) 157 158union bpf_attr { 159 struct { /* anonymous struct used by BPF_MAP_CREATE command */ 160 __u32 map_type; /* one of enum bpf_map_type */ 161 __u32 key_size; /* size of key in bytes */ 162 __u32 value_size; /* size of value in bytes */ 163 __u32 max_entries; /* max number of entries in a map */ 164 __u32 map_flags; /* prealloc or not */ 165 __u32 inner_map_fd; /* fd pointing to the inner map */ 166 }; 167 168 struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */ 169 __u32 map_fd; 170 __aligned_u64 key; 171 union { 172 __aligned_u64 value; 173 __aligned_u64 next_key; 174 }; 175 __u64 flags; 176 }; 177 178 struct { /* anonymous struct used by BPF_PROG_LOAD command */ 179 __u32 prog_type; /* one of enum bpf_prog_type */ 180 __u32 insn_cnt; 181 __aligned_u64 insns; 182 __aligned_u64 license; 183 __u32 log_level; /* verbosity level of verifier */ 184 __u32 log_size; /* size of user buffer */ 185 __aligned_u64 log_buf; /* user supplied buffer */ 186 __u32 kern_version; /* checked when prog_type=kprobe */ 187 __u32 prog_flags; 188 }; 189 190 struct { /* anonymous struct used by BPF_OBJ_* commands */ 191 __aligned_u64 pathname; 192 __u32 bpf_fd; 193 }; 194 195 struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */ 196 __u32 target_fd; /* container object to attach to */ 197 __u32 attach_bpf_fd; /* eBPF program to attach */ 198 __u32 attach_type; 199 __u32 attach_flags; 200 }; 201 202 struct { /* anonymous struct used by BPF_PROG_TEST_RUN command */ 203 __u32 prog_fd; 204 __u32 retval; 205 __u32 data_size_in; 206 __u32 data_size_out; 207 __aligned_u64 data_in; 208 __aligned_u64 data_out; 209 __u32 repeat; 210 __u32 duration; 211 } test; 212} __attribute__((aligned(8))); 213 214/* BPF helper function descriptions: 215 * 216 * void *bpf_map_lookup_elem(&map, &key) 217 * Return: Map value or NULL 218 * 219 * int bpf_map_update_elem(&map, &key, &value, flags) 220 * Return: 0 on success or negative error 221 * 222 * int bpf_map_delete_elem(&map, &key) 223 * Return: 0 on success or negative error 224 * 225 * int bpf_probe_read(void *dst, int size, void *src) 226 * Return: 0 on success or negative error 227 * 228 * u64 bpf_ktime_get_ns(void) 229 * Return: current ktime 230 * 231 * int bpf_trace_printk(const char *fmt, int fmt_size, ...) 232 * Return: length of buffer written or negative error 233 * 234 * u32 bpf_prandom_u32(void) 235 * Return: random value 236 * 237 * u32 bpf_raw_smp_processor_id(void) 238 * Return: SMP processor ID 239 * 240 * int bpf_skb_store_bytes(skb, offset, from, len, flags) 241 * store bytes into packet 242 * @skb: pointer to skb 243 * @offset: offset within packet from skb->mac_header 244 * @from: pointer where to copy bytes from 245 * @len: number of bytes to store into packet 246 * @flags: bit 0 - if true, recompute skb->csum 247 * other bits - reserved 248 * Return: 0 on success or negative error 249 * 250 * int bpf_l3_csum_replace(skb, offset, from, to, flags) 251 * recompute IP checksum 252 * @skb: pointer to skb 253 * @offset: offset within packet where IP checksum is located 254 * @from: old value of header field 255 * @to: new value of header field 256 * @flags: bits 0-3 - size of header field 257 * other bits - reserved 258 * Return: 0 on success or negative error 259 * 260 * int bpf_l4_csum_replace(skb, offset, from, to, flags) 261 * recompute TCP/UDP checksum 262 * @skb: pointer to skb 263 * @offset: offset within packet where TCP/UDP checksum is located 264 * @from: old value of header field 265 * @to: new value of header field 266 * @flags: bits 0-3 - size of header field 267 * bit 4 - is pseudo header 268 * other bits - reserved 269 * Return: 0 on success or negative error 270 * 271 * int bpf_tail_call(ctx, prog_array_map, index) 272 * jump into another BPF program 273 * @ctx: context pointer passed to next program 274 * @prog_array_map: pointer to map which type is BPF_MAP_TYPE_PROG_ARRAY 275 * @index: index inside array that selects specific program to run 276 * Return: 0 on success or negative error 277 * 278 * int bpf_clone_redirect(skb, ifindex, flags) 279 * redirect to another netdev 280 * @skb: pointer to skb 281 * @ifindex: ifindex of the net device 282 * @flags: bit 0 - if set, redirect to ingress instead of egress 283 * other bits - reserved 284 * Return: 0 on success or negative error 285 * 286 * u64 bpf_get_current_pid_tgid(void) 287 * Return: current->tgid << 32 | current->pid 288 * 289 * u64 bpf_get_current_uid_gid(void) 290 * Return: current_gid << 32 | current_uid 291 * 292 * int bpf_get_current_comm(char *buf, int size_of_buf) 293 * stores current->comm into buf 294 * Return: 0 on success or negative error 295 * 296 * u32 bpf_get_cgroup_classid(skb) 297 * retrieve a proc's classid 298 * @skb: pointer to skb 299 * Return: classid if != 0 300 * 301 * int bpf_skb_vlan_push(skb, vlan_proto, vlan_tci) 302 * Return: 0 on success or negative error 303 * 304 * int bpf_skb_vlan_pop(skb) 305 * Return: 0 on success or negative error 306 * 307 * int bpf_skb_get_tunnel_key(skb, key, size, flags) 308 * int bpf_skb_set_tunnel_key(skb, key, size, flags) 309 * retrieve or populate tunnel metadata 310 * @skb: pointer to skb 311 * @key: pointer to 'struct bpf_tunnel_key' 312 * @size: size of 'struct bpf_tunnel_key' 313 * @flags: room for future extensions 314 * Return: 0 on success or negative error 315 * 316 * u64 bpf_perf_event_read(&map, index) 317 * Return: Number events read or error code 318 * 319 * int bpf_redirect(ifindex, flags) 320 * redirect to another netdev 321 * @ifindex: ifindex of the net device 322 * @flags: bit 0 - if set, redirect to ingress instead of egress 323 * other bits - reserved 324 * Return: TC_ACT_REDIRECT 325 * 326 * u32 bpf_get_route_realm(skb) 327 * retrieve a dst's tclassid 328 * @skb: pointer to skb 329 * Return: realm if != 0 330 * 331 * int bpf_perf_event_output(ctx, map, index, data, size) 332 * output perf raw sample 333 * @ctx: struct pt_regs* 334 * @map: pointer to perf_event_array map 335 * @index: index of event in the map 336 * @data: data on stack to be output as raw data 337 * @size: size of data 338 * Return: 0 on success or negative error 339 * 340 * int bpf_get_stackid(ctx, map, flags) 341 * walk user or kernel stack and return id 342 * @ctx: struct pt_regs* 343 * @map: pointer to stack_trace map 344 * @flags: bits 0-7 - numer of stack frames to skip 345 * bit 8 - collect user stack instead of kernel 346 * bit 9 - compare stacks by hash only 347 * bit 10 - if two different stacks hash into the same stackid 348 * discard old 349 * other bits - reserved 350 * Return: >= 0 stackid on success or negative error 351 * 352 * s64 bpf_csum_diff(from, from_size, to, to_size, seed) 353 * calculate csum diff 354 * @from: raw from buffer 355 * @from_size: length of from buffer 356 * @to: raw to buffer 357 * @to_size: length of to buffer 358 * @seed: optional seed 359 * Return: csum result or negative error code 360 * 361 * int bpf_skb_get_tunnel_opt(skb, opt, size) 362 * retrieve tunnel options metadata 363 * @skb: pointer to skb 364 * @opt: pointer to raw tunnel option data 365 * @size: size of @opt 366 * Return: option size 367 * 368 * int bpf_skb_set_tunnel_opt(skb, opt, size) 369 * populate tunnel options metadata 370 * @skb: pointer to skb 371 * @opt: pointer to raw tunnel option data 372 * @size: size of @opt 373 * Return: 0 on success or negative error 374 * 375 * int bpf_skb_change_proto(skb, proto, flags) 376 * Change protocol of the skb. Currently supported is v4 -> v6, 377 * v6 -> v4 transitions. The helper will also resize the skb. eBPF 378 * program is expected to fill the new headers via skb_store_bytes 379 * and lX_csum_replace. 380 * @skb: pointer to skb 381 * @proto: new skb->protocol type 382 * @flags: reserved 383 * Return: 0 on success or negative error 384 * 385 * int bpf_skb_change_type(skb, type) 386 * Change packet type of skb. 387 * @skb: pointer to skb 388 * @type: new skb->pkt_type type 389 * Return: 0 on success or negative error 390 * 391 * int bpf_skb_under_cgroup(skb, map, index) 392 * Check cgroup2 membership of skb 393 * @skb: pointer to skb 394 * @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type 395 * @index: index of the cgroup in the bpf_map 396 * Return: 397 * == 0 skb failed the cgroup2 descendant test 398 * == 1 skb succeeded the cgroup2 descendant test 399 * < 0 error 400 * 401 * u32 bpf_get_hash_recalc(skb) 402 * Retrieve and possibly recalculate skb->hash. 403 * @skb: pointer to skb 404 * Return: hash 405 * 406 * u64 bpf_get_current_task(void) 407 * Returns current task_struct 408 * Return: current 409 * 410 * int bpf_probe_write_user(void *dst, void *src, int len) 411 * safely attempt to write to a location 412 * @dst: destination address in userspace 413 * @src: source address on stack 414 * @len: number of bytes to copy 415 * Return: 0 on success or negative error 416 * 417 * int bpf_current_task_under_cgroup(map, index) 418 * Check cgroup2 membership of current task 419 * @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type 420 * @index: index of the cgroup in the bpf_map 421 * Return: 422 * == 0 current failed the cgroup2 descendant test 423 * == 1 current succeeded the cgroup2 descendant test 424 * < 0 error 425 * 426 * int bpf_skb_change_tail(skb, len, flags) 427 * The helper will resize the skb to the given new size, to be used f.e. 428 * with control messages. 429 * @skb: pointer to skb 430 * @len: new skb length 431 * @flags: reserved 432 * Return: 0 on success or negative error 433 * 434 * int bpf_skb_pull_data(skb, len) 435 * The helper will pull in non-linear data in case the skb is non-linear 436 * and not all of len are part of the linear section. Only needed for 437 * read/write with direct packet access. 438 * @skb: pointer to skb 439 * @len: len to make read/writeable 440 * Return: 0 on success or negative error 441 * 442 * s64 bpf_csum_update(skb, csum) 443 * Adds csum into skb->csum in case of CHECKSUM_COMPLETE. 444 * @skb: pointer to skb 445 * @csum: csum to add 446 * Return: csum on success or negative error 447 * 448 * void bpf_set_hash_invalid(skb) 449 * Invalidate current skb->hash. 450 * @skb: pointer to skb 451 * 452 * int bpf_get_numa_node_id() 453 * Return: Id of current NUMA node. 454 * 455 * int bpf_skb_change_head() 456 * Grows headroom of skb and adjusts MAC header offset accordingly. 457 * Will extends/reallocae as required automatically. 458 * May change skb data pointer and will thus invalidate any check 459 * performed for direct packet access. 460 * @skb: pointer to skb 461 * @len: length of header to be pushed in front 462 * @flags: Flags (unused for now) 463 * Return: 0 on success or negative error 464 * 465 * int bpf_xdp_adjust_head(xdp_md, delta) 466 * Adjust the xdp_md.data by delta 467 * @xdp_md: pointer to xdp_md 468 * @delta: An positive/negative integer to be added to xdp_md.data 469 * Return: 0 on success or negative on error 470 * 471 * int bpf_probe_read_str(void *dst, int size, const void *unsafe_ptr) 472 * Copy a NUL terminated string from unsafe address. In case the string 473 * length is smaller than size, the target is not padded with further NUL 474 * bytes. In case the string length is larger than size, just count-1 475 * bytes are copied and the last byte is set to NUL. 476 * @dst: destination address 477 * @size: maximum number of bytes to copy, including the trailing NUL 478 * @unsafe_ptr: unsafe address 479 * Return: 480 * > 0 length of the string including the trailing NUL on success 481 * < 0 error 482 * 483 * u64 bpf_get_socket_cookie(skb) 484 * Get the cookie for the socket stored inside sk_buff. 485 * @skb: pointer to skb 486 * Return: 8 Bytes non-decreasing number on success or 0 if the socket 487 * field is missing inside sk_buff 488 * 489 * u32 bpf_get_socket_uid(skb) 490 * Get the owner uid of the socket stored inside sk_buff. 491 * @skb: pointer to skb 492 * Return: uid of the socket owner on success or overflowuid if failed. 493 */ 494#define __BPF_FUNC_MAPPER(FN) \ 495 FN(unspec), \ 496 FN(map_lookup_elem), \ 497 FN(map_update_elem), \ 498 FN(map_delete_elem), \ 499 FN(probe_read), \ 500 FN(ktime_get_ns), \ 501 FN(trace_printk), \ 502 FN(get_prandom_u32), \ 503 FN(get_smp_processor_id), \ 504 FN(skb_store_bytes), \ 505 FN(l3_csum_replace), \ 506 FN(l4_csum_replace), \ 507 FN(tail_call), \ 508 FN(clone_redirect), \ 509 FN(get_current_pid_tgid), \ 510 FN(get_current_uid_gid), \ 511 FN(get_current_comm), \ 512 FN(get_cgroup_classid), \ 513 FN(skb_vlan_push), \ 514 FN(skb_vlan_pop), \ 515 FN(skb_get_tunnel_key), \ 516 FN(skb_set_tunnel_key), \ 517 FN(perf_event_read), \ 518 FN(redirect), \ 519 FN(get_route_realm), \ 520 FN(perf_event_output), \ 521 FN(skb_load_bytes), \ 522 FN(get_stackid), \ 523 FN(csum_diff), \ 524 FN(skb_get_tunnel_opt), \ 525 FN(skb_set_tunnel_opt), \ 526 FN(skb_change_proto), \ 527 FN(skb_change_type), \ 528 FN(skb_under_cgroup), \ 529 FN(get_hash_recalc), \ 530 FN(get_current_task), \ 531 FN(probe_write_user), \ 532 FN(current_task_under_cgroup), \ 533 FN(skb_change_tail), \ 534 FN(skb_pull_data), \ 535 FN(csum_update), \ 536 FN(set_hash_invalid), \ 537 FN(get_numa_node_id), \ 538 FN(skb_change_head), \ 539 FN(xdp_adjust_head), \ 540 FN(probe_read_str), \ 541 FN(get_socket_cookie), \ 542 FN(get_socket_uid), 543 544/* integer value in 'imm' field of BPF_CALL instruction selects which helper 545 * function eBPF program intends to call 546 */ 547#define __BPF_ENUM_FN(x) BPF_FUNC_ ## x 548enum bpf_func_id { 549 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) 550 __BPF_FUNC_MAX_ID, 551}; 552#undef __BPF_ENUM_FN 553 554/* All flags used by eBPF helper functions, placed here. */ 555 556/* BPF_FUNC_skb_store_bytes flags. */ 557#define BPF_F_RECOMPUTE_CSUM (1ULL << 0) 558#define BPF_F_INVALIDATE_HASH (1ULL << 1) 559 560/* BPF_FUNC_l3_csum_replace and BPF_FUNC_l4_csum_replace flags. 561 * First 4 bits are for passing the header field size. 562 */ 563#define BPF_F_HDR_FIELD_MASK 0xfULL 564 565/* BPF_FUNC_l4_csum_replace flags. */ 566#define BPF_F_PSEUDO_HDR (1ULL << 4) 567#define BPF_F_MARK_MANGLED_0 (1ULL << 5) 568#define BPF_F_MARK_ENFORCE (1ULL << 6) 569 570/* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */ 571#define BPF_F_INGRESS (1ULL << 0) 572 573/* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ 574#define BPF_F_TUNINFO_IPV6 (1ULL << 0) 575 576/* BPF_FUNC_get_stackid flags. */ 577#define BPF_F_SKIP_FIELD_MASK 0xffULL 578#define BPF_F_USER_STACK (1ULL << 8) 579#define BPF_F_FAST_STACK_CMP (1ULL << 9) 580#define BPF_F_REUSE_STACKID (1ULL << 10) 581 582/* BPF_FUNC_skb_set_tunnel_key flags. */ 583#define BPF_F_ZERO_CSUM_TX (1ULL << 1) 584#define BPF_F_DONT_FRAGMENT (1ULL << 2) 585 586/* BPF_FUNC_perf_event_output and BPF_FUNC_perf_event_read flags. */ 587#define BPF_F_INDEX_MASK 0xffffffffULL 588#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK 589/* BPF_FUNC_perf_event_output for sk_buff input context. */ 590#define BPF_F_CTXLEN_MASK (0xfffffULL << 32) 591 592/* user accessible mirror of in-kernel sk_buff. 593 * new fields can only be added to the end of this structure 594 */ 595struct __sk_buff { 596 __u32 len; 597 __u32 pkt_type; 598 __u32 mark; 599 __u32 queue_mapping; 600 __u32 protocol; 601 __u32 vlan_present; 602 __u32 vlan_tci; 603 __u32 vlan_proto; 604 __u32 priority; 605 __u32 ingress_ifindex; 606 __u32 ifindex; 607 __u32 tc_index; 608 __u32 cb[5]; 609 __u32 hash; 610 __u32 tc_classid; 611 __u32 data; 612 __u32 data_end; 613 __u32 napi_id; 614}; 615 616struct bpf_tunnel_key { 617 __u32 tunnel_id; 618 union { 619 __u32 remote_ipv4; 620 __u32 remote_ipv6[4]; 621 }; 622 __u8 tunnel_tos; 623 __u8 tunnel_ttl; 624 __u16 tunnel_ext; 625 __u32 tunnel_label; 626}; 627 628/* Generic BPF return codes which all BPF program types may support. 629 * The values are binary compatible with their TC_ACT_* counter-part to 630 * provide backwards compatibility with existing SCHED_CLS and SCHED_ACT 631 * programs. 632 * 633 * XDP is handled seprately, see XDP_*. 634 */ 635enum bpf_ret_code { 636 BPF_OK = 0, 637 /* 1 reserved */ 638 BPF_DROP = 2, 639 /* 3-6 reserved */ 640 BPF_REDIRECT = 7, 641 /* >127 are reserved for prog type specific return codes */ 642}; 643 644struct bpf_sock { 645 __u32 bound_dev_if; 646 __u32 family; 647 __u32 type; 648 __u32 protocol; 649}; 650 651#define XDP_PACKET_HEADROOM 256 652 653/* User return codes for XDP prog type. 654 * A valid XDP program must return one of these defined values. All other 655 * return codes are reserved for future use. Unknown return codes will result 656 * in packet drop. 657 */ 658enum xdp_action { 659 XDP_ABORTED = 0, 660 XDP_DROP, 661 XDP_PASS, 662 XDP_TX, 663}; 664 665/* user accessible metadata for XDP packet hook 666 * new fields must be added to the end of this structure 667 */ 668struct xdp_md { 669 __u32 data; 670 __u32 data_end; 671}; 672 673#endif /* _UAPI__LINUX_BPF_H__ */