History

bpf: explicitly define BPF_FUNC_xxx integer values

Historically enum bpf_func_id's BPF_FUNC_xxx enumerators relied on implicit sequential values being assigned by compiler. This is convenient, as new BPF helpers are always added at the very end, but it also has its downsides, some of them being: - with over 200 helpers now it's very hard to know what's each helper's ID, which is often important to know when working with BPF assembly (e.g., by dumping raw bpf assembly instructions with llvm-objdump -d command). it's possible to work around this by looking into vmlinux.h, dumping /sys/btf/kernel/vmlinux, looking at libbpf-provided bpf_helper_defs.h, etc. But it always feels like an unnecessary step and one should be able to quickly figure this out from UAPI header. - when backporting and cherry-picking only some BPF helpers onto older kernels it's important to be able to skip some enum values for helpers that weren't backported, but preserve absolute integer IDs to keep BPF helper IDs stable so that BPF programs stay portable across upstream and backported kernels. While neither problem is insurmountable, they come up frequently enough and are annoying enough to warrant improving the situation. And for the backporting the problem can easily go unnoticed for a while, especially if backport is done with people not very familiar with BPF subsystem overall. Anyways, it's easy to fix this by making sure that __BPF_FUNC_MAPPER macro provides explicit helper IDs. Unfortunately that would potentially break existing users that use UAPI-exposed __BPF_FUNC_MAPPER and are expected to pass macro that accepts only symbolic helper identifier (e.g., map_lookup_elem for bpf_map_lookup_elem() helper). As such, we need to introduce a new macro (___BPF_FUNC_MAPPER) which would specify both identifier and integer ID, but in such a way as to allow existing __BPF_FUNC_MAPPER be expressed in terms of new ___BPF_FUNC_MAPPER macro. And that's what this patch is doing. To avoid duplication and allow __BPF_FUNC_MAPPER stay *exactly* the same, ___BPF_FUNC_MAPPER accepts arbitrary "context" arguments, which can be used to pass any extra macros, arguments, and whatnot. In our case we use this to pass original user-provided macro that expects single argument and __BPF_FUNC_MAPPER is using it's own three-argument __BPF_FUNC_MAPPER_APPLY intermediate macro to impedance-match new and old "callback" macros. Once we resolve this, we use new ___BPF_FUNC_MAPPER to define enum bpf_func_id with explicit values. The other users of __BPF_FUNC_MAPPER in kernel (namely in kernel/bpf/disasm.c) are kept exactly the same both as demonstration that backwards compat works, but also to avoid unnecessary code churn. Note that new ___BPF_FUNC_MAPPER() doesn't forcefully insert comma between values, as that might not be appropriate in all possible cases where ___BPF_FUNC_MAPPER might be used by users. This doesn't reduce usability, as it's trivial to insert that comma inside "callback" macro. To validate all the manually specified IDs are exactly right, we used BTF to compare before and after values: $ bpftool btf dump file ~/linux-build/default/vmlinux | rg bpf_func_id -A 211 > after.txt $ git stash # stach UAPI changes $ make -j90 ... re-building kernel without UAPI changes ... $ bpftool btf dump file ~/linux-build/default/vmlinux | rg bpf_func_id -A 211 > before.txt $ diff -u before.txt after.txt --- before.txt 2022-10-05 10:48:18.119195916 -0700 +++ after.txt 2022-10-05 10:46:49.446615025 -0700 @@ -1,4 +1,4 @@ -[14576] ENUM 'bpf_func_id' encoding=UNSIGNED size=4 vlen=211 +[9560] ENUM 'bpf_func_id' encoding=UNSIGNED size=4 vlen=211 'BPF_FUNC_unspec' val=0 'BPF_FUNC_map_lookup_elem' val=1 'BPF_FUNC_map_update_elem' val=2 As can be seen from diff above, the only thing that changed was resulting BTF type ID of ENUM bpf_func_id, not any of the enumerators, their names or integer values. The only other place that needed fixing was scripts/bpf_doc.py used to generate man pages and bpf_helper_defs.h header for libbpf and selftests. That script is tightly-coupled to exact shape of ___BPF_FUNC_MAPPER macro definition, so had to be trivially adapted.

Andrii Nakryiko committed 4 years ago

Commit 8a761451 parent 60df8c43 files · +447 −436Browse files

Showing the changes to tools/include/uapi/linux (1 of 3 files). Show all

Unified · Split

tools/include/uapi/linux/bpf.h+219−213
@@ -5436,225 +5436,231 @@ union bpf_attr { · 5435 unmodified lines
5436 * larger than the size of the ring buffer, or which cannot fit5436 * larger than the size of the ring buffer, or which cannot fit
5437 * within a struct bpf_dynptr.5437 * within a struct bpf_dynptr.
5438 */5438 */
5439#define __BPF_FUNC_MAPPER(FN) \5439#define ___BPF_FUNC_MAPPER(FN, ctx...) \
5440 FN(unspec), \5440 FN(unspec, 0, ##ctx) \
5441 FN(map_lookup_elem), \5441 FN(map_lookup_elem, 1, ##ctx) \
5442 FN(map_update_elem), \5442 FN(map_update_elem, 2, ##ctx) \
5443 FN(map_delete_elem), \5443 FN(map_delete_elem, 3, ##ctx) \
5444 FN(probe_read), \5444 FN(probe_read, 4, ##ctx) \
5445 FN(ktime_get_ns), \5445 FN(ktime_get_ns, 5, ##ctx) \
5446 FN(trace_printk), \5446 FN(trace_printk, 6, ##ctx) \
5447 FN(get_prandom_u32), \5447 FN(get_prandom_u32, 7, ##ctx) \
5448 FN(get_smp_processor_id), \5448 FN(get_smp_processor_id, 8, ##ctx) \
5449 FN(skb_store_bytes), \5449 FN(skb_store_bytes, 9, ##ctx) \
5450 FN(l3_csum_replace), \5450 FN(l3_csum_replace, 10, ##ctx) \
5451 FN(l4_csum_replace), \5451 FN(l4_csum_replace, 11, ##ctx) \
5452 FN(tail_call), \5452 FN(tail_call, 12, ##ctx) \
5453 FN(clone_redirect), \5453 FN(clone_redirect, 13, ##ctx) \
5454 FN(get_current_pid_tgid), \5454 FN(get_current_pid_tgid, 14, ##ctx) \
5455 FN(get_current_uid_gid), \5455 FN(get_current_uid_gid, 15, ##ctx) \
5456 FN(get_current_comm), \5456 FN(get_current_comm, 16, ##ctx) \
5457 FN(get_cgroup_classid), \5457 FN(get_cgroup_classid, 17, ##ctx) \
5458 FN(skb_vlan_push), \5458 FN(skb_vlan_push, 18, ##ctx) \
5459 FN(skb_vlan_pop), \5459 FN(skb_vlan_pop, 19, ##ctx) \
5460 FN(skb_get_tunnel_key), \5460 FN(skb_get_tunnel_key, 20, ##ctx) \
5461 FN(skb_set_tunnel_key), \5461 FN(skb_set_tunnel_key, 21, ##ctx) \
5462 FN(perf_event_read), \5462 FN(perf_event_read, 22, ##ctx) \
5463 FN(redirect), \5463 FN(redirect, 23, ##ctx) \
5464 FN(get_route_realm), \5464 FN(get_route_realm, 24, ##ctx) \
5465 FN(perf_event_output), \5465 FN(perf_event_output, 25, ##ctx) \
5466 FN(skb_load_bytes), \5466 FN(skb_load_bytes, 26, ##ctx) \
5467 FN(get_stackid), \5467 FN(get_stackid, 27, ##ctx) \
5468 FN(csum_diff), \5468 FN(csum_diff, 28, ##ctx) \
5469 FN(skb_get_tunnel_opt), \5469 FN(skb_get_tunnel_opt, 29, ##ctx) \
5470 FN(skb_set_tunnel_opt), \5470 FN(skb_set_tunnel_opt, 30, ##ctx) \
5471 FN(skb_change_proto), \5471 FN(skb_change_proto, 31, ##ctx) \
5472 FN(skb_change_type), \5472 FN(skb_change_type, 32, ##ctx) \
5473 FN(skb_under_cgroup), \5473 FN(skb_under_cgroup, 33, ##ctx) \
5474 FN(get_hash_recalc), \5474 FN(get_hash_recalc, 34, ##ctx) \
5475 FN(get_current_task), \5475 FN(get_current_task, 35, ##ctx) \
5476 FN(probe_write_user), \5476 FN(probe_write_user, 36, ##ctx) \
5477 FN(current_task_under_cgroup), \5477 FN(current_task_under_cgroup, 37, ##ctx) \
5478 FN(skb_change_tail), \5478 FN(skb_change_tail, 38, ##ctx) \
5479 FN(skb_pull_data), \5479 FN(skb_pull_data, 39, ##ctx) \
5480 FN(csum_update), \5480 FN(csum_update, 40, ##ctx) \
5481 FN(set_hash_invalid), \5481 FN(set_hash_invalid, 41, ##ctx) \
5482 FN(get_numa_node_id), \5482 FN(get_numa_node_id, 42, ##ctx) \
5483 FN(skb_change_head), \5483 FN(skb_change_head, 43, ##ctx) \
5484 FN(xdp_adjust_head), \5484 FN(xdp_adjust_head, 44, ##ctx) \
5485 FN(probe_read_str), \5485 FN(probe_read_str, 45, ##ctx) \
5486 FN(get_socket_cookie), \5486 FN(get_socket_cookie, 46, ##ctx) \
5487 FN(get_socket_uid), \5487 FN(get_socket_uid, 47, ##ctx) \
5488 FN(set_hash), \5488 FN(set_hash, 48, ##ctx) \
5489 FN(setsockopt), \5489 FN(setsockopt, 49, ##ctx) \
5490 FN(skb_adjust_room), \5490 FN(skb_adjust_room, 50, ##ctx) \
5491 FN(redirect_map), \5491 FN(redirect_map, 51, ##ctx) \
5492 FN(sk_redirect_map), \5492 FN(sk_redirect_map, 52, ##ctx) \
5493 FN(sock_map_update), \5493 FN(sock_map_update, 53, ##ctx) \
5494 FN(xdp_adjust_meta), \5494 FN(xdp_adjust_meta, 54, ##ctx) \
5495 FN(perf_event_read_value), \5495 FN(perf_event_read_value, 55, ##ctx) \
5496 FN(perf_prog_read_value), \5496 FN(perf_prog_read_value, 56, ##ctx) \
5497 FN(getsockopt), \5497 FN(getsockopt, 57, ##ctx) \
5498 FN(override_return), \5498 FN(override_return, 58, ##ctx) \
5499 FN(sock_ops_cb_flags_set), \5499 FN(sock_ops_cb_flags_set, 59, ##ctx) \
5500 FN(msg_redirect_map), \5500 FN(msg_redirect_map, 60, ##ctx) \
5501 FN(msg_apply_bytes), \5501 FN(msg_apply_bytes, 61, ##ctx) \
5502 FN(msg_cork_bytes), \5502 FN(msg_cork_bytes, 62, ##ctx) \
5503 FN(msg_pull_data), \5503 FN(msg_pull_data, 63, ##ctx) \
5504 FN(bind), \5504 FN(bind, 64, ##ctx) \
5505 FN(xdp_adjust_tail), \5505 FN(xdp_adjust_tail, 65, ##ctx) \
5506 FN(skb_get_xfrm_state), \5506 FN(skb_get_xfrm_state, 66, ##ctx) \
5507 FN(get_stack), \5507 FN(get_stack, 67, ##ctx) \
5508 FN(skb_load_bytes_relative), \5508 FN(skb_load_bytes_relative, 68, ##ctx) \
5509 FN(fib_lookup), \5509 FN(fib_lookup, 69, ##ctx) \
5510 FN(sock_hash_update), \5510 FN(sock_hash_update, 70, ##ctx) \
5511 FN(msg_redirect_hash), \5511 FN(msg_redirect_hash, 71, ##ctx) \
5512 FN(sk_redirect_hash), \5512 FN(sk_redirect_hash, 72, ##ctx) \
5513 FN(lwt_push_encap), \5513 FN(lwt_push_encap, 73, ##ctx) \
5514 FN(lwt_seg6_store_bytes), \5514 FN(lwt_seg6_store_bytes, 74, ##ctx) \
5515 FN(lwt_seg6_adjust_srh), \5515 FN(lwt_seg6_adjust_srh, 75, ##ctx) \
5516 FN(lwt_seg6_action), \5516 FN(lwt_seg6_action, 76, ##ctx) \
5517 FN(rc_repeat), \5517 FN(rc_repeat, 77, ##ctx) \
5518 FN(rc_keydown), \5518 FN(rc_keydown, 78, ##ctx) \
5519 FN(skb_cgroup_id), \5519 FN(skb_cgroup_id, 79, ##ctx) \
5520 FN(get_current_cgroup_id), \5520 FN(get_current_cgroup_id, 80, ##ctx) \
5521 FN(get_local_storage), \5521 FN(get_local_storage, 81, ##ctx) \
5522 FN(sk_select_reuseport), \5522 FN(sk_select_reuseport, 82, ##ctx) \
5523 FN(skb_ancestor_cgroup_id), \5523 FN(skb_ancestor_cgroup_id, 83, ##ctx) \
5524 FN(sk_lookup_tcp), \5524 FN(sk_lookup_tcp, 84, ##ctx) \
5525 FN(sk_lookup_udp), \5525 FN(sk_lookup_udp, 85, ##ctx) \
5526 FN(sk_release), \5526 FN(sk_release, 86, ##ctx) \
5527 FN(map_push_elem), \5527 FN(map_push_elem, 87, ##ctx) \
5528 FN(map_pop_elem), \5528 FN(map_pop_elem, 88, ##ctx) \
5529 FN(map_peek_elem), \5529 FN(map_peek_elem, 89, ##ctx) \
5530 FN(msg_push_data), \5530 FN(msg_push_data, 90, ##ctx) \
5531 FN(msg_pop_data), \5531 FN(msg_pop_data, 91, ##ctx) \
5532 FN(rc_pointer_rel), \5532 FN(rc_pointer_rel, 92, ##ctx) \
5533 FN(spin_lock), \5533 FN(spin_lock, 93, ##ctx) \
5534 FN(spin_unlock), \5534 FN(spin_unlock, 94, ##ctx) \
5535 FN(sk_fullsock), \5535 FN(sk_fullsock, 95, ##ctx) \
5536 FN(tcp_sock), \5536 FN(tcp_sock, 96, ##ctx) \
5537 FN(skb_ecn_set_ce), \5537 FN(skb_ecn_set_ce, 97, ##ctx) \
5538 FN(get_listener_sock), \5538 FN(get_listener_sock, 98, ##ctx) \
5539 FN(skc_lookup_tcp), \5539 FN(skc_lookup_tcp, 99, ##ctx) \
5540 FN(tcp_check_syncookie), \5540 FN(tcp_check_syncookie, 100, ##ctx) \
5541 FN(sysctl_get_name), \5541 FN(sysctl_get_name, 101, ##ctx) \
5542 FN(sysctl_get_current_value), \5542 FN(sysctl_get_current_value, 102, ##ctx) \
5543 FN(sysctl_get_new_value), \5543 FN(sysctl_get_new_value, 103, ##ctx) \
5544 FN(sysctl_set_new_value), \5544 FN(sysctl_set_new_value, 104, ##ctx) \
5545 FN(strtol), \5545 FN(strtol, 105, ##ctx) \
5546 FN(strtoul), \5546 FN(strtoul, 106, ##ctx) \
5547 FN(sk_storage_get), \5547 FN(sk_storage_get, 107, ##ctx) \
5548 FN(sk_storage_delete), \5548 FN(sk_storage_delete, 108, ##ctx) \
5549 FN(send_signal), \5549 FN(send_signal, 109, ##ctx) \
5550 FN(tcp_gen_syncookie), \5550 FN(tcp_gen_syncookie, 110, ##ctx) \
5551 FN(skb_output), \5551 FN(skb_output, 111, ##ctx) \
5552 FN(probe_read_user), \5552 FN(probe_read_user, 112, ##ctx) \
5553 FN(probe_read_kernel), \5553 FN(probe_read_kernel, 113, ##ctx) \
5554 FN(probe_read_user_str), \5554 FN(probe_read_user_str, 114, ##ctx) \
5555 FN(probe_read_kernel_str), \5555 FN(probe_read_kernel_str, 115, ##ctx) \
5556 FN(tcp_send_ack), \5556 FN(tcp_send_ack, 116, ##ctx) \
5557 FN(send_signal_thread), \5557 FN(send_signal_thread, 117, ##ctx) \
5558 FN(jiffies64), \5558 FN(jiffies64, 118, ##ctx) \
5559 FN(read_branch_records), \5559 FN(read_branch_records, 119, ##ctx) \
5560 FN(get_ns_current_pid_tgid), \5560 FN(get_ns_current_pid_tgid, 120, ##ctx) \
5561 FN(xdp_output), \5561 FN(xdp_output, 121, ##ctx) \
5562 FN(get_netns_cookie), \5562 FN(get_netns_cookie, 122, ##ctx) \
5563 FN(get_current_ancestor_cgroup_id), \5563 FN(get_current_ancestor_cgroup_id, 123, ##ctx) \
5564 FN(sk_assign), \5564 FN(sk_assign, 124, ##ctx) \
5565 FN(ktime_get_boot_ns), \5565 FN(ktime_get_boot_ns, 125, ##ctx) \
5566 FN(seq_printf), \5566 FN(seq_printf, 126, ##ctx) \
5567 FN(seq_write), \5567 FN(seq_write, 127, ##ctx) \
5568 FN(sk_cgroup_id), \5568 FN(sk_cgroup_id, 128, ##ctx) \
5569 FN(sk_ancestor_cgroup_id), \5569 FN(sk_ancestor_cgroup_id, 129, ##ctx) \
5570 FN(ringbuf_output), \5570 FN(ringbuf_output, 130, ##ctx) \
5571 FN(ringbuf_reserve), \5571 FN(ringbuf_reserve, 131, ##ctx) \
5572 FN(ringbuf_submit), \5572 FN(ringbuf_submit, 132, ##ctx) \
5573 FN(ringbuf_discard), \5573 FN(ringbuf_discard, 133, ##ctx) \
5574 FN(ringbuf_query), \5574 FN(ringbuf_query, 134, ##ctx) \
5575 FN(csum_level), \5575 FN(csum_level, 135, ##ctx) \
5576 FN(skc_to_tcp6_sock), \5576 FN(skc_to_tcp6_sock, 136, ##ctx) \
5577 FN(skc_to_tcp_sock), \5577 FN(skc_to_tcp_sock, 137, ##ctx) \
5578 FN(skc_to_tcp_timewait_sock), \5578 FN(skc_to_tcp_timewait_sock, 138, ##ctx) \
5579 FN(skc_to_tcp_request_sock), \5579 FN(skc_to_tcp_request_sock, 139, ##ctx) \
5580 FN(skc_to_udp6_sock), \5580 FN(skc_to_udp6_sock, 140, ##ctx) \
5581 FN(get_task_stack), \5581 FN(get_task_stack, 141, ##ctx) \
5582 FN(load_hdr_opt), \5582 FN(load_hdr_opt, 142, ##ctx) \
5583 FN(store_hdr_opt), \5583 FN(store_hdr_opt, 143, ##ctx) \
5584 FN(reserve_hdr_opt), \5584 FN(reserve_hdr_opt, 144, ##ctx) \
5585 FN(inode_storage_get), \5585 FN(inode_storage_get, 145, ##ctx) \
5586 FN(inode_storage_delete), \5586 FN(inode_storage_delete, 146, ##ctx) \
5587 FN(d_path), \5587 FN(d_path, 147, ##ctx) \
5588 FN(copy_from_user), \5588 FN(copy_from_user, 148, ##ctx) \
5589 FN(snprintf_btf), \5589 FN(snprintf_btf, 149, ##ctx) \
5590 FN(seq_printf_btf), \5590 FN(seq_printf_btf, 150, ##ctx) \
5591 FN(skb_cgroup_classid), \5591 FN(skb_cgroup_classid, 151, ##ctx) \
5592 FN(redirect_neigh), \5592 FN(redirect_neigh, 152, ##ctx) \
5593 FN(per_cpu_ptr), \5593 FN(per_cpu_ptr, 153, ##ctx) \
5594 FN(this_cpu_ptr), \5594 FN(this_cpu_ptr, 154, ##ctx) \
5595 FN(redirect_peer), \5595 FN(redirect_peer, 155, ##ctx) \
5596 FN(task_storage_get), \5596 FN(task_storage_get, 156, ##ctx) \
5597 FN(task_storage_delete), \5597 FN(task_storage_delete, 157, ##ctx) \
5598 FN(get_current_task_btf), \5598 FN(get_current_task_btf, 158, ##ctx) \
5599 FN(bprm_opts_set), \5599 FN(bprm_opts_set, 159, ##ctx) \
5600 FN(ktime_get_coarse_ns), \5600 FN(ktime_get_coarse_ns, 160, ##ctx) \
5601 FN(ima_inode_hash), \5601 FN(ima_inode_hash, 161, ##ctx) \
5602 FN(sock_from_file), \5602 FN(sock_from_file, 162, ##ctx) \
5603 FN(check_mtu), \5603 FN(check_mtu, 163, ##ctx) \
5604 FN(for_each_map_elem), \5604 FN(for_each_map_elem, 164, ##ctx) \
5605 FN(snprintf), \5605 FN(snprintf, 165, ##ctx) \
5606 FN(sys_bpf), \5606 FN(sys_bpf, 166, ##ctx) \
5607 FN(btf_find_by_name_kind), \5607 FN(btf_find_by_name_kind, 167, ##ctx) \
5608 FN(sys_close), \5608 FN(sys_close, 168, ##ctx) \
5609 FN(timer_init), \5609 FN(timer_init, 169, ##ctx) \
5610 FN(timer_set_callback), \5610 FN(timer_set_callback, 170, ##ctx) \
5611 FN(timer_start), \5611 FN(timer_start, 171, ##ctx) \
5612 FN(timer_cancel), \5612 FN(timer_cancel, 172, ##ctx) \
5613 FN(get_func_ip), \5613 FN(get_func_ip, 173, ##ctx) \
5614 FN(get_attach_cookie), \5614 FN(get_attach_cookie, 174, ##ctx) \
5615 FN(task_pt_regs), \5615 FN(task_pt_regs, 175, ##ctx) \
5616 FN(get_branch_snapshot), \5616 FN(get_branch_snapshot, 176, ##ctx) \
5617 FN(trace_vprintk), \5617 FN(trace_vprintk, 177, ##ctx) \
5618 FN(skc_to_unix_sock), \5618 FN(skc_to_unix_sock, 178, ##ctx) \
5619 FN(kallsyms_lookup_name), \5619 FN(kallsyms_lookup_name, 179, ##ctx) \
5620 FN(find_vma), \5620 FN(find_vma, 180, ##ctx) \
5621 FN(loop), \5621 FN(loop, 181, ##ctx) \
5622 FN(strncmp), \5622 FN(strncmp, 182, ##ctx) \
5623 FN(get_func_arg), \5623 FN(get_func_arg, 183, ##ctx) \
5624 FN(get_func_ret), \5624 FN(get_func_ret, 184, ##ctx) \
5625 FN(get_func_arg_cnt), \5625 FN(get_func_arg_cnt, 185, ##ctx) \
5626 FN(get_retval), \5626 FN(get_retval, 186, ##ctx) \
5627 FN(set_retval), \5627 FN(set_retval, 187, ##ctx) \
5628 FN(xdp_get_buff_len), \5628 FN(xdp_get_buff_len, 188, ##ctx) \
5629 FN(xdp_load_bytes), \5629 FN(xdp_load_bytes, 189, ##ctx) \
5630 FN(xdp_store_bytes), \5630 FN(xdp_store_bytes, 190, ##ctx) \
5631 FN(copy_from_user_task), \5631 FN(copy_from_user_task, 191, ##ctx) \
5632 FN(skb_set_tstamp), \5632 FN(skb_set_tstamp, 192, ##ctx) \
5633 FN(ima_file_hash), \5633 FN(ima_file_hash, 193, ##ctx) \
5634 FN(kptr_xchg), \5634 FN(kptr_xchg, 194, ##ctx) \
5635 FN(map_lookup_percpu_elem), \5635 FN(map_lookup_percpu_elem, 195, ##ctx) \
5636 FN(skc_to_mptcp_sock), \5636 FN(skc_to_mptcp_sock, 196, ##ctx) \
5637 FN(dynptr_from_mem), \5637 FN(dynptr_from_mem, 197, ##ctx) \
5638 FN(ringbuf_reserve_dynptr), \5638 FN(ringbuf_reserve_dynptr, 198, ##ctx) \
5639 FN(ringbuf_submit_dynptr), \5639 FN(ringbuf_submit_dynptr, 199, ##ctx) \
5640 FN(ringbuf_discard_dynptr), \5640 FN(ringbuf_discard_dynptr, 200, ##ctx) \
5641 FN(dynptr_read), \5641 FN(dynptr_read, 201, ##ctx) \
5642 FN(dynptr_write), \5642 FN(dynptr_write, 202, ##ctx) \
5643 FN(dynptr_data), \5643 FN(dynptr_data, 203, ##ctx) \
5644 FN(tcp_raw_gen_syncookie_ipv4), \5644 FN(tcp_raw_gen_syncookie_ipv4, 204, ##ctx) \
5645 FN(tcp_raw_gen_syncookie_ipv6), \5645 FN(tcp_raw_gen_syncookie_ipv6, 205, ##ctx) \
5646 FN(tcp_raw_check_syncookie_ipv4), \5646 FN(tcp_raw_check_syncookie_ipv4, 206, ##ctx) \
5647 FN(tcp_raw_check_syncookie_ipv6), \5647 FN(tcp_raw_check_syncookie_ipv6, 207, ##ctx) \
5648 FN(ktime_get_tai_ns), \5648 FN(ktime_get_tai_ns, 208, ##ctx) \
5649 FN(user_ringbuf_drain), \5649 FN(user_ringbuf_drain, 209, ##ctx) \
5650 /* */5650 /* */
5651 5651
5652/* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't
5653 * know or care about integer value that is now passed as second argument
5654 */
5655#define __BPF_FUNC_MAPPER_APPLY(name, value, FN) FN(name),
5656#define __BPF_FUNC_MAPPER(FN) ___BPF_FUNC_MAPPER(__BPF_FUNC_MAPPER_APPLY, FN)
5657
5652/* integer value in 'imm' field of BPF_CALL instruction selects which helper5658/* integer value in 'imm' field of BPF_CALL instruction selects which helper
5653 * function eBPF program intends to call5659 * function eBPF program intends to call
5654 */5660 */
5655#define __BPF_ENUM_FN(x) BPF_FUNC_ ## x5661#define __BPF_ENUM_FN(x, y) BPF_FUNC_ ## x = y,
5656enum bpf_func_id {5662enum bpf_func_id {
5657 __BPF_FUNC_MAPPER(__BPF_ENUM_FN)5663 ___BPF_FUNC_MAPPER(__BPF_ENUM_FN)
5658 __BPF_FUNC_MAX_ID,5664 __BPF_FUNC_MAX_ID,
5659};5665};
5660#undef __BPF_ENUM_FN5666#undef __BPF_ENUM_FN