bpf: more flexible support for kernel helpers
authorJose E. Marchesi <jose.marchesi@oracle.com>
Thu, 6 Aug 2020 12:13:59 +0000 (14:13 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Thu, 6 Aug 2020 12:13:59 +0000 (14:13 +0200)
This patch changes the existing support for BPF kernel helpers to be
more flexible, in two main ways.

First, there is no longer a hardcoded list of kernel helpers defined
in the compiler internals.  This is replaced by a new target-specific
attribute `kernel_helper' that the user can use to define her own
helpers, annotating function prototypes.

Second, following feedback from the kernel hackers, the pre-defined
helpers in the distributed bpf-helpers.h are no longer available
conditionally depending on the kernel version used in -mkernel.  The
command-line option stays for now, as it may be useful for other
things.

Target tests and documentation updated.

2020-08-06  Jose E. Marchesi  <jose.marchesi@oracle.com>

gcc/
* config/bpf/bpf-helpers.h (KERNEL_HELPER): Define.
(KERNEL_VERSION): Remove.
* config/bpf/bpf-helpers.def: Delete.
* config/bpf/bpf.c (bpf_handle_fndecl_attribute): New function.
(bpf_attribute_table): Define.
(bpf_helper_names): Delete.
(bpf_helper_code): Likewise.
(enum bpf_builtins): Adjust to new helpers mechanism.
(bpf_output_call): Likewise.
(bpf_init_builtins): Likewise.
(bpf_init_builtins): Likewise.
* doc/extend.texi (BPF Function Attributes): New section.
(BPF Kernel Helpers): Delete section.

gcc/testsuite/
* gcc.target/bpf/helper-bind.c: Adjust to new kernel helpers
mechanism.
* gcc.target/bpf/helper-bpf-redirect.c: Likewise.
* gcc.target/bpf/helper-clone-redirect.c: Likewise.
* gcc.target/bpf/helper-csum-diff.c: Likewise.
* gcc.target/bpf/helper-csum-update.c: Likewise.
* gcc.target/bpf/helper-current-task-under-cgroup.c: Likewise.
* gcc.target/bpf/helper-fib-lookup.c: Likewise.
* gcc.target/bpf/helper-get-cgroup-classid.c: Likewise.
* gcc.target/bpf/helper-get-current-cgroup-id.c: Likewise.
* gcc.target/bpf/helper-get-current-comm.c: Likewise.
* gcc.target/bpf/helper-get-current-pid-tgid.c: Likewise.
* gcc.target/bpf/helper-get-current-task.c: Likewise.
* gcc.target/bpf/helper-get-current-uid-gid.c: Likewise.
* gcc.target/bpf/helper-get-hash-recalc.c: Likewise.
* gcc.target/bpf/helper-get-listener-sock.c: Likewise.
* gcc.target/bpf/helper-get-local-storage.c: Likewise.
* gcc.target/bpf/helper-get-numa-node-id.c: Likewise.
* gcc.target/bpf/helper-get-prandom-u32.c: Likewise.
* gcc.target/bpf/helper-get-route-realm.c: Likewise.
* gcc.target/bpf/helper-get-smp-processor-id.c: Likewise.
* gcc.target/bpf/helper-get-socket-cookie.c: Likewise.
* gcc.target/bpf/helper-get-socket-uid.c: Likewise.
* gcc.target/bpf/helper-get-stack.c: Likewise.
* gcc.target/bpf/helper-get-stackid.c: Likewise.
* gcc.target/bpf/helper-getsockopt.c: Likewise.
* gcc.target/bpf/helper-ktime-get-ns.c: Likewise.
* gcc.target/bpf/helper-l3-csum-replace.c: Likewise.
* gcc.target/bpf/helper-l4-csum-replace.c: Likewise.
* gcc.target/bpf/helper-lwt-push-encap.c: Likewise.
* gcc.target/bpf/helper-lwt-seg6-action.c: Likewise.
* gcc.target/bpf/helper-lwt-seg6-adjust-srh.c: Likewise.
* gcc.target/bpf/helper-lwt-seg6-store-bytes.c: Likewise.
* gcc.target/bpf/helper-map-delete-elem.c: Likewise.
* gcc.target/bpf/helper-map-lookup-elem.c: Likewise.
* gcc.target/bpf/helper-map-peek-elem.c: Likewise.
* gcc.target/bpf/helper-map-pop-elem.c: Likewise.
* gcc.target/bpf/helper-map-push-elem.c: Likewise.
* gcc.target/bpf/helper-map-update-elem.c: Likewise.
* gcc.target/bpf/helper-msg-apply-bytes.c: Likewise.
* gcc.target/bpf/helper-msg-cork-bytes.c: Likewise.
* gcc.target/bpf/helper-msg-pop-data.c: Likewise.
* gcc.target/bpf/helper-msg-pull-data.c: Likewise.
* gcc.target/bpf/helper-msg-push-data.c: Likewise.
* gcc.target/bpf/helper-msg-redirect-hash.c: Likewise.
* gcc.target/bpf/helper-msg-redirect-map.c: Likewise.
* gcc.target/bpf/helper-override-return.c: Likewise.
* gcc.target/bpf/helper-perf-event-output.c: Likewise.
* gcc.target/bpf/helper-perf-event-read-value.c: Likewise.
* gcc.target/bpf/helper-perf-event-read.c: Likewise.
* gcc.target/bpf/helper-perf-prog-read-value.c: Likewise.
* gcc.target/bpf/helper-probe-read-str.c: Likewise.
* gcc.target/bpf/helper-probe-read.c: Likewise.
* gcc.target/bpf/helper-probe-write-user.c: Likewise.
* gcc.target/bpf/helper-rc-keydown.c: Likewise.
* gcc.target/bpf/helper-rc-pointer-rel.c: Likewise.
* gcc.target/bpf/helper-rc-repeat.c: Likewise.
* gcc.target/bpf/helper-redirect-map.c: Likewise.
* gcc.target/bpf/helper-set-hash-invalid.c: Likewise.
* gcc.target/bpf/helper-set-hash.c: Likewise.
* gcc.target/bpf/helper-setsockopt.c: Likewise.
* gcc.target/bpf/helper-sk-fullsock.c: Likewise.
* gcc.target/bpf/helper-sk-lookup-tcp.c: Likewise.
* gcc.target/bpf/helper-sk-lookup-upd.c: Likewise.
* gcc.target/bpf/helper-sk-redirect-hash.c: Likewise.
* gcc.target/bpf/helper-sk-redirect-map.c: Likewise.
* gcc.target/bpf/helper-sk-release.c: Likewise.
* gcc.target/bpf/helper-sk-select-reuseport.c: Likewise.
* gcc.target/bpf/helper-sk-storage-delete.c: Likewise.
* gcc.target/bpf/helper-sk-storage-get.c: Likewise.
* gcc.target/bpf/helper-skb-adjust-room.c: Likewise.
* gcc.target/bpf/helper-skb-cgroup-id.c: Likewise.
* gcc.target/bpf/helper-skb-change-head.c: Likewise.
* gcc.target/bpf/helper-skb-change-proto.c: Likewise.
* gcc.target/bpf/helper-skb-change-tail.c: Likewise.
* gcc.target/bpf/helper-skb-change-type.c: Likewise.
* gcc.target/bpf/helper-skb-ecn-set-ce.c: Likewise.
* gcc.target/bpf/helper-skb-get-tunnel-key.c: Likewise.
* gcc.target/bpf/helper-skb-get-tunnel-opt.c: Likewise.
* gcc.target/bpf/helper-skb-get-xfrm-state.c: Likewise.
* gcc.target/bpf/helper-skb-load-bytes-relative.c: Likewise.
* gcc.target/bpf/helper-skb-load-bytes.c: Likewise.
* gcc.target/bpf/helper-skb-pull-data.c: Likewise.
* gcc.target/bpf/helper-skb-set-tunnel-key.c: Likewise.
* gcc.target/bpf/helper-skb-set-tunnel-opt.c: Likewise.
* gcc.target/bpf/helper-skb-store-bytes.c: Likewise.
* gcc.target/bpf/helper-skb-under-cgroup.c: Likewise.
* gcc.target/bpf/helper-skb-vlan-pop.c: Likewise.
* gcc.target/bpf/helper-skb-vlan-push.c: Likewise.
* gcc.target/bpf/helper-skc-lookup-tcp.c: Likewise.
* gcc.target/bpf/helper-sock-hash-update.c: Likewise.
* gcc.target/bpf/helper-sock-map-update.c: Likewise.
* gcc.target/bpf/helper-sock-ops-cb-flags-set.c: Likewise.
* gcc.target/bpf/helper-spin-lock.c: Likewise.
* gcc.target/bpf/helper-spin-unlock.c: Likewise.
* gcc.target/bpf/helper-strtol.c: Likewise.
* gcc.target/bpf/helper-strtoul.c: Likewise.
* gcc.target/bpf/helper-sysctl-get-current-value.c: Likewise.
* gcc.target/bpf/helper-sysctl-get-name.c: Likewise.
* gcc.target/bpf/helper-sysctl-get-new-value.c: Likewise.
* gcc.target/bpf/helper-sysctl-set-new-value.c: Likewise.
* gcc.target/bpf/helper-tail-call.c: Likewise.
* gcc.target/bpf/helper-tcp-check-syncookie.c: Likewise.
* gcc.target/bpf/helper-tcp-sock.c: Likewise.
* gcc.target/bpf/helper-trace-printk.c: Likewise.
* gcc.target/bpf/helper-xdp-adjust-head.c: Likewise.
* gcc.target/bpf/helper-xdp-adjust-meta.c: Likewise.
* gcc.target/bpf/helper-xdp-adjust-tail.c: Likewise.
* gcc.target/bpf/skb-ancestor-cgroup-id.c: Likewise.

112 files changed:
gcc/config/bpf/bpf-helpers.def [deleted file]
gcc/config/bpf/bpf-helpers.h
gcc/config/bpf/bpf.c
gcc/doc/extend.texi
gcc/testsuite/gcc.target/bpf/helper-bind.c
gcc/testsuite/gcc.target/bpf/helper-bpf-redirect.c
gcc/testsuite/gcc.target/bpf/helper-clone-redirect.c
gcc/testsuite/gcc.target/bpf/helper-csum-diff.c
gcc/testsuite/gcc.target/bpf/helper-csum-update.c
gcc/testsuite/gcc.target/bpf/helper-current-task-under-cgroup.c
gcc/testsuite/gcc.target/bpf/helper-fib-lookup.c
gcc/testsuite/gcc.target/bpf/helper-get-cgroup-classid.c
gcc/testsuite/gcc.target/bpf/helper-get-current-cgroup-id.c
gcc/testsuite/gcc.target/bpf/helper-get-current-comm.c
gcc/testsuite/gcc.target/bpf/helper-get-current-pid-tgid.c
gcc/testsuite/gcc.target/bpf/helper-get-current-task.c
gcc/testsuite/gcc.target/bpf/helper-get-current-uid-gid.c
gcc/testsuite/gcc.target/bpf/helper-get-hash-recalc.c
gcc/testsuite/gcc.target/bpf/helper-get-listener-sock.c
gcc/testsuite/gcc.target/bpf/helper-get-local-storage.c
gcc/testsuite/gcc.target/bpf/helper-get-numa-node-id.c
gcc/testsuite/gcc.target/bpf/helper-get-prandom-u32.c
gcc/testsuite/gcc.target/bpf/helper-get-route-realm.c
gcc/testsuite/gcc.target/bpf/helper-get-smp-processor-id.c
gcc/testsuite/gcc.target/bpf/helper-get-socket-cookie.c
gcc/testsuite/gcc.target/bpf/helper-get-socket-uid.c
gcc/testsuite/gcc.target/bpf/helper-get-stack.c
gcc/testsuite/gcc.target/bpf/helper-get-stackid.c
gcc/testsuite/gcc.target/bpf/helper-getsockopt.c
gcc/testsuite/gcc.target/bpf/helper-ktime-get-ns.c
gcc/testsuite/gcc.target/bpf/helper-l3-csum-replace.c
gcc/testsuite/gcc.target/bpf/helper-l4-csum-replace.c
gcc/testsuite/gcc.target/bpf/helper-lwt-push-encap.c
gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-action.c
gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-adjust-srh.c
gcc/testsuite/gcc.target/bpf/helper-lwt-seg6-store-bytes.c
gcc/testsuite/gcc.target/bpf/helper-map-delete-elem.c
gcc/testsuite/gcc.target/bpf/helper-map-lookup-elem.c
gcc/testsuite/gcc.target/bpf/helper-map-peek-elem.c
gcc/testsuite/gcc.target/bpf/helper-map-pop-elem.c
gcc/testsuite/gcc.target/bpf/helper-map-push-elem.c
gcc/testsuite/gcc.target/bpf/helper-map-update-elem.c
gcc/testsuite/gcc.target/bpf/helper-msg-apply-bytes.c
gcc/testsuite/gcc.target/bpf/helper-msg-cork-bytes.c
gcc/testsuite/gcc.target/bpf/helper-msg-pop-data.c
gcc/testsuite/gcc.target/bpf/helper-msg-pull-data.c
gcc/testsuite/gcc.target/bpf/helper-msg-push-data.c
gcc/testsuite/gcc.target/bpf/helper-msg-redirect-hash.c
gcc/testsuite/gcc.target/bpf/helper-msg-redirect-map.c
gcc/testsuite/gcc.target/bpf/helper-override-return.c
gcc/testsuite/gcc.target/bpf/helper-perf-event-output.c
gcc/testsuite/gcc.target/bpf/helper-perf-event-read-value.c
gcc/testsuite/gcc.target/bpf/helper-perf-event-read.c
gcc/testsuite/gcc.target/bpf/helper-perf-prog-read-value.c
gcc/testsuite/gcc.target/bpf/helper-probe-read-str.c
gcc/testsuite/gcc.target/bpf/helper-probe-read.c
gcc/testsuite/gcc.target/bpf/helper-probe-write-user.c
gcc/testsuite/gcc.target/bpf/helper-rc-keydown.c
gcc/testsuite/gcc.target/bpf/helper-rc-pointer-rel.c
gcc/testsuite/gcc.target/bpf/helper-rc-repeat.c
gcc/testsuite/gcc.target/bpf/helper-redirect-map.c
gcc/testsuite/gcc.target/bpf/helper-set-hash-invalid.c
gcc/testsuite/gcc.target/bpf/helper-set-hash.c
gcc/testsuite/gcc.target/bpf/helper-setsockopt.c
gcc/testsuite/gcc.target/bpf/helper-sk-fullsock.c
gcc/testsuite/gcc.target/bpf/helper-sk-lookup-tcp.c
gcc/testsuite/gcc.target/bpf/helper-sk-lookup-upd.c
gcc/testsuite/gcc.target/bpf/helper-sk-redirect-hash.c
gcc/testsuite/gcc.target/bpf/helper-sk-redirect-map.c
gcc/testsuite/gcc.target/bpf/helper-sk-release.c
gcc/testsuite/gcc.target/bpf/helper-sk-select-reuseport.c
gcc/testsuite/gcc.target/bpf/helper-sk-storage-delete.c
gcc/testsuite/gcc.target/bpf/helper-sk-storage-get.c
gcc/testsuite/gcc.target/bpf/helper-skb-adjust-room.c
gcc/testsuite/gcc.target/bpf/helper-skb-cgroup-id.c
gcc/testsuite/gcc.target/bpf/helper-skb-change-head.c
gcc/testsuite/gcc.target/bpf/helper-skb-change-proto.c
gcc/testsuite/gcc.target/bpf/helper-skb-change-tail.c
gcc/testsuite/gcc.target/bpf/helper-skb-change-type.c
gcc/testsuite/gcc.target/bpf/helper-skb-ecn-set-ce.c
gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-key.c
gcc/testsuite/gcc.target/bpf/helper-skb-get-tunnel-opt.c
gcc/testsuite/gcc.target/bpf/helper-skb-get-xfrm-state.c
gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes-relative.c
gcc/testsuite/gcc.target/bpf/helper-skb-load-bytes.c
gcc/testsuite/gcc.target/bpf/helper-skb-pull-data.c
gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-key.c
gcc/testsuite/gcc.target/bpf/helper-skb-set-tunnel-opt.c
gcc/testsuite/gcc.target/bpf/helper-skb-store-bytes.c
gcc/testsuite/gcc.target/bpf/helper-skb-under-cgroup.c
gcc/testsuite/gcc.target/bpf/helper-skb-vlan-pop.c
gcc/testsuite/gcc.target/bpf/helper-skb-vlan-push.c
gcc/testsuite/gcc.target/bpf/helper-skc-lookup-tcp.c
gcc/testsuite/gcc.target/bpf/helper-sock-hash-update.c
gcc/testsuite/gcc.target/bpf/helper-sock-map-update.c
gcc/testsuite/gcc.target/bpf/helper-sock-ops-cb-flags-set.c
gcc/testsuite/gcc.target/bpf/helper-spin-lock.c
gcc/testsuite/gcc.target/bpf/helper-spin-unlock.c
gcc/testsuite/gcc.target/bpf/helper-strtol.c
gcc/testsuite/gcc.target/bpf/helper-strtoul.c
gcc/testsuite/gcc.target/bpf/helper-sysctl-get-current-value.c
gcc/testsuite/gcc.target/bpf/helper-sysctl-get-name.c
gcc/testsuite/gcc.target/bpf/helper-sysctl-get-new-value.c
gcc/testsuite/gcc.target/bpf/helper-sysctl-set-new-value.c
gcc/testsuite/gcc.target/bpf/helper-tail-call.c
gcc/testsuite/gcc.target/bpf/helper-tcp-check-syncookie.c
gcc/testsuite/gcc.target/bpf/helper-tcp-sock.c
gcc/testsuite/gcc.target/bpf/helper-trace-printk.c
gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-head.c
gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-meta.c
gcc/testsuite/gcc.target/bpf/helper-xdp-adjust-tail.c
gcc/testsuite/gcc.target/bpf/skb-ancestor-cgroup-id.c

diff --git a/gcc/config/bpf/bpf-helpers.def b/gcc/config/bpf/bpf-helpers.def
deleted file mode 100644 (file)
index 249ad24..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/* Kernel helpers database.
-   Copyright (C) 2019-2020 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-/* This file contains the definition of the kernel helpers that are
-   available to eBPF programs.
-
-   The primary source for information on kernel helpers is the
-   linux/include/uapi/linux/bpf.h file in the Linux source tree.
-   Please keep this database in sync.
-
-   The first column is the first kernel version featuring the helper
-   function.  This should be an enumerate from bpf_kernel_version,
-   defined in bpf-opts.h.  Note that the backend assumes that helpers
-   never get deprecated in the kernel.  If that eventually happens,
-   then we will need to use a bitmask here instead of an enumerate.
-
-   The second column is the constant-name for the helper.
-   The third column is the program-name of the helper.
-
-   The fourth column is a list of names describing the types of the
-   values returned and accepted by the helper, in one of these forms:
-
-     TYPES (type1, type2, ..., 0)
-     VTYPES (type1, type2, ..., 0)
-
-   VTYPES should be used should the helper accept a variable number of
-   arguments, TYPES otherwise.  The valid type names are:
-
-     `vt' for void.
-     `it' for signed int.
-     `ut' for unsigned int.
-     `pt' for void*.
-     `cpt' for const void*.
-     `st' for short int.
-     `ust' for unsigned short int.
-     `cst' for const char *.
-     `ullt' for unsigned long long.
-     `llt' for long long.
-     `u32t' for uint32.
-     `u64t' for uint64.
-  
-   In types descriptions, the firt entry corresponds to the value
-   returned by the helper.  Subsequent names correspond to the helper
-   arguments.  Finally, a 0 should close the list.
-
-   VERY IMPORTANT: the helper entries should be listed in the same
-   order than in the definition of __BPF_FUNC_MAPPER in
-   linux/include/uapi/linux/bpf.h!  */
-
-DEF_HELPER (LINUX_V4_0, MAP_LOOKUP_ELEM, map_lookup_elem, TYPES (pt, pt, pt, 0))
-DEF_HELPER (LINUX_V4_0, MAP_UPDATE_ELEM, map_update_elem, TYPES (it, pt, pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V4_0, MAP_DELETE_ELEM, map_delete_elem, TYPES (it, pt, pt, 0))
-DEF_HELPER (LINUX_V4_1, PROBE_READ, probe_read, TYPES (it, pt, ut, cpt, 0))
-DEF_HELPER (LINUX_V4_1, KTIME_GET_NS, ktime_get_ns, TYPES (ullt, 0))
-DEF_HELPER (LINUX_V4_1, TRACE_PRINTK, trace_printk, VTYPES (it, cst, it, 0))
-DEF_HELPER (LINUX_V4_1, GET_PRANDOM_U32, get_prandom_u32, TYPES (ullt, 0))
-DEF_HELPER (LINUX_V4_1, GET_SMP_PROCESSOR_ID, get_smp_processor_id, TYPES (ullt, 0))
-DEF_HELPER (LINUX_V4_1, SKB_STORE_BYTES, skb_store_bytes, TYPES (it, pt, it, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_1, L3_CSUM_REPLACE, l3_csum_replace, TYPES (it, pt, it, it ,it ,it, 0))
-DEF_HELPER (LINUX_V4_1, L4_CSUM_REPLACE, l4_csum_replace, TYPES (it, pt, it, it, it, it, 0))
-DEF_HELPER (LINUX_V4_2, TAIL_CALL, tail_call, TYPES (vt, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_2, CLONE_REDIRECT, clone_redirect, TYPES (it, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_2, GET_CURRENT_PID_TGID, get_current_pid_tgid, TYPES (ullt, 0))
-DEF_HELPER (LINUX_V4_2, GET_CURRENT_UID_GID, get_current_uid_gid, TYPES (ullt, 0))
-DEF_HELPER (LINUX_V4_2, GET_CURRENT_COMM, get_current_comm, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_3, GET_CGROUP_CLASSID, get_cgroup_classid, TYPES (it, pt, 0))
-DEF_HELPER (LINUX_V4_3, SKB_VLAN_PUSH, skb_vlan_push, TYPES (it, pt, st, ust, 0))
-DEF_HELPER (LINUX_V4_3, SKB_VLAN_POP, skb_vlan_pop, TYPES (it, pt, 0))
-DEF_HELPER (LINUX_V4_3, SKB_GET_TUNNEL_KEY, skb_get_tunnel_key, TYPES (it, pt, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_3, SKB_SET_TUNNEL_KEY, skb_set_tunnel_key, TYPES (it, pt, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_3, PERF_EVENT_READ, perf_event_read, TYPES (ullt, pt, ullt, 0))
-DEF_HELPER (LINUX_V4_4, REDIRECT, redirect, TYPES (it, it, it, 0))
-DEF_HELPER (LINUX_V4_4, GET_ROUTE_REALM, get_route_realm, TYPES (ut, pt, 0))
-DEF_HELPER (LINUX_V4_4, PERF_EVENT_OUTPUT, perf_event_output, \
-           TYPES (it, pt, pt, ullt, pt, it, 0))
-DEF_HELPER (LINUX_V4_5, SKB_LOAD_BYTES, skb_load_bytes, TYPES (it, pt, it, pt, it, 0))
-DEF_HELPER (LINUX_V4_6, GET_STACKID, get_stackid, TYPES (it, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_6, CSUM_DIFF, csum_diff, TYPES (it, pt, it, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_6, SKB_GET_TUNNEL_OPT, skb_get_tunnel_opt, TYPES (it, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_6, SKB_SET_TUNNEL_OPT, skb_set_tunnel_opt, TYPES (it, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_8, SKB_CHANGE_PROTO, skb_change_proto, TYPES (it, pt, st, u64t, 0))
-DEF_HELPER (LINUX_V4_8, SKB_CHANGE_TYPE, skb_change_type, TYPES (it, pt, u32t, 0))
-DEF_HELPER (LINUX_V4_8, SKB_UNDER_CGROUP, skb_under_cgroup, TYPES (it, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_8, GET_HASH_RECALC, get_hash_recalc, TYPES (ut, pt, 0))
-DEF_HELPER (LINUX_V4_8, GET_CURRENT_TASK, get_current_task, TYPES (ullt, 0))
-DEF_HELPER (LINUX_V4_8, PROBE_WRITE_USER, probe_write_user, TYPES (it, pt, cpt, ut, 0))
-DEF_HELPER (LINUX_V4_9, CURRENT_TASK_UNDER_CGROUP, current_task_under_cgroup, \
-           TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_9, SKB_CHANGE_TAIL, skb_change_tail, TYPES (it, pt, ut, u64t, 0))
-DEF_HELPER (LINUX_V4_9, SKB_PULL_DATA, skb_pull_data, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_9, CSUM_UPDATE, csum_update, TYPES (llt, pt, u32t, 0))
-DEF_HELPER (LINUX_V4_9, SET_HASH_INVALID, set_hash_invalid, TYPES (vt, pt, 0))
-DEF_HELPER (LINUX_V4_10, GET_NUMA_NODE_ID, get_numa_node_id, TYPES (it, 0))
-DEF_HELPER (LINUX_V4_10, SKB_CHANGE_HEAD, skb_change_head, TYPES (it, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_10, XDP_ADJUST_HEAD, xdp_adjust_head, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_11, PROBE_READ_STR, probe_read_str, TYPES (it, pt, u32t, cpt, 0))
-DEF_HELPER (LINUX_V4_12, GET_SOCKET_COOKIE, get_socket_cookie, TYPES (it, pt, 0))
-DEF_HELPER (LINUX_V4_12, GET_SOCKET_UID, get_socket_uid, TYPES (ut, pt, 0))
-DEF_HELPER (LINUX_V4_13, SET_HASH, set_hash, TYPES (ut, pt, u32t, 0))
-DEF_HELPER (LINUX_V4_13, SETSOCKOPT, setsockopt, TYPES (it, pt, it, it, pt, it, 0))
-DEF_HELPER (LINUX_V4_13, SKB_ADJUST_ROOM, skb_adjust_room, TYPES (it, pt, st, u32t, ullt, 0))
-DEF_HELPER (LINUX_V4_14, REDIRECT_MAP, redirect_map, TYPES (it, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_14, SK_REDIRECT_MAP, sk_redirect_map, TYPES (it, pt, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_14, SOCK_MAP_UPDATE, sock_map_update, TYPES (it, pt, pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V4_15, XDP_ADJUST_META, xdp_adjust_meta, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_15, PERF_EVENT_READ_VALUE, perf_event_read_value,
-           TYPES (it, pt, ullt, pt, ut, 0))
-DEF_HELPER (LINUX_V4_15, PERF_PROG_READ_VALUE, perf_prog_read_value,
-           TYPES (it, pt, pt, ut, 0))
-DEF_HELPER (LINUX_V4_15, GETSOCKOPT, getsockopt, TYPES (it, pt, it, it, pt, it, 0))
-
-DEF_HELPER (LINUX_V4_16, OVERRIDE_RETURN, override_return, TYPES (it, pt, ult, 0))
-DEF_HELPER (LINUX_V4_16, SOCK_OPS_CB_FLAGS_SET, sock_ops_cb_flags_set, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_17, MSG_REDIRECT_MAP, msg_redirect_map, TYPES (it, pt, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_17, MSG_APPLY_BYTES, msg_apply_bytes, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_17, MSG_CORK_BYTES, msg_cork_bytes, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_17, MSG_PULL_DATA, msg_pull_data, TYPES (it, pt, it, it, it, 0))
-DEF_HELPER (LINUX_V4_17, BIND, bind, TYPES (it, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_18, XDP_ADJUST_TAIL, xdp_adjust_tail, TYPES (it, pt, it, 0))
-DEF_HELPER (LINUX_V4_18, SKB_GET_XFRM_STATE,
-           skb_get_xfrm_state, TYPES (it, pt, it, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_18, GET_STACK, get_stack, TYPES (it, pt, pt, it, it, 0))
-DEF_HELPER (LINUX_V4_18, SKB_LOAD_BYTES_RELATIVE, skb_load_bytes_relative,
-           TYPES (it, pt, it, pt, it, ut, 0))
-DEF_HELPER (LINUX_V4_18, FIB_LOOKUP, fib_lookup, TYPES (it, pt, pt, it, ut, 0))
-DEF_HELPER (LINUX_V4_18, SOCK_HASH_UPDATE, sock_hash_update, TYPES (it, pt, pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V4_18, MSG_REDIRECT_HASH, msg_redirect_hash, TYPES (it, pt, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_18, SK_REDIRECT_HASH, sk_redirect_hash, TYPES (it, pt, pt, pt, it, 0))
-DEF_HELPER (LINUX_V4_18, LWT_PUSH_ENCAP, lwt_push_encap, TYPES (it, pt, ut, pt, ut, 0))
-DEF_HELPER (LINUX_V4_18, LWT_SEG6_STORE_BYTES, lwt_seg6_store_bytes,
-           TYPES (it, pt, ut, pt, ut, 0))
-DEF_HELPER (LINUX_V4_18, LWT_SEG6_ADJUST_SRH, lwt_seg6_adjust_srh, TYPES (it, pt, ut, ut, 0))
-DEF_HELPER (LINUX_V4_18, LWT_SEG6_ACTION, lwt_seg6_action, TYPES (it, pt, ut, pt, ut, 0))
-DEF_HELPER (LINUX_V4_18, RC_REPEAT, rc_repeat, TYPES (it, pt, 0))
-DEF_HELPER (LINUX_V4_18, RC_KEYDOWN, rc_keydown, TYPES (it, pt, ut, ullt, ut, 0))
-DEF_HELPER (LINUX_V4_18, SKB_CGROUP_ID, skb_cgroup_id, TYPES (ullt, pt, 0))
-DEF_HELPER (LINUX_V4_18, GET_CURRENT_CGROUP_ID, get_current_cgroup_id, TYPES (ullt, 0))
-DEF_HELPER (LINUX_V4_19, GET_LOCAL_STORAGE, get_local_storage, TYPES (pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V4_19, SK_SELECT_REUSEPORT, sk_select_reuseport,
-           TYPES (it, pt, pt, pt, ut, 0))
-DEF_HELPER (LINUX_V4_19, SKB_ANCESTOR_CGROUP_ID, skb_ancestor_cgroup_id,
-           TYPES (ullt, pt, it, 0))
-DEF_HELPER (LINUX_V4_20, SK_LOOKUP_TCP, sk_lookup_tcp, TYPES (pt, pt, pt, it, ullt, ullt, 0))
-DEF_HELPER (LINUX_V4_20, SK_LOOKUP_UDP, sk_lookup_udp, TYPES (pt, pt, pt, it, ullt, ullt, 0))
-DEF_HELPER (LINUX_V4_20, SK_RELEASE, sk_release, TYPES (it, pt, 0))
-DEF_HELPER (LINUX_V4_20, MAP_PUSH_ELEM, map_push_elem, TYPES (it, pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V4_20, MAP_POP_ELEM, map_pop_elem, TYPES (it, pt, pt, 0))
-DEF_HELPER (LINUX_V4_20, MAP_PEEK_ELEM, map_peek_elem, TYPES (it, pt, pt, 0))
-DEF_HELPER (LINUX_V4_20, MSG_PUSH_DATA, msg_push_data, TYPES (it, pt, it, it, it, 0))
-DEF_HELPER (LINUX_V5_0, MSG_POP_DATA, msg_pop_data, TYPES (it, pt, it, it, it, 0))
-DEF_HELPER (LINUX_V5_0, RC_POINTER_REL, rc_pointer_rel, TYPES (it, pt, it, it, 0))
-DEF_HELPER (LINUX_V5_1, SPIN_LOCK, spin_lock, TYPES (vt, pt, 0))
-DEF_HELPER (LINUX_V5_1, SPIN_UNLOCK, spin_unlock, TYPES (vt, pt, 0))
-DEF_HELPER (LINUX_V5_1, SK_FULLSOCK, sk_fullsock, TYPES (pt, pt, 0))
-DEF_HELPER (LINUX_V5_1, TCP_SOCK, tcp_sock, TYPES (pt, pt, 0))
-DEF_HELPER (LINUX_V5_1, SKB_ECN_SET_CE, skb_ecn_set_ce, TYPES (it, pt, 0))
-DEF_HELPER (LINUX_V5_1, GET_LISTENER_SOCK, get_listener_sock, TYPES (pt, pt, 0))
-DEF_HELPER (LINUX_V5_2, SKC_LOOKUP_TCP, skc_lookup_tcp,
-           TYPES (pt, pt, pt, u32t, u64t, u64t, 0))
-DEF_HELPER (LINUX_V5_2, TCP_CHECK_SYNCOOKIE, tcp_check_syncookie,
-           TYPES (it, pt, pt, u32t, pt, u32t, 0))
-DEF_HELPER (LINUX_V5_2, SYSCTL_GET_NAME, sysctl_get_name, TYPES (it, pt, pt, ullt, u64t, 0))
-DEF_HELPER (LINUX_V5_2, SYSCTL_GET_CURRENT_VALUE, sysctl_get_current_value,
-           TYPES (it, pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V5_2, SYSCTL_GET_NEW_VALUE, sysctl_get_new_value,
-           TYPES (it, pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V5_2, SYSCTL_SET_NEW_VALUE, sysctl_set_new_value,
-           TYPES (it, pt, pt, ullt, 0))
-DEF_HELPER (LINUX_V5_2, STRTOL, strtol, TYPES (it, cst, ullt, u64t, pt, 0))
-DEF_HELPER (LINUX_V5_2, STRTOUL, strtoul, TYPES (it, pt, ullt, u64t, pt, 0))
-DEF_HELPER (LINUX_V5_2, SK_STORAGE_GET, sk_storage_get, TYPES (pt, pt, pt, pt, u64t, 0))
-DEF_HELPER (LINUX_V5_2, SK_STORAGE_DELETE, sk_storage_delete, TYPES (it, pt, pt, 0))
-
-/*
-Local variables:
-mode:c
-End:
-*/
index 1dd05c8..a615321 100644 (file)
@@ -30,6 +30,7 @@
 #define __BPF_HELPERS_H
 
 #define SEC(NAME) __attribute__((section(NAME), used))
+#define KERNEL_HELPER(NUM) __attribute__((kernel_helper(NUM)))
 
 /* Flags used in some kernel helpers.  */
 
 #define BPF_F_NO_COMMON_LRU (1U << 1)
 #define BPF_F_NUMA_NODE (1U << 2)
 
-/* Functions to call kernel helpers.  We provide the "standard" bpf_*
-   names as synonyms of the corresponding GCC builtins.  In some
-   cases, where non-void pointers are passed to the helper, inline
-   functions are used to achieve proper type checking.  */
+/* Prototypes of functions to call kernel helpers.
+   Please keep these protoypes sorted by helper number.  */
 
-#ifndef KERNEL_VERSION
-# define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
+void *bpf_map_lookup_elem (void *map, const void *key)
+  KERNEL_HELPER (1);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,0,0)
+int bpf_map_update_elem (void *map, const void *key, const void *value,
+                        unsigned long long flags)
+  KERNEL_HELPER (2);
 
-#define bpf_map_lookup_elem    __builtin_bpf_helper_map_lookup_elem
-#define bpf_map_update_elem    __builtin_bpf_helper_map_update_elem
-#define bpf_map_delete_elem    __builtin_bpf_helper_map_delete_elem
+int bpf_map_delete_elem (void *map, const void *key)
+  KERNEL_HELPER (3);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,1,0)
+int bpf_probe_read (void *dst, int size, const void *unsafe_ptr)
+  KERNEL_HELPER (4);
 
-#define bpf_probe_read         __builtin_bpf_helper_probe_read
-#define bpf_ktime_get_ns       __builtin_bpf_helper_ktime_get_ns
-#define bpf_trace_printk       __builtin_bpf_helper_trace_printk
-#define bpf_get_prandom_u32    __builtin_bpf_helper_get_prandom_u32
-#define bpf_get_smp_processor_id __builtin_bpf_helper_get_smp_processor_id
-#define bpf_skb_store_bytes    __builtin_bpf_helper_skb_store_bytes
-#define bpf_l3_csum_replace    __builtin_bpf_helper_l3_csum_replace
-#define bpf_l4_csum_replace    __builtin_bpf_helper_l4_csum_replace
+unsigned long long bpf_ktime_get_ns (void)
+  KERNEL_HELPER (5);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,2,0)
+int bpf_trace_printk (const char *fmt, int fmt_size, ...)
+  KERNEL_HELPER (6);
 
-#define bpf_tail_call          __builtin_bpf_helper_tail_call
-#define bpf_clone_redirect     __builtin_bpf_helper_clone_redirect
-#define bpf_get_current_pid_tgid __builtin_bpf_helper_get_current_pid_tgid
-#define bpf_get_current_uid_gid  __builtin_bpf_helper_get_current_uid_gid
-#define bpf_get_current_comm   __builtin_bpf_helper_get_current_comm
+unsigned long long bpf_get_prandom_u32 (void)
+  KERNEL_HELPER (7);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,3,0)
+unsigned long long bpf_get_smp_processor_id (void)
+  KERNEL_HELPER (8);
 
-#define bpf_get_cgroup_classid __builtin_bpf_helper_get_cgroup_classid
-#define bpf_skb_vlan_push      __builtin_bpf_helper_skb_vlan_push
-#define bpf_skb_vlan_pop       __builtin_bpf_helper_skb_vlan_pop
-#define bpf_skb_get_tunnel_key __builtin_bpf_helper_skb_get_tunnel_key
-#define bpf_skb_set_tunnel_key __builtin_bpf_helper_skb_set_tunnel_key
-#define bpf_perf_event_read    __builtin_bpf_helper_perf_event_read
+int bpf_skb_store_bytes (void *ctx, int off, void *from, int len,
+                        unsigned int start_header)
+  KERNEL_HELPER (9);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,4,0)
+int bpf_l3_csum_replace (void *ctx, int off, int from, int to, int flags)
+  KERNEL_HELPER (10);
 
-#define bpf_redirect           __builtin_bpf_helper_redirect
-#define bpf_get_route_realm    __builtin_bpf_helper_get_route_realm
-#define bpf_perf_event_output  __builtin_bpf_helper_perf_event_output
+int bpf_l4_csum_replace (void *ctx, int off, int from, int to, int flags)
+  KERNEL_HELPER (11);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,5,0)
+int bpf_tail_call (void *ctx, void *map, unsigned int index)
+  KERNEL_HELPER (12);
 
-#define bpf_skb_load_bytes     __builtin_bpf_helper_skb_load_bytes
+int bpf_clone_redirect (void *ctx, int ifindex, int flags)
+  KERNEL_HELPER (13);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,6,0)
+unsigned long long bpf_get_current_pid_tgid (void)
+  KERNEL_HELPER (14);
 
-#define bpf_get_stackid                __builtin_bpf_helper_get_stackid
-#define bpf_csum_diff          __builtin_bpf_helper_csum_diff
-#define bpf_skb_get_tunnel_opt __builtin_bpf_helper_skb_get_tunnel_opt
-#define bpf_skb_set_tunnel_opt __builtin_bpf_helper_skb_set_tunnel_opt
+unsigned long long bpf_get_current_uid_gid (void)
+  KERNEL_HELPER (15);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,8,0)
+int bpf_get_current_comm (void *buf, int buf_size)
+  KERNEL_HELPER (16);
 
-#define bpf_skb_change_proto   __builtin_bpf_helper_skb_change_proto
-#define bpf_skb_change_type    __builtin_bpf_helper_skb_change_type
-#define bpf_skb_under_cgroup   __builtin_bpf_helper_skb_under_cgroup
-#define bpf_get_hash_recalc    __builtin_bpf_helper_get_hash_recalc
-#define bpf_get_current_task   __builtin_bpf_helper_get_current_task
-#define bpf_probe_write_user   __builtin_bpf_helper_probe_write_user
+unsigned int bpf_get_cgroup_classid (void *ctx)
+  KERNEL_HELPER (17);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,9,0)
+int bpf_skb_vlan_push (void *ctx, short vlan_proto,
+                      unsigned short vlan_tci)
+  KERNEL_HELPER (18);
 
-#define bpf_current_task_under_cgroup __builtin_bpf_helper_current_task_under_cgroup
-#define bpf_skb_change_tail    __builtin_bpf_helper_skb_change_tail
-#define bpf_skb_pull_data      __builtin_bpf_helper_skb_pull_data
-#define bpf_csum_update                __builtin_bpf_helper_csum_update
-#define bpf_set_hash_invalid   __builtin_bpf_helper_set_hash_invalid
+int bpf_skb_vlan_pop (void *ctx)
+  KERNEL_HELPER (19);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,10,0)
+int bpf_skb_get_tunnel_key (void *ctx, void *key, int size, int flags)
+  KERNEL_HELPER (20);
 
-#define bpf_get_numa_node_id   __builtin_bpf_helper_get_numa_node_id
-#define bpf_skb_change_head    __builtin_bpf_helper_skb_change_head
-#define bpf_xdp_adjust_head    __builtin_bpf_helper_xdp_adjust_head
+int bpf_skb_set_tunnel_key (void *ctx, void *key, int size, int flags)
+  KERNEL_HELPER (21);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,11,0)
+unsigned long long bpf_perf_event_read (void *map, unsigned long long flags)
+  KERNEL_HELPER (22);
 
-#define bpf_probe_read_str     __builtin_bpf_helper_probe_read_str
+int bpf_redirect (int ifindex, int flags)
+  KERNEL_HELPER (23);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,12,0)
+unsigned int bpf_get_route_realm (void *ctx)
+  KERNEL_HELPER (24);
 
-#define bpf_get_socket_cookie  __builtin_bpf_helper_get_socket_cookie
-#define bpf_get_socket_uid     __builtin_bpf_helper_get_socket_uid
+int bpf_perf_event_output (void *ctx, void *map, unsigned long long flags,
+                          void *data, int size)
+  KERNEL_HELPER (25);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,13,0)
+int bpf_skb_load_bytes (void *ctx, int off, void *to, int len)
+  KERNEL_HELPER (26);
 
-#define bpf_set_hash           __builtin_bpf_helper_set_hash
-#define bpf_setsockopt         __builtin_bpf_helper_setsockopt
-#define bpf_skb_adjust_room    __builtin_bpf_helper_skb_adjust_room
+int bpf_get_stackid (void *ctx, void *map, int flags)
+  KERNEL_HELPER (27);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,14,0)
+int bpf_csum_diff (void *from, int from_size, void *to, int to_size, int seed)
+  KERNEL_HELPER (28);
 
-#define bpf_redirect_map       __builtin_bpf_helper_redirect_map
-#define bpf_sk_redirect_map    __builtin_bpf_helper_sk_redirect_map
-#define bpf_sock_map_update    __builtin_bpf_helper_sock_map_update
+int bpf_skb_get_tunnel_opt (void *ctx, void *md, int size)
+  KERNEL_HELPER (29);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,15,0)
+int bpf_skb_set_tunnel_opt (void *ctx, void *md, int size)
+  KERNEL_HELPER (30);
 
-#define bpf_perf_event_read_value __builtin_bpf_helper_perf_event_read_value
-#define bpf_perf_prog_read_value  __builtin_bpf_helper_perf_prog_read_value
-#define bpf_getsockopt           __builtin_bpf_helper_getsockopt
-#define bpf_xdp_adjust_meta    __builtin_bpf_helper_xdp_adjust_meta
+int bpf_skb_change_proto (void *ctx, short proto, unsigned long flags)
+  KERNEL_HELPER (31);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,16,0)
+int bpf_skb_change_type (void *ctx, unsigned int type)
+  KERNEL_HELPER (32);
 
-#define bpf_override_return    __builtin_bpf_helper_override_return
-#define bpf_sock_ops_cb_flags_set __builtin_bpf_helper_sock_ops_cb_flags_set
+int bpf_skb_under_cgroup (void *ctx, void *map, int index)
+  KERNEL_HELPER (33);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,17,0)
+unsigned int bpf_get_hash_recalc (void *ctx)
+  KERNEL_HELPER (34);
 
-#define bpf_msg_redirect_map   __builtin_bpf_helper_msg_redirect_map
-#define bpf_msg_apply_bytes    __builtin_bpf_helper_msg_apply_bytes
-#define bpf_msg_cork_bytes     __builtin_bpf_helper_msg_cork_bytes
-#define bpf_pull_data          __builtin_bpf_helper_pull_data
-#define bpf_bind               __builtin_bpf_helper_bpf_bind
+unsigned long long bpf_get_current_task (void)
+  KERNEL_HELPER (35);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,18,0)
+int bpf_probe_write_user (void *dst, const void *src, int size)
+  KERNEL_HELPER (36);
 
-#define bpf_xdp_adjust_tail    __builtin_bpf_helper_xdp_adjust_tail
-#define bpf_skb_get_xfrm_state __builtin_bpf_helper_skb_get_xfrm_state
-#define bpf_get_stack          __builtin_bpf_helper_get_stack
-#define bpf_skb_load_bytes_relative __builtin_bpf_helper_skb_load_bytes_relative
-#define bpf_sock_hash_update   __builtin_bpf_helper_sock_hash_update
-#define bpf_msg_redirect_hash  __builtin_bpf_helper_msg_redirect_hash
-#define bpf_sk_redirect_hash   __builtin_bpf_helper_sk_redirect_hash
-#define bpf_lwt_push_encap             __builtin_bpf_helper_lwt_push_encap
-#define bpf_lwt_seg6_store_bytes       __builtin_bpf_helper_lwt_seg6_store_bytes
-#define bpf_lwt_seg6_adjust_srh                __builtin_bpf_helper_lwt_seg6_adjust_srh
-#define bpf_lwt_seg6_action            __builtin_bpf_helper_lwt_seg6_action
-#define bpf_rc_repeat                  __builtin_bpf_helper_rc_repeat
-#define bpf_rc_keydown                 __builtin_bpf_helper_rc_keydown
-#define bpf_skb_cgroup_id              __builtin_bpf_helper_skb_cgroup_id
-#define bpf_get_current_cgroup_id      __builtin_bpf_helper_get_current_cgroup_id
+int bpf_current_task_under_cgroup (void *map, int index)
+  KERNEL_HELPER (37);
 
-static inline int
-bpf_fib_lookup (void *ctx, struct bpf_fib_lookup *param, int plen,
-               unsigned int flags)
-{
-  return __builtin_bpf_helper_fib_lookup (ctx, (void *) param, plen, flags);
-}
+int bpf_skb_change_tail (void *ctx, unsigned int len, unsigned long flags)
+  KERNEL_HELPER (38);
 
+int bpf_skb_pull_data (void *, int len)
+  KERNEL_HELPER (39);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,19,0)
+long long bpf_csum_update (void *ctx, unsigned int csum)
+  KERNEL_HELPER (40);
 
-#define bpf_get_local_storage  __builtin_bpf_helper_get_local_storage
-#define bpf_sk_select_reuseport        __builtin_bpf_helper_sk_select_reuseport
-#define bpf_skb_ancestor_cgroup_id     __builtin_bpf_helper_skb_ancestor_cgroup_id
+void bpf_set_hash_invalid (void *ctx)
+  KERNEL_HELPER (41);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (4,20,0)
+int bpf_get_numa_node_id (void)
+  KERNEL_HELPER (42);
 
-#define bpf_sk_release         __builtin_bpf_helper_sk_release
-#define bpf_map_push_elem      __builtin_bpf_helper_map_push_elem
-#define bpf_map_pop_elem       __builtin_bpf_helper_map_pop_elem
-#define bpf_map_peek_elem      __builtin_bpf_helper_map_peek_elem
-#define bpf_msg_push_data      __builtin_bpf_helper_msg_push_data
+int bpf_skb_change_head (void *, int len, int flags)
+  KERNEL_HELPER (43);
 
-static inline struct bpf_sock *
-bpf_sk_lookup_tcp (void *ctx, struct bpf_sock_tuple *tuple,
-                  int size, unsigned long long netns_id,
-                  unsigned long long flags)
-{
-  return
-    (struct bpf_sock *) __builtin_bpf_helper_sk_lookup_tcp (ctx,
-                                                           (void *) tuple,
-                                                           size,
-                                                           netns_id, flags);
-}
-
-static inline struct bpf_sock *
-bpf_sk_lookup_udp (void *ctx, struct bpf_sock_tuple *tuple,
-                  int size, unsigned long long netns_id,
-                  unsigned long long flags)
-{
-  return
-    (struct bpf_sock *) __builtin_bpf_helper_sk_lookup_udp (ctx,
-                                                           (void *) tuple,
-                                                           size,
-                                                           netns_id, flags);
-}
+int bpf_xdp_adjust_head (void *ctx, int offset)
+  KERNEL_HELPER (44);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (5,0,0)
+int bpf_probe_read_str (void *ctx, unsigned int size, const void *unsafe_ptr)
+  KERNEL_HELPER (45);
 
-#define bpf_msg_pop_data       __builtin_bpf_helper_pop_data
-#define bpf_rc_pointer_rel     __builtin_bpf_helper_rc_pointer_rel
+int bpf_get_socket_cookie (void *ctx)
+  KERNEL_HELPER (46);
 
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (5,1,0)
+unsigned int bpf_get_socket_uid (void *ctx)
+  KERNEL_HELPER (47);
 
-#define bpf_spin_lock          __builtin_bpf_helper_spin_lock
-#define bpf_spin_unlock                __builtin_bpf_helper_spin_unlock
-#define bpf_skb_ecn_set_ce     __builtin_bpf_helper_skb_ecn_set_ce
+unsigned int bpf_set_hash (void *ctx, unsigned int hash)
+  KERNEL_HELPER (48);
 
-static inline struct bpf_sock *
-bpf_sk_fullsock (struct bpf_sock *sk)
-{
-  return
-    (struct bpf_sock *) __builtin_bpf_helper_sk_fullsock ((void *) sk);
-}
+int bpf_setsockopt (void *ctx, int level, int optname, void *optval, int optlen)
+  KERNEL_HELPER (49);
 
-static inline struct bpf_sock *
-bpf_tcp_sock (struct bpf_sock *sk)
-{
-  return
-    (struct bpf_sock *) __builtin_bpf_helper_tcp_sock ((void *) sk);
-}
+int bpf_skb_adjust_room (void *ctx, int len_diff, unsigned int mode,
+                        unsigned long long flags)
+  KERNEL_HELPER (50);
 
-static inline struct bpf_sock *
-bpf_get_listener_sock (struct bpf_sock *sk)
-{
-  return
-    (struct bpf_sock *) __builtin_bpf_helper_get_listener_sock ((void *) sk);
-}
-
-#if __BPF_KERNEL_VERSION_CODE__ >= KERNEL_VERSION (5,2,0)
-
-
-#endif /* 5.2 */
-#endif /* 5.1 */
-#endif /* 5.0 */
-#endif /* 4.20 */
-#endif /* 4.19 */
-#endif /* 4.18 */
-#endif /* 4.17 */
-#endif /* 4.16 */
-#endif /* 4.15 */
-#endif /* 4.14 */
-#endif /* 4.13 */
-#endif /* 4.12 */
-#endif /* 4.11 */
-#endif /* 4.10 */
-#endif /* 4.9 */
-#endif /* 4.8 */
-#endif /* 4.6 */
-#endif /* 4.5 */
-#endif /* 4.4 */
-#endif /* 4.3 */
-#endif /* 4.2 */
-#endif /* 4.1 */
-#endif /* 4.0 */
+int bpf_redirect_map (void *map, int key, int flags)
+  KERNEL_HELPER (51);
+
+int bpf_sk_redirect_map (void *ctx, void *map, int key, int flags)
+  KERNEL_HELPER (52);
+
+int bpf_sock_map_update (void *map, void *key, void *value,
+                        unsigned long long flags)
+  KERNEL_HELPER (53);
+
+int bpf_xdp_adjust_meta (void *ctx, int offset)
+  KERNEL_HELPER (54);
+
+int bpf_perf_event_read_value (void *map, unsigned long long flags,
+                              void *buf, unsigned int buf_size)
+  KERNEL_HELPER (55);
+
+int bpf_perf_prog_read_value (void *ctx, void *buf, unsigned int buf_size)
+  KERNEL_HELPER (56);
+
+int bpf_getsockopt (void *ctx, int level, int optname, void *optval,
+                   int optlen)
+  KERNEL_HELPER (57);
+
+int bpf_override_return (void *ctx, unsigned long rc)
+  KERNEL_HELPER (58);
+
+int bpf_sock_ops_cb_flags_set (void *ctx, int flags)
+  KERNEL_HELPER (59);
+
+int bpf_msg_redirect_map (void *ctx, void *map, int key, int flags)
+  KERNEL_HELPER (60);
+
+int bpf_msg_apply_bytes (void *ctx, int len)
+  KERNEL_HELPER (61);
+
+int bpf_msg_cork_bytes (void *ctx, int len)
+  KERNEL_HELPER (62);
+
+int bpf_msg_pull_data (void *, int len)
+  KERNEL_HELPER (63);
+
+int bpf_bind (void *ctx, void *addr, int addr_len)
+  KERNEL_HELPER (64);
+
+int bpf_xdp_adjust_tail (struct xdp_md *xdp_md, int delta)
+  KERNEL_HELPER (65);
+
+int bpf_skb_get_xfrm_state (void *ctx, int index, void *state,
+                           int size, int flags)
+  KERNEL_HELPER (66);
+
+int bpf_get_stack (void *ctx, void *buf, int size, int flags)
+  KERNEL_HELPER (67);
+
+int bpf_skb_load_bytes_relative (void *ctx, int off, void *to, int len,
+                                unsigned int start_header)
+  KERNEL_HELPER (68);
+
+int bpf_fib_lookup (void *ctx, struct bpf_fib_lookup *params,
+                   int plen, unsigned int flags)
+  KERNEL_HELPER (69);
+
+int bpf_sock_hash_update (void *map, void *key, void *value,
+                         unsigned long long flags)
+  KERNEL_HELPER (70);
+
+int bpf_msg_redirect_hash (void *ctx, void *map, void *key, int flags)
+  KERNEL_HELPER (71);
+
+int bpf_sk_redirect_hash (void *ctx, void *map, void *key, int flags)
+  KERNEL_HELPER (72);
+
+int bpf_lwt_push_encap (void *ctx, unsigned int type, void *hdr,
+                       unsigned int len)
+  KERNEL_HELPER (73);
+
+int bpf_lwt_seg6_store_bytes (void *ctx, unsigned int offset,
+                             void *from, unsigned int len)
+  KERNEL_HELPER (74);
+
+int bpf_lwt_seg6_adjust_srh (void *ctx, unsigned int offset,
+                            unsigned int len)
+  KERNEL_HELPER (75);
+
+int bpf_lwt_seg6_action (void *ctx, unsigned int action, void *param,
+                        unsigned int param_len)
+  KERNEL_HELPER (76);
+
+int bpf_rc_repeat (void *ctx)
+  KERNEL_HELPER (77);
+
+int bpf_rc_keydown (void *ctx, unsigned int protocol,
+                   unsigned long long scancode, unsigned int toggle)
+  KERNEL_HELPER (78);
+
+unsigned bpf_skb_cgroup_id (void *ctx)
+  KERNEL_HELPER (79);
+
+unsigned long long bpf_get_current_cgroup_id (void)
+  KERNEL_HELPER (80);
+
+void *bpf_get_local_storage (void *map, unsigned long long flags)
+  KERNEL_HELPER (81);
+
+int bpf_sk_select_reuseport (void *ctx, void *map, void *key, unsigned int flags)
+  KERNEL_HELPER (82);
+
+unsigned long long bpf_skb_ancestor_cgroup_id (void *ctx, int level)
+  KERNEL_HELPER (83);
+
+struct bpf_sock *bpf_sk_lookup_tcp (void *ctx, struct bpf_sock_tuple *tuple,
+                                   int size, unsigned long long netns_id,
+                                   unsigned long long flags)
+  KERNEL_HELPER (84);
+
+struct bpf_sock *bpf_sk_lookup_udp (void *ctx, struct bpf_sock_tuple *tuple,
+                                   int size, unsigned long long netns_id,
+                                   unsigned long long flags)
+  KERNEL_HELPER (85);
+
+int bpf_sk_release (struct bpf_sock *sk)
+  KERNEL_HELPER (86);
+
+int bpf_map_push_elem (void *map, const void *value, unsigned long long flags)
+  KERNEL_HELPER (87);
+
+int bpf_map_pop_elem (void *map, void *value)
+  KERNEL_HELPER (88);
+
+int bpf_map_peek_elem (void *map, void *value)
+  KERNEL_HELPER (89);
+
+int bpf_msg_push_data (void *ctx, int start, int cut, int flags)
+  KERNEL_HELPER (90);
+
+int bpf_msg_pop_data (void *ctx, int start, int cut, int flags)
+  KERNEL_HELPER (91);
+
+int bpf_rc_pointer_rel (void *ctx, int rel_x, int rel_y)
+  KERNEL_HELPER (92);
+
+void bpf_spin_lock (struct bpf_spin_lock *lock)
+  KERNEL_HELPER (93);
+
+void bpf_spin_unlock (struct bpf_spin_lock *lock)
+  KERNEL_HELPER (94);
+
+struct bpf_sock *bpf_sk_fullsock (struct bpf_sock *sk)
+  KERNEL_HELPER (95);
+
+struct bpf_sock *bpf_tcp_sock (struct bpf_sock *sk)
+  KERNEL_HELPER (96);
+
+int bpf_skb_ecn_set_ce (void *ctx)
+  KERNEL_HELPER (97);
+
+struct bpf_sock *bpf_get_listener_sock (struct bpf_sock *sk)
+  KERNEL_HELPER (98);
+
+struct bpf_sock *bpf_skc_lookup_tcp (void *ctx,
+                                    struct bpf_sock_tuple *tuple,
+                                    unsigned int tuple_size,
+                                    unsigned long netns,
+                                    unsigned long flags)
+  KERNEL_HELPER (99);
+
+int bpf_tcp_check_syncookie (struct bpf_sock *sk, void *iph,
+                            unsigned int iph_len,
+                            struct tcp_hdr *th,
+                            unsigned int th_len)
+  KERNEL_HELPER (100);
+
+int bpf_sysctl_get_name (struct bpf_sysctl *ctx,
+                        char *buf, unsigned long buf_len,
+                        unsigned long flags)
+  KERNEL_HELPER (101);
+
+int bpf_sysctl_get_current_value (struct bpf_sysctl *ctx,
+                                 char *buf, unsigned long buf_len)
+  KERNEL_HELPER (102);
+
+int bpf_sysctl_get_new_value (struct bpf_sysctl *ctx, char *buf,
+                             unsigned long buf_len)
+  KERNEL_HELPER (103);
+
+int bpf_sysctl_set_new_value (struct bpf_sysctl *ctx, const char *buf,
+                             unsigned long buf_len)
+  KERNEL_HELPER (104);
+
+int bpf_strtol (const char *buf, unsigned long buf_len,
+               unsigned long flags, long *res)
+  KERNEL_HELPER (105);
+
+int bpf_strtoul (const char *buf, unsigned long buf_len,
+                unsigned long flags, unsigned long *res)
+  KERNEL_HELPER (106);
+
+void *bpf_sk_storage_get (void *map, struct bpf_sock *sk,
+                         void *value, long flags)
+  KERNEL_HELPER (107);
+
+int bpf_sk_storage_delete (void *map, struct bpf_sock *sk)
+  KERNEL_HELPER (108);
 
 /* Functions to emit BPF_LD_ABS and BPF_LD_IND instructions.  We
    provide the "standard" names as synonyms of the corresponding GCC
    builtins.  Note how the SKB argument is ignored.  */
 
-static inline long long
-load_byte (void *skb __attribute__ ((unused)),
-          unsigned long long off)
-{
-  return __builtin_bpf_load_byte (off);
-}
-
-static inline long long
-load_half (void *skb __attribute__ ((unused)),
-          unsigned long long off)
-{
-  return __builtin_bpf_load_half (off);
-}
-
-static inline long long
-load_word (void *skb __attribute__ ((unused)),
-          unsigned long long off)
-{
-  return __builtin_bpf_load_word (off);
-}
+#define load_byte(SKB,OFF) __builtin_bpf_load_byte ((OFF))
+#define load_half(SKB,OFF) __builtin_bpf_load_half ((OFF))
+#define load_word(SKB,OFF) __builtin_bpf_load_word ((OFF))
 
 struct bpf_map_def
 {
index 36e0833..84d17d4 100644 (file)
@@ -66,6 +66,63 @@ struct GTY(()) machine_function
   int callee_saved_reg_size;
 };
 
+/* Handle an attribute requiring a FUNCTION_DECL;
+   arguments as in struct attribute_spec.handler.  */
+
+static tree
+bpf_handle_fndecl_attribute (tree *node, tree name,
+                            tree args,
+                            int flags ATTRIBUTE_UNUSED,
+                            bool *no_add_attrs)
+{
+  if (TREE_CODE (*node) != FUNCTION_DECL)
+    {
+      warning (OPT_Wattributes, "%qE attribute only applies to functions",
+              name);
+      *no_add_attrs = true;
+    }
+
+  if (is_attribute_p ("kernel_helper", name))
+    {
+      if (args)
+       {
+         tree cst = TREE_VALUE (args);
+         if (TREE_CODE (cst) != INTEGER_CST)
+           {
+             warning (OPT_Wattributes, "%qE attribute requires an integer argument",
+                      name);
+             *no_add_attrs = true;
+           }
+       }
+      else
+       {
+         warning (OPT_Wattributes, "%qE requires an argument", name);
+         *no_add_attrs = true;
+       }
+    }
+
+  return NULL_TREE;
+}
+
+/* Target-specific attributes.  */
+
+static const struct attribute_spec bpf_attribute_table[] =
+{
+  /* Syntax: { name, min_len, max_len, decl_required, type_required,
+              function_type_required, affects_type_identity, handler,
+              exclude } */
+
+ /* Attribute to mark function prototypes as kernel helpers.  */
+ { "kernel_helper", 1, 1, true, false, false, false,
+   bpf_handle_fndecl_attribute, NULL },
+
+ /* The last attribute spec is set to be NULL.  */
+ { NULL,       0,  0, false, false, false, false, NULL, NULL }
+};
+
+#undef TARGET_ATTRIBUTE_TABLE
+#define TARGET_ATTRIBUTE_TABLE bpf_attribute_table
+
 /* Data structures for the eBPF specific built-ins.  */
 
 /* Maximum number of arguments taken by a builtin function, plus
@@ -75,47 +132,13 @@ struct GTY(()) machine_function
 enum bpf_builtins
 {
   BPF_BUILTIN_UNUSED = 0,
-  /* Built-ins for kernel helpers.  */
-#define DEF_HELPER(V,D,N,T) BPF_BUILTIN_HELPER_##D,
-#  include "bpf-helpers.def"
-#undef DEF_HELPER
-  BPF_BUILTIN_HELPER_MAX,
   /* Built-ins for non-generic loads and stores.  */
-  BPF_BUILTIN_LOAD_BYTE = BPF_BUILTIN_HELPER_MAX,
+  BPF_BUILTIN_LOAD_BYTE,
   BPF_BUILTIN_LOAD_HALF,
   BPF_BUILTIN_LOAD_WORD,
   BPF_BUILTIN_MAX,
 };
 
-/* This table is indexed by an enum bpf_builtin.  */
-static const char *bpf_helper_names[] =
-{
-  NULL,
-#define DEF_HELPER(V,D,N,T) #N,
-#  include "bpf-helpers.def"
-#undef DEF_HELPER
-  NULL,
-  NULL,
-  NULL,
-  NULL
-};
-
-/* Return the builtin code corresponding to the kernel helper builtin
-   __builtin_NAME, or 0 if the name doesn't correspond to a kernel
-   helper builtin.  */
-
-static inline int
-bpf_helper_code (const char *name)
-{
-  int i;
-
-  for (i = 1; i < BPF_BUILTIN_HELPER_MAX; ++i)
-    if (strcmp (name, bpf_helper_names[i]) == 0)
-      return i;
-
-  return 0;
-}
-
 static GTY (()) tree bpf_builtins[(int) BPF_BUILTIN_MAX];
 
 /* Initialize the per-function machine status.  */
@@ -149,7 +172,7 @@ void
 bpf_target_macros (cpp_reader *pfile)
 {
   builtin_define ("__BPF__");
-  
+
   if (TARGET_BIG_ENDIAN)
     builtin_define ("__BPF_BIG_ENDIAN__");
   else
@@ -187,7 +210,7 @@ bpf_target_macros (cpp_reader *pfile)
       case LINUX_V5_1: version_code = "0x50100"; break;
       case LINUX_V5_2: version_code = "0x50200"; break;
       default:
-       gcc_unreachable ();      
+       gcc_unreachable ();
       }
 
     kernel_version_code = ACONCAT (("__BPF_KERNEL_VERSION_CODE__=",
@@ -359,7 +382,7 @@ bpf_expand_prologue (void)
       insn = emit_move_insn (stack_pointer_rtx,
                             hard_frame_pointer_rtx);
       RTX_FRAME_RELATED_P (insn) = 1;
-      
+
       if (size > 0)
        {
          insn = emit_insn (gen_rtx_SET (stack_pointer_rtx,
@@ -528,7 +551,7 @@ bpf_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
 
        rtx x0 = XEXP (x, 0);
        rtx x1 = XEXP (x, 1);
-       
+
        if (bpf_address_base_p (x0, strict) && GET_CODE (x1) == CONST_INT)
          return IN_RANGE (INTVAL (x1), -1 - 0x7fff, 0x7fff);
 
@@ -681,13 +704,16 @@ bpf_output_call (rtx target)
       break;
     case SYMBOL_REF:
       {
-       const char *function_name = XSTR (target, 0);
-       int code;
-      
-       if (strncmp (function_name, "__builtin_bpf_helper_", 21) == 0
-           && ((code = bpf_helper_code (function_name + 21)) != 0))
+       tree decl = SYMBOL_REF_DECL (target);
+       tree attr;
+
+       if (decl
+           && (attr = lookup_attribute ("kernel_helper",
+                                        DECL_ATTRIBUTES (decl))))
          {
-           xops[0] = GEN_INT (code);
+           tree attr_args = TREE_VALUE (attr);
+
+           xops[0] = GEN_INT (TREE_INT_CST_LOW (TREE_VALUE (attr_args)));
            output_asm_insn ("call\t%0", xops);
          }
        else
@@ -792,40 +818,7 @@ def_builtin (const char *name, enum bpf_builtins code, tree type)
 static void
 bpf_init_builtins (void)
 {
-  /* Built-ins for calling kernel helpers.  */
-
-  tree pt = build_pointer_type (void_type_node);
-  tree const_void_type
-    = build_qualified_type (void_type_node, TYPE_QUAL_CONST);
-  tree cpt = build_pointer_type (const_void_type);
-  tree st = short_integer_type_node;
-  tree ust = uint16_type_node;
-  tree it = integer_type_node;
-  tree ut = unsigned_type_node;
-  tree const_char_type
-    = build_qualified_type (char_type_node, TYPE_QUAL_CONST);
-  tree cst = build_pointer_type (const_char_type);
-  tree vt = void_type_node;
-  tree ult = long_unsigned_type_node;
-  tree u32t = uint32_type_node;
-  tree u64t = uint64_type_node;
-  tree llt = long_long_integer_type_node;
   tree ullt = long_long_unsigned_type_node;
-  
-#define TYPES build_function_type_list
-#define VTYPES build_varargs_function_type_list
-#define DEF_HELPER(V,D,N,T)                            \
-  do                                                   \
-    {                                                  \
-      if (bpf_kernel >= (V))                           \
-       def_builtin ("__builtin_bpf_helper_" #N,        \
-                    BPF_BUILTIN_HELPER_##D,            \
-                    T);                                \
-    } while (0);
-#  include "bpf-helpers.def"
-#undef TYPES
-#undef VTYPES
-#undef DEF_HELPER
 
   /* Built-ins for BPF_LD_ABS and BPF_LD_IND instructions.  */
 
@@ -844,30 +837,17 @@ bpf_init_builtins (void)
    with bpf_init_builtins.  */
 
 static rtx
-bpf_expand_builtin (tree exp, rtx target,
+bpf_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED,
                    rtx subtarget ATTRIBUTE_UNUSED,
                    machine_mode mode ATTRIBUTE_UNUSED,
-                   int ignore)
+                   int ignore ATTRIBUTE_UNUSED)
 {
   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
   int code = DECL_MD_FUNCTION_CODE (fndecl);
 
-  if (code >= 1 && code < BPF_BUILTIN_HELPER_MAX)
-    {
-      /* This is a builtin to call a kernel helper function.
-
-        For these builtins, we just expand the function call normally
-        with expand_call like we would do for a libcall. The function
-        bpf_output_call below will then do The Right Thing (TM),
-        recognizing the name of the called __builtin_helper_* symbol
-        and emitting the corresponding CALL N instruction whenever
-        necessary.  */
-
-      return expand_call (exp, target, ignore);
-    }
-  else if (code == BPF_BUILTIN_LOAD_BYTE
-          || code == BPF_BUILTIN_LOAD_HALF
-          || code == BPF_BUILTIN_LOAD_WORD)
+  if (code == BPF_BUILTIN_LOAD_BYTE
+      || code == BPF_BUILTIN_LOAD_HALF
+      || code == BPF_BUILTIN_LOAD_WORD)
     {
       /* Expand an indirect load from the sk_buff in the context.
         There is just one argument to the builtin, which is the
index 37a675a..7983317 100644 (file)
@@ -2446,6 +2446,7 @@ GCC plugins may provide their own attributes.
 * ARM Function Attributes::
 * AVR Function Attributes::
 * Blackfin Function Attributes::
+* BPF Function Attributes::
 * CR16 Function Attributes::
 * C-SKY Function Attributes::
 * Epiphany Function Attributes::
@@ -4657,6 +4658,24 @@ all registers except the stack pointer should be saved in the prologue
 regardless of whether they are used or not.
 @end table
 
+@node BPF Function Attributes
+@subsection BPF Function Attributes
+
+These function attributes are supported by the BPF back end:
+
+@table @code
+@item kernel_helper
+@cindex @code{kernel helper}, function attribute, BPF
+use this attribute to indicate the specified function declaration is a
+kernel helper.  The helper function is passed as an argument to the
+attribute.  Example:
+
+@smallexample
+int bpf_probe_read (void *dst, int size, const void *unsafe_ptr)
+  __attribute__ ((kernel_helper (4)));
+@end smallexample
+@end table
+
 @node CR16 Function Attributes
 @subsection CR16 Function Attributes
 
@@ -13858,7 +13877,6 @@ instructions, but allow the compiler to schedule those calls.
 * AVR Built-in Functions::
 * Blackfin Built-in Functions::
 * BPF Built-in Functions::
-* BPF Kernel Helpers::
 * FR-V Built-in Functions::
 * MIPS DSP Built-in Functions::
 * MIPS Paired-Single Support::
@@ -14879,158 +14897,6 @@ Load 16-bits from the @code{struct sk_buff} packet data pointed by the register
 Load 32-bits from the @code{struct sk_buff} packet data pointed by the register @code{%r6} and return it.
 @end deftypefn
 
-@node BPF Kernel Helpers
-@subsection BPF Kernel Helpers
-
-These built-in functions are available for calling kernel helpers, and
-they are available depending on the kernel version selected as the
-CPU.
-
-Rather than using the built-ins directly, it is preferred for programs
-to include @file{bpf-helpers.h} and use the wrappers defined there.
-
-For a full description of what the helpers do, the arguments they
-take, and the returned value, see the
-@file{linux/include/uapi/linux/bpf.h} in a Linux source tree.
-
-@smallexample
-void *__builtin_bpf_helper_map_lookup_elem (void *map, void *key)
-int   __builtin_bpf_helper_map_update_elem (void *map, void *key,
-                                            void *value,
-                                            unsigned long long flags)
-int   __builtin_bpf_helper_map_delete_elem (void *map, const void *key)
-int   __builtin_bpf_helper_map_push_elem (void *map, const void *value,
-                                          unsigned long long flags)
-int   __builtin_bpf_helper_map_pop_elem (void *map, void *value)
-int   __builtin_bpf_helper_map_peek_elem (void *map, void *value)
-int __builtin_bpf_helper_clone_redirect (void *skb,
-                                         unsigned int ifindex,
-                                         unsigned long long flags)
-int __builtin_bpf_helper_skb_get_tunnel_key (void *ctx, void *key, int size, int flags)
-int __builtin_bpf_helper_skb_set_tunnel_key (void *ctx, void *key, int size, int flags)
-int __builtin_bpf_helper_skb_get_tunnel_opt (void *ctx, void *md, int size)
-int __builtin_bpf_helper_skb_set_tunnel_opt (void *ctx, void *md, int size)
-int __builtin_bpf_helper_skb_get_xfrm_state (void *ctx, int index, void *state,
-                                    int size, int flags)
-static unsigned long long __builtin_bpf_helper_skb_cgroup_id (void *ctx)
-static unsigned long long __builtin_bpf_helper_skb_ancestor_cgroup_id
-                                         (void *ctx, int level)
-int __builtin_bpf_helper_skb_vlan_push (void *ctx, __be16 vlan_proto, __u16 vlan_tci)
-int __builtin_bpf_helper_skb_vlan_pop (void *ctx)
-int __builtin_bpf_helper_skb_ecn_set_ce (void *ctx)
-
-int __builtin_bpf_helper_skb_load_bytes (void *ctx, int off, void *to, int len)
-int __builtin_bpf_helper_skb_load_bytes_relative (void *ctx, int off, void *to, int len, __u32 start_header)
-int __builtin_bpf_helper_skb_store_bytes (void *ctx, int off, void *from, int len, int flags)
-int __builtin_bpf_helper_skb_under_cgroup (void *ctx, void *map, int index)
-int __builtin_bpf_helper_skb_change_head (void *, int len, int flags)
-int __builtin_bpf_helper_skb_pull_data (void *, int len)
-int __builtin_bpf_helper_skb_change_proto (void *ctx, __be16 proto, __u64 flags)
-int __builtin_bpf_helper_skb_change_type (void *ctx, __u32 type)
-int __builtin_bpf_helper_skb_change_tail (void *ctx, __u32 len, __u64 flags)
-int __builtin_bpf_helper_skb_adjust_room (void *ctx, __s32 len_diff, __u32 mode,
-                                 unsigned long long flags)
-@end smallexample
-
-Other helpers:
-
-@smallexample
-int __builtin_bpf_helper_probe_read (void *dst, unsigned int size, void *src)
-unsigned long long __builtin_bpf_helper_ktime_get_ns (void)
-int __builtin_bpf_helper_trace_printk (const char *fmt, unsigned int fmt_size, ...)
-void __builtin_bpf_helper_tail_call (void *ctx, void *prog_array_map, unsigned int index)
-unsigned int __builtin_bpf_helper_get_smp_processor_id (void)
-unsigned long long __builtin_bpf_helper_get_current_pid_tgid (void)
-unsigned long long __builtin_bpf_helper_get_current_uid_gid (void)
-int __builtin_bpf_helper_get_current_comm (void *buf, unsigned int size_of_buf)
-unsigned long long __builtin_bpf_helper_perf_event_read (void *map, unsigned long long flags)
-
-int __builtin_bpf_helper_redirect (unsigned int ifindex, unsigned long long flags)
-int __builtin_bpf_helper_redirect_map (void *map, unsigned int key, unsigned long long flags)
-int __builtin_bpf_helper_perf_event_output (void *ctx,void *map, unsigned long long flags, void *data, unsigned long long size)
-int __builtin_bpf_helper_get_stackid (void *ctx, void *map, unsigned long long flags)
-int __builtin_bpf_helper_probe_write_user (void *dst, const void *src, unsigned int len)
-int __builtin_bpf_helper_current_task_under_cgroup (void *map, unsigned int index)
-
-static unsigned long long __builtin_bpf_helper_get_prandom_u32 (void)
-int __builtin_bpf_helper_xdp_adjust_head (void *ctx, int offset)
-int __builtin_bpf_helper_xdp_adjust_meta (void *ctx, int offset)
-int __builtin_bpf_helper_get_socket_cookie (void *ctx)
-int __builtin_bpf_helper_setsockopt (void *ctx, int level, int optname, void *optval,
-                            int optlen)
-int __builtin_bpf_helper_getsockopt (void *ctx, int level, int optname, void *optval,
-                            int optlen)
-int __builtin_bpf_helper_sock_ops_cb_flags_set (void *ctx, int flags)
-int __builtin_bpf_helper_sk_redirect_map (void *ctx, void *map, int key, int flags)
-int __builtin_bpf_helper_sk_redirect_hash (void *ctx, void *map, void *key, int flags)
-int __builtin_bpf_helper_sock_map_update (void *map, void *key, void *value,
-                                 unsigned long long flags)
-int __builtin_bpf_helper_sock_hash_update (void *map, void *key, void *value,
-                                  unsigned long long flags)
-int __builtin_bpf_helper_perf_event_read_value (void *map, unsigned long long flags,
-                                       void *buf, unsigned int buf_size)
-int __builtin_bpf_helper_perf_prog_read_value (void *ctx, void *buf,
-                                      unsigned int buf_size)
-
-int __builtin_bpf_helper_override_return (void *ctx, unsigned long rc)
-int __builtin_bpf_helper_msg_redirect_map (void *ctx, void *map, int key, int flags)
-int __builtin_bpf_helper_msg_redirect_hash (void *ctx,
-                                   void *map, void *key, int flags)
-int __builtin_bpf_helper_msg_apply_bytes (void *ctx, int len)
-int __builtin_bpf_helper_msg_cork_bytes (void *ctx, int len)
-int __builtin_bpf_helper_msg_pull_data (void *ctx, int start, int end, int flags)
-int __builtin_bpf_helper_msg_push_data (void *ctx, int start, int end, int flags)
-int __builtin_bpf_helper_msg_pop_data (void *ctx, int start, int cut, int flags)
-int __builtin_bpf_helper_bind (void *ctx, void *addr, int addr_len)
-int __builtin_bpf_helper_xdp_adjust_tail (void *ctx, int offset)
-int __builtin_bpf_helper_sk_select_reuseport (void *ctx, void *map, void *key, __u32 flags)
-int __builtin_bpf_helper_get_stack (void *ctx, void *buf, int size, int flags)
-int __builtin_bpf_helper_fib_lookup (void *ctx, struct bpf_fib_lookup *params,
-                            int plen, __u32 flags)
-
-int __builtin_bpf_helper_lwt_push_encap (void *ctx, unsigned int type, void *hdr,
-                                unsigned int len)
-int __builtin_bpf_helper_lwt_seg6_store_bytes (void *ctx, unsigned int offset,
-                                      void *from, unsigned int len)
-int __builtin_bpf_helper_lwt_seg6_action (void *ctx, unsigned int action, void *param,
-                                 unsigned int param_len)
-int __builtin_bpf_helper_lwt_seg6_adjust_srh (void *ctx, unsigned int offset,
-                                     unsigned int len)
-int __builtin_bpf_helper_rc_repeat (void *ctx)
-int __builtin_bpf_helper_rc_keydown (void *ctx, unsigned int protocol,
-                            unsigned long long scancode, unsigned int toggle)
-static unsigned long long __builtin_bpf_helper_get_current_cgroup_id (void)
-static void *__builtin_bpf_helper_get_local_storage (void *map, unsigned long long flags)
-static struct bpf_sock *__builtin_bpf_helper_sk_lookup_tcp (void *ctx, void *tuple, int size, unsigned long long netns_id, unsigned long long flags)
-static struct bpf_sock *__builtin_bpf_helper_sk_lookup_udp (void *ctx, void *tuple, int size, unsigned long long netns_id, unsigned long long flags)
-int __builtin_bpf_helper_sk_release (struct bpf_sock *sk)
-int __builtin_bpf_helper_rc_pointer_rel (void *ctx, int rel_x, int rel_y)
-static void __builtin_bpf_helper_spin_lock (struct bpf_spin_lock *lock)
-static void __builtin_bpf_helper_spin_unlock (struct bpf_spin_lock *lock)
-
-static struct bpf_sock *__builtin_bpf_helper_sk_fullsock (struct bpf_sock *sk)
-static struct bpf_tcp_sock *__builtin_bpf_helper_tcp_sock (struct bpf_sock *sk)
-static struct bpf_sock *__builtin_bpf_helper_get_listener_sock (struct bpf_sock *sk)
-
-int __builtin_bpf_helper_l3_csum_replace (void *ctx, int off, int from, int to, int flags)
-int __builtin_bpf_helper_l4_csum_replace (void *ctx, int off, int from, int to, int flags)
-int __builtin_bpf_helper_csum_diff (void *from, int from_size, void *to, int to_size, int seed)
-
-static unsigned int __builtin_bpf_helper_get_cgroup_classid (void *ctx)
-static unsigned int __builtin_bpf_helper_get_route_realm (void *ctx)
-static unsigned int __builtin_bpf_helper_get_hash_recalc (void *ctx)
-static unsigned long long __builtin_bpf_helper_get_current_task (void *ctx)
-
-static long long __builtin_bpf_helper_csum_update (void *ctx, __u32 csum)
-static void __builtin_bpf_helper_set_hash_invalid (void *ctx)
-int __builtin_bpf_helper_get_numa_node_id (void)
-int __builtin_bpf_helper_probe_read_str (void *ctx, __u32 size,
-                                const void *unsafe_ptr)
-static unsigned int __builtin_bpf_helper_get_socket_uid (void *ctx)
-static unsigned int __builtin_bpf_helper_set_hash (void *ctx, __u32 hash)
-@end smallexample
-
-
 @node FR-V Built-in Functions
 @subsection FR-V Built-in Functions
 
index 2d1fedc..8dfde24 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *ctx, *addr;
   int addr_len;
 
-  ret = __builtin_bpf_helper_bind (ctx, addr, addr_len);
+  ret = bpf_bind (ctx, addr, addr_len);
 }
 
 /* { dg-final { scan-assembler "call\t64" } } */
index 844c88d..9937d5a 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   uint32_t ifindex;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_redirect (ifindex, flags);
+  ret = bpf_redirect (ifindex, flags);
 }
 
 /* { dg-final { scan-assembler "call\t23" } } */
index a4fb813..e38adbc 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t ifindex;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_clone_redirect (skb, ifindex, flags);
+  ret = bpf_clone_redirect (skb, ifindex, flags);
 }
 
 /* { dg-final { scan-assembler "call\t13" } } */
index ef38192..a1c8bf5 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint64_t to_size, from_size;
   int seed;
 
-  ret = __builtin_bpf_helper_csum_diff (from, from_size, to, to_size, seed);
+  ret = bpf_csum_diff (from, from_size, to, to_size, seed);
 }
 
 /* { dg-final { scan-assembler "call\t28" } } */
index 3cde867..4f65033 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb;
   int csum;
 
-  ret = __builtin_bpf_helper_csum_update (skb, csum);
+  ret = bpf_csum_update (skb, csum);
 }
 
 /* { dg-final { scan-assembler "call\t40" } } */
index a7eb6e6..5b05378 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *map;
   uint32_t index;
 
-  ret = __builtin_bpf_helper_current_task_under_cgroup (map, index);
+  ret = bpf_current_task_under_cgroup (map, index);
 }
 
 /* { dg-final { scan-assembler "call\t37" } } */
index 9a9f79d..8290234 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   int plen;
   uint32_t flags;
 
-  ret = __builtin_bpf_helper_fib_lookup (ctx, params, plen, flags);
+  ret = bpf_fib_lookup (ctx, params, plen, flags);
 }
 
 /* { dg-final { scan-assembler "call\t69" } } */
index 6cfd14d..5d85a89 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   uint32_t ret;
   void *skb;
 
-  ret = __builtin_bpf_helper_get_cgroup_classid (skb);
+  ret = bpf_get_cgroup_classid (skb);
 }
 
 /* { dg-final { scan-assembler "call\t17" } } */
index 916dc4d..b0c0b74 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   uint64_t ret;
   
-  ret = __builtin_bpf_helper_get_current_cgroup_id ();
+  ret = bpf_get_current_cgroup_id ();
 }
 
 /* { dg-final { scan-assembler "call\t80" } } */
index efc330c..1e25cd1 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *buf;
   uint32_t size_of_buf;
 
-  ret = __builtin_bpf_helper_get_current_comm (buf, size_of_buf);
+  ret = bpf_get_current_comm (buf, size_of_buf);
 }
 
 /* { dg-final { scan-assembler "call\t16" } } */
index 32d3e9c..1dd7a1e 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   uint64_t ret;
 
-  ret = __builtin_bpf_helper_get_current_pid_tgid ();
+  ret = bpf_get_current_pid_tgid ();
 }
 
 /* { dg-final { scan-assembler "call\t14" } } */
index 016c134..79344d1 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   uint64_t ret;
 
-  ret = __builtin_bpf_helper_get_current_task ();
+  ret = bpf_get_current_task ();
 }
 
 /* { dg-final { scan-assembler "call\t35" } } */
index 1dc2f9f..b3e7261 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   uint64_t ret;
 
-  ret = __builtin_bpf_helper_get_current_uid_gid ();
+  ret = bpf_get_current_uid_gid ();
 }
 
 /* { dg-final { scan-assembler "call\t15" } } */
index 1db5d87..e9d87ae 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   uint32_t ret;
   void *skb;
 
-  ret = __builtin_bpf_helper_get_hash_recalc (skb);
+  ret = bpf_get_hash_recalc (skb);
 }
 
 /* { dg-final { scan-assembler "call\t34" } } */
index 298da1c..500ba78 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   void *ret, *sk;
 
-  ret = __builtin_bpf_helper_get_listener_sock (sk);
+  ret = bpf_get_listener_sock (sk);
 }
 
 /* { dg-final { scan-assembler "call\t98" } } */
index 88da67e..1c28ef5 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   void *ret, *map;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_get_local_storage (map, flags);
+  ret = bpf_get_local_storage (map, flags);
 }
 
 /* { dg-final { scan-assembler "call\t81" } } */
index 628e101..e6477a5 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   int ret;
 
-  ret = __builtin_bpf_helper_get_numa_node_id ();
+  ret = bpf_get_numa_node_id ();
 }
 
 /* { dg-final { scan-assembler "call\t42" } } */
index 6d3e5bc..f30cafd 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   uint32_t ret;
 
-  ret = __builtin_bpf_helper_get_prandom_u32 ();
+  ret = bpf_get_prandom_u32 ();
 }
 
 /* { dg-final { scan-assembler "call\t7" } } */
index 5056c4a..b779430 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   uint32_t ret;
   void *skb;
 
-  ret = __builtin_bpf_helper_get_route_realm (skb);
+  ret = bpf_get_route_realm (skb);
 }
 
 /* { dg-final { scan-assembler "call\t24" } } */
index 655b873..7d0e986 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   uint32_t ret;
 
-  ret = __builtin_bpf_helper_get_smp_processor_id ();
+  ret = bpf_get_smp_processor_id ();
 }
 
 /* { dg-final { scan-assembler "call\t8" } } */
index afd17dd..e2e421f 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   uint64_t ret;
   void *skb;
   
-  ret = __builtin_bpf_helper_get_socket_cookie (skb);
+  ret = bpf_get_socket_cookie (skb);
 }
 
 /* { dg-final { scan-assembler "call\t46" } } */
index 3a274c9..343f866 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   uint32_t ret;
   void *skb;
   
-  ret = __builtin_bpf_helper_get_socket_uid (skb);
+  ret = bpf_get_socket_uid (skb);
 }
 
 /* { dg-final { scan-assembler "call\t47" } } */
index bbcdeb5..cc3f6a0 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t size;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_get_stack (regs, buf, size, flags);
+  ret = bpf_get_stack (regs, buf, size, flags);
 }
 
 /* { dg-final { scan-assembler "call\t67" } } */
index 319d15c..cc3ecb0 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *ctx, *map;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_get_stackid (ctx, map, flags);
+  ret = bpf_get_stackid (ctx, map, flags);
 }
 
 /* { dg-final { scan-assembler "call\t27" } } */
index fb16f15..c4b3298 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,8 +12,8 @@ foo ()
   int level, optname, optlen;
   char *optval;
   
-  ret = __builtin_bpf_helper_getsockopt (bpf_socket, level,
-                                        optname, optval, optlen);
+  ret = bpf_getsockopt (bpf_socket, level,
+                       optname, optval, optlen);
 }
 
 /* { dg-final { scan-assembler "call\t57" } } */
index 405df05..77f1661 100644 (file)
@@ -1,12 +1,14 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   uint64_t ret;
-  ret = __builtin_bpf_helper_ktime_get_ns ();
+  ret = bpf_ktime_get_ns ();
 }
 
 /* { dg-final { scan-assembler "call\t5" } } */
index ac17662..c3f1b78 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t offset;
   uint64_t from, to, size;
 
-  ret = __builtin_bpf_helper_l3_csum_replace (skb, offset, from, to, size);
+  ret = bpf_l3_csum_replace (skb, offset, from, to, size);
 }
 
 /* { dg-final { scan-assembler "call\t10" } } */
index 52b5514..fd54f0b 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t offset;
   uint64_t from, to, size;
 
-  ret = __builtin_bpf_helper_l4_csum_replace (skb, offset, from, to, size);
+  ret = bpf_l4_csum_replace (skb, offset, from, to, size);
 }
 
 /* { dg-final { scan-assembler "call\t11" } } */
index 1baed27..c6d4769 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb, *hdr;
   uint32_t type, len;
   
-  ret = __builtin_bpf_helper_lwt_push_encap (skb, type, hdr, len);
+  ret = bpf_lwt_push_encap (skb, type, hdr, len);
 }
 
 /* { dg-final { scan-assembler "call\t73" } } */
index ccc94c1..4cd7052 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,8 +11,8 @@ foo ()
   void *skb, *param;
   uint32_t action, param_len;
   
-  ret = __builtin_bpf_helper_lwt_seg6_action (skb, action,
-                                             param, param_len);
+  ret = bpf_lwt_seg6_action (skb, action,
+                            param, param_len);
 }
 
 /* { dg-final { scan-assembler "call\t76" } } */
index 5e95124..adc8dc4 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb;
   uint32_t offset, delta;
   
-  ret = __builtin_bpf_helper_lwt_seg6_adjust_srh (skb, offset,
+  ret = bpf_lwt_seg6_adjust_srh (skb, offset,
                                                  delta);
 }
 
index 098f976..a35e917 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,8 +11,7 @@ foo ()
   void *skb, *from;
   uint32_t offset, len;
   
-  ret = __builtin_bpf_helper_lwt_seg6_store_bytes (skb, offset,
-                                                  from, len);
+  ret = bpf_lwt_seg6_store_bytes (skb, offset, from, len);
 }
 
 /* { dg-final { scan-assembler "call\t74" } } */
index b8a6cde..0200b15 100644 (file)
@@ -1,4 +1,7 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
 
 char *map () { return 0; }
 
@@ -8,7 +11,7 @@ foo ()
   int ret;
   char *key = 0;
 
-  ret = __builtin_bpf_helper_map_delete_elem (map (), key);
+  ret = bpf_map_delete_elem (map (), key);
 }
 
 /* { dg-final { scan-assembler "call\t3" } } */
index 839cfc4..1d443a0 100644 (file)
@@ -1,4 +1,7 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
 
 char *map () { return 0; }
 
@@ -6,7 +9,7 @@ void
 foo ()
 {
   char *key = 0, *value = 0;
-  value = __builtin_bpf_helper_map_lookup_elem (map (), key);
+  value = bpf_map_lookup_elem (map (), key);
 }
 
 /* { dg-final { scan-assembler "call\t1" } } */
index 6d0acb1..de833f2 100644 (file)
@@ -1,4 +1,7 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
 
 char *map () { return 0; }
 
@@ -8,7 +11,7 @@ foo ()
   int ret;
   char *value = 0;
 
-  ret = __builtin_bpf_helper_map_peek_elem (map (), value);
+  ret = bpf_map_peek_elem (map (), value);
 }
 
 /* { dg-final { scan-assembler "call\t89" } } */
index 71a7851..7d76f85 100644 (file)
@@ -1,4 +1,7 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
 
 char *map () { return 0; }
 
@@ -8,7 +11,7 @@ foo ()
   int ret;
   char *value = 0;
 
-  ret = __builtin_bpf_helper_map_pop_elem (map (), value);
+  ret = bpf_map_pop_elem (map (), value);
 }
 
 /* { dg-final { scan-assembler "call\t88" } } */
index 53bc0ac..b4b2a8e 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
 /* { dg-options "-std=gnu99" } */
 
+#include <bpf-helpers.h>
+
 char *map () { return 0; }
 
 void
@@ -10,7 +12,7 @@ foo ()
   char *value = 0;
   long long flags = 0;
 
-  ret = __builtin_bpf_helper_map_push_elem (map (), value, flags);
+  ret = bpf_map_push_elem (map (), value, flags);
 }
 
 /* { dg-final { scan-assembler "call\t87" } } */
index 6281442..6cceafe 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
 /* { dg-options "-std=gnu99" } */
 
+#include <bpf-helpers.h>
+
 char *map () { return 0; }
 
 void
@@ -10,7 +12,7 @@ foo ()
   long long flags = 0;
   char *key = 0, *value = 0;
 
-  ret = __builtin_bpf_helper_map_update_elem (map (), key, value, flags);
+  ret = bpf_map_update_elem (map (), key, value, flags);
 }
 
 /* { dg-final { scan-assembler "call\t2" } } */
index 3b831ac..9c8ef9d 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *msg;
   uint32_t bytes;
   
-  ret = __builtin_bpf_helper_msg_apply_bytes (msg, bytes);
+  ret = bpf_msg_apply_bytes (msg, bytes);
 }
 
 /* { dg-final { scan-assembler "call\t61" } } */
index 2c4ee21..988a04d 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *msg;
   uint32_t bytes;
   
-  ret = __builtin_bpf_helper_msg_cork_bytes (msg, bytes);
+  ret = bpf_msg_cork_bytes (msg, bytes);
 }
 
 /* { dg-final { scan-assembler "call\t62" } } */
index 377c036..5679044 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t start, pop;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_msg_pop_data (skb, start, pop, flags);
+  ret = bpf_msg_pop_data (skb, start, pop, flags);
 }
 
 /* { dg-final { scan-assembler "call\t91" } } */
index ef27493..7714101 100644 (file)
@@ -1,16 +1,17 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   int ret;
   void *msg;
-  uint32_t start, end;
-  uint64_t flags;
+  int len;
   
-  ret = __builtin_bpf_helper_msg_pull_data (msg, start, end, flags);
+  ret = bpf_msg_pull_data (msg, len);
 }
 
 /* { dg-final { scan-assembler "call\t63" } } */
index 9e256bc..40b9361 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t start, len;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_msg_push_data (skb, start, len, flags);
+  ret = bpf_msg_push_data (skb, start, len, flags);
 }
 
 /* { dg-final { scan-assembler "call\t90" } } */
index 2e9d413..6ac680c 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *msg, *map, *key;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_msg_redirect_hash (msg, map, key,
+  ret = bpf_msg_redirect_hash (msg, map, key,
                                                flags);
 }
 
index f5f8405..ef69f11 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint64_t key;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_msg_redirect_map (msg, map, key,
+  ret = bpf_msg_redirect_map (msg, map, key,
                                               flags);
 }
 
index 3bd5424..380fd59 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *regs;
   uint64_t rc;
   
-  ret = __builtin_bpf_helper_override_return (regs, rc);
+  ret = bpf_override_return (regs, rc);
 }
 
 /* { dg-final { scan-assembler "call\t58" } } */
index afb3201..24ed565 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -11,7 +12,7 @@ foo ()
   void *data;
   uint64_t size;
 
-  ret = __builtin_bpf_helper_perf_event_output (ctx, map, flags, data, size);
+  ret = bpf_perf_event_output (ctx, map, flags, data, size);
 }
 
 /* { dg-final { scan-assembler "call\t25" } } */
index 1d512c9..6692f64 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint64_t flags;
   uint64_t buf_size;
   
-  ret = __builtin_bpf_helper_perf_event_read_value (map, flags, buf, buf_size);
+  ret = bpf_perf_event_read_value (map, flags, buf, buf_size);
 }
 
 /* { dg-final { scan-assembler "call\t55" } } */
index f099a09..674058d 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *map;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_perf_event_read (map, flags);
+  ret = bpf_perf_event_read (map, flags);
 }
 
 /* { dg-final { scan-assembler "call\t22" } } */
index 00c4a3a..7f0a801 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *ctx, *buf;
   uint64_t buf_size;
   
-  ret = __builtin_bpf_helper_perf_prog_read_value (ctx, buf, buf_size);
+  ret = bpf_perf_prog_read_value (ctx, buf, buf_size);
 }
 
 /* { dg-final { scan-assembler "call\t56" } } */
index fd04760..0774da4 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   void *dst;
   const void *unsafe_ptr;
   
-  ret = __builtin_bpf_helper_probe_read_str (dst, size, unsafe_ptr);
+  ret = bpf_probe_read_str (dst, size, unsafe_ptr);
 }
 
 /* { dg-final { scan-assembler "call\t45" } } */
index a77a907..64261c5 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *src, *dst;
   uint32_t size;
 
-  ret = __builtin_bpf_helper_probe_read (dst, size, src);
+  ret = bpf_probe_read (dst, size, src);
 }
 
 /* { dg-final { scan-assembler "call\t4" } } */
index bf22620..127ae61 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *dst, *src;
   uint32_t len;
 
-  ret = __builtin_bpf_helper_probe_write_user (dst, src, len);
+  ret = bpf_probe_write_user (dst, src, len);
 }
 
 /* { dg-final { scan-assembler "call\t36" } } */
index 58e9395..c419ee0 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t protocol, toggle;
   uint64_t scancode;
   
-  ret = __builtin_bpf_helper_rc_keydown (ctx, protocol,
+  ret = bpf_rc_keydown (ctx, protocol,
                                         scancode, toggle);
 }
 
index e776bc7..ca0a5c4 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *ctx;
   int32_t rel_x, rel_y;
 
-  ret = __builtin_bpf_helper_rc_pointer_rel (ctx, rel_x, rel_y);
+  ret = bpf_rc_pointer_rel (ctx, rel_x, rel_y);
 }
 
 /* { dg-final { scan-assembler "call\t92" } } */
index 0ebc7de..52d83e4 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   int ret;
   void *ctx;
   
-  ret = __builtin_bpf_helper_rc_repeat (ctx);
+  ret = bpf_rc_repeat (ctx);
 }
 
 /* { dg-final { scan-assembler "call\t77" } } */
index daeecc2..0d05977 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t key;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_redirect_map (map, key, flags);
+  ret = bpf_redirect_map (map, key, flags);
 }
 
 /* { dg-final { scan-assembler "call\t51" } } */
index 4bc63ff..adbc41b 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   void *skb;
 
-  __builtin_bpf_helper_set_hash_invalid (skb);
+  bpf_set_hash_invalid (skb);
 }
 
 /* { dg-final { scan-assembler "call\t41" } } */
index d01ae6e..a36cd6b 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb;
   uint32_t hash;
   
-  ret = __builtin_bpf_helper_set_hash (skb, hash);
+  ret = bpf_set_hash (skb, hash);
 }
 
 /* { dg-final { scan-assembler "call\t48" } } */
index 6f3b450..f79c2a8 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -12,8 +14,7 @@ foo ()
   void *optval;
   int optlen;
   
-  ret = __builtin_bpf_helper_setsockopt (bpf_socket, level, optname,
-                                        optval, optlen);
+  ret = bpf_setsockopt (bpf_socket, level, optname, optval, optlen);
 }
 
 /* { dg-final { scan-assembler "call\t49" } } */
index abe813d..9e66e94 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   void *ret, *sk;
 
-  ret = __builtin_bpf_helper_sk_fullsock (sk);
+  ret = bpf_sk_fullsock (sk);
 }
 
 /* { dg-final { scan-assembler "call\t95" } } */
index 4408640..1adcc69 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,10 +12,10 @@ foo ()
   uint32_t tuple_size;
   uint64_t netns, flags;
   
-  ret = __builtin_bpf_helper_sk_lookup_tcp (ctx,
-                                           tuple,
-                                           tuple_size,
-                                           netns, flags);
+  ret = bpf_sk_lookup_tcp (ctx,
+                          tuple,
+                          tuple_size,
+                          netns, flags);
 }
 
 /* { dg-final { scan-assembler "call\t84" } } */
index 4c50f9c..8bbd40b 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t tuple_size;
   uint64_t netns, flags;
   
-  ret = __builtin_bpf_helper_sk_lookup_udp (ctx,
+  ret = bpf_sk_lookup_udp (ctx,
                                            tuple,
                                            tuple_size,
                                            netns, flags);
index 7047c9f..f449b5b 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,8 +11,7 @@ foo ()
   void *skb, *map, *key;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_sk_redirect_hash (skb, map, key,
-                                              flags);
+  ret = bpf_sk_redirect_hash (skb, map, key, flags);
 }
 
 /* { dg-final { scan-assembler "call\t72" } } */
index 5afb0ac..0ebb315 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t key;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_sk_redirect_map (ctx, map, key, flags);
+  ret = bpf_sk_redirect_map (ctx, map, key, flags);
 }
 
 /* { dg-final { scan-assembler "call\t52" } } */
index f054c90..620dbe9 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   int ret;
   void *sock;
   
-  ret = __builtin_bpf_helper_sk_release (sock);
+  ret = bpf_sk_release (sock);
 }
 
 /* { dg-final { scan-assembler "call\t86" } } */
index 399ad2c..0505fc9 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *reuse, *map, *key;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_sk_select_reuseport (reuse, map,
+  ret = bpf_sk_select_reuseport (reuse, map,
                                                  key, flags);
 }
 
index 07c5875..a25421f 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   int ret;
   void *map, *sk;
   
-  ret = __builtin_bpf_helper_sk_storage_delete (map, sk);
+  ret = bpf_sk_storage_delete (map, sk);
 }
 
 /* { dg-final { scan-assembler "call\t108" } } */
index a199ef0..6d047dd 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,8 +11,7 @@ foo ()
   void *map, *sk, *value;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_sk_storage_get (map, sk, value,
-                                            flags);
+  ret = bpf_sk_storage_get (map, sk, value, flags);
 }
 
 /* { dg-final { scan-assembler "call\t107" } } */
index 88196f5..6b1eef9 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -11,7 +13,7 @@ foo ()
   uint32_t mode;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_skb_adjust_room (skb, len_diff, mode, flags);
+  ret = bpf_skb_adjust_room (skb, len_diff, mode, flags);
 }
 
 /* { dg-final { scan-assembler "call\t50" } } */
index 7c9021e..7ad08c1 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   uint64_t ret;
   void *skb;
   
-  ret = __builtin_bpf_helper_skb_cgroup_id (skb);
+  ret = bpf_skb_cgroup_id (skb);
 }
 
 /* { dg-final { scan-assembler "call\t79" } } */
index de62815..f93cefa 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t len;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_skb_change_head (skb, len, flags);
+  ret = bpf_skb_change_head (skb, len, flags);
 }
 
 /* { dg-final { scan-assembler "call\t43" } } */
index 5738f3c..a41d197 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   int16_t proto;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_skb_change_proto (skb, proto, flags);
+  ret = bpf_skb_change_proto (skb, proto, flags);
 }
 
 /* { dg-final { scan-assembler "call\t31" } } */
index 1fb6b45..2bfc597 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t len;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_skb_change_tail (skb, len, flags);
+  ret = bpf_skb_change_tail (skb, len, flags);
 }
 
 /* { dg-final { scan-assembler "call\t38" } } */
index bcf22ce..46a9421 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb;
   uint32_t type;
 
-  ret = __builtin_bpf_helper_skb_change_type (skb, type);
+  ret = bpf_skb_change_type (skb, type);
 }
 
 /* { dg-final { scan-assembler "call\t32" } } */
index f769993..c028ec1 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   int ret;
   void *skb;
 
-  ret = __builtin_bpf_helper_skb_ecn_set_ce (skb);
+  ret = bpf_skb_ecn_set_ce (skb);
 }
 
 /* { dg-final { scan-assembler "call\t97" } } */
index 0d4db23..aad8472 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t size;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_skb_get_tunnel_key (skb, key, size, flags);
+  ret = bpf_skb_get_tunnel_key (skb, key, size, flags);
 }
 
 /* { dg-final { scan-assembler "call\t20" } } */
index 9428657..0b39ad7 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint8_t *opt;
   uint32_t size;
 
-  ret = __builtin_bpf_helper_skb_get_tunnel_opt (skb, opt, size);
+  ret = bpf_skb_get_tunnel_opt (skb, opt, size);
 }
 
 /* { dg-final { scan-assembler "call\t29" } } */
index 8217b4a..de83d91 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,8 +12,8 @@ foo ()
   uint32_t index, size;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_skb_get_xfrm_state (skb, index,
-                                                xfrm_state, size, flags);
+  ret = bpf_skb_get_xfrm_state (skb, index,
+                               xfrm_state, size, flags);
 }
 
 /* { dg-final { scan-assembler "call\t66" } } */
index bcaa43b..cd8c2c2 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,9 +11,9 @@ foo ()
   void *skb, *to;
   uint32_t offset, len, start_header;
 
-  ret = __builtin_bpf_helper_skb_load_bytes_relative (skb, offset,
-                                                     to, len,
-                                                     start_header);
+  ret = bpf_skb_load_bytes_relative (skb, offset,
+                                    to, len,
+                                    start_header);
 }
 
 /* { dg-final { scan-assembler "call\t68" } } */
index 9da5454..1e4612a 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb, *to;
   uint32_t offset, len;
 
-  ret = __builtin_bpf_helper_skb_load_bytes (skb, offset, to, len);
+  ret = bpf_skb_load_bytes (skb, offset, to, len);
 }
 
 /* { dg-final { scan-assembler "call\t26" } } */
index 9bb8b8d..579d856 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb;
   uint32_t len;
 
-  ret = __builtin_bpf_helper_skb_pull_data (skb, len);
+  ret = bpf_skb_pull_data (skb, len);
 }
 
 /* { dg-final { scan-assembler "call\t39" } } */
index 21b835f..85754fd 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint32_t size;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_skb_set_tunnel_key (skb, key, size, flags);
+  ret = bpf_skb_set_tunnel_key (skb, key, size, flags);
 }
 
 /* { dg-final { scan-assembler "call\t21" } } */
index 5a0528e..591eb48 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   uint8_t *opt;
   uint32_t size;
 
-  ret = __builtin_bpf_helper_skb_set_tunnel_opt (skb, opt, size);
+  ret = bpf_skb_set_tunnel_opt (skb, opt, size);
 }
 
 /* { dg-final { scan-assembler "call\t30" } } */
index a41967c..17f8e02 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -12,7 +14,7 @@ foo ()
   uint32_t len;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_skb_store_bytes (skb, offset, from, len, flags);
+  ret = bpf_skb_store_bytes (skb, offset, from, len, flags);
 }
 
 /* { dg-final { scan-assembler "call\t9" } } */
index 0ccee8b..72adfcd 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb, *map;
   uint32_t index;
 
-  ret = __builtin_bpf_helper_skb_under_cgroup (skb, map, index);
+  ret = bpf_skb_under_cgroup (skb, map, index);
 }
 
 /* { dg-final { scan-assembler "call\t33" } } */
index e99a0ac..4d5b347 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -8,7 +10,7 @@ foo ()
   int ret;
   void *skb;
 
-  ret = __builtin_bpf_helper_skb_vlan_pop (skb);
+  ret = bpf_skb_vlan_pop (skb);
 }
 
 /* { dg-final { scan-assembler "call\t19" } } */
index dbe52ae..1a43bd4 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,7 +12,7 @@ foo ()
   int16_t vlan_proto;
   uint16_t vlan_tci;
 
-  ret = __builtin_bpf_helper_skb_vlan_push (skb, vlan_proto, vlan_tci);
+  ret = bpf_skb_vlan_push (skb, vlan_proto, vlan_tci);
 }
 
 /* { dg-final { scan-assembler "call\t18" } } */
index bbc4b99..8ed2d46 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,8 +12,8 @@ foo ()
   uint32_t tuple_size;
   uint64_t netns, flags;
 
-  ret = __builtin_bpf_helper_skc_lookup_tcp (ctx, tuple,
-                                            tuple_size, netns, flags);
+  ret = bpf_skc_lookup_tcp (ctx, tuple,
+                           tuple_size, netns, flags);
 }
 
 /* { dg-final { scan-assembler "call\t99" } } */
index bbb77ef..81ff4dd 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skops, *map, *key;
   uint64_t flags;
 
-  ret = __builtin_bpf_helper_sock_hash_update (skops, map, key,
+  ret = bpf_sock_hash_update (skops, map, key,
                                               flags);
 }
 
index 301e59e..fbb5d75 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skops, *map, *key;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_sock_map_update (skops, map, key,
+  ret = bpf_sock_map_update (skops, map, key,
                                              flags);
 }
 
index 2056312..4efd69a 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *bpf_sock;
   int argval;
   
-  ret = __builtin_bpf_helper_sock_ops_cb_flags_set (bpf_sock,
+  ret = bpf_sock_ops_cb_flags_set (bpf_sock,
                                                    argval);
 }
 
index 4178914..8358e88 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   void *lock;
 
-  __builtin_bpf_helper_spin_lock (lock);
+  bpf_spin_lock (lock);
 }
 
 /* { dg-final { scan-assembler "call\t93" } } */
index c2416b6..400695f 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   void *lock;
 
-  __builtin_bpf_helper_spin_unlock (lock);
+  bpf_spin_unlock (lock);
 }
 
 /* { dg-final { scan-assembler "call\t94" } } */
index e15b6d6..5383012 100644 (file)
@@ -1,7 +1,9 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
 #include <stddef.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -12,7 +14,7 @@ foo ()
   uint64_t flags;
   size_t buf_len;
   
-  ret = __builtin_bpf_helper_strtol (buf, buf_len, flags, &res);
+  ret = bpf_strtol (buf, buf_len, flags, &res);
 }
 
 /* { dg-final { scan-assembler "call\t105" } } */
index bc0d776..f648a2b 100644 (file)
@@ -1,7 +1,9 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
 #include <stddef.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -12,7 +14,7 @@ foo ()
   uint64_t flags;
   size_t buf_len;
   
-  ret = __builtin_bpf_helper_strtoul (buf, buf_len, flags, &res);
+  ret = bpf_strtoul (buf, buf_len, flags, &res);
 }
 
 /* { dg-final { scan-assembler "call\t106" } } */
index 8035841..55a31e4 100644 (file)
@@ -1,7 +1,9 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
 #include <stddef.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,8 +12,7 @@ foo ()
   void *ctx, *buf;
   size_t buf_len;
   
-  ret = __builtin_bpf_helper_sysctl_get_current_value (ctx, buf,
-                                                      buf_len);
+  ret = bpf_sysctl_get_current_value (ctx, buf, buf_len);
 }
 
 /* { dg-final { scan-assembler "call\t102" } } */
index a748b4b..bacb288 100644 (file)
@@ -1,7 +1,9 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
 #include <stddef.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -11,8 +13,7 @@ foo ()
   size_t buf_len;
   uint64_t flags;
   
-  ret = __builtin_bpf_helper_sysctl_get_name (ctx, buf,
-                                             buf_len, flags);
+  ret = bpf_sysctl_get_name (ctx, buf, buf_len, flags);
 }
 
 /* { dg-final { scan-assembler "call\t101" } } */
index 2c48351..5ad3644 100644 (file)
@@ -1,7 +1,9 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
 #include <stddef.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,8 +12,7 @@ foo ()
   void *ctx, *buf;
   size_t buf_len;
   
-  ret = __builtin_bpf_helper_sysctl_get_new_value (ctx, buf,
-                                                  buf_len);
+  ret = bpf_sysctl_get_new_value (ctx, buf, buf_len);
 }
 
 /* { dg-final { scan-assembler "call\t103" } } */
index fc3780d..2b3b3af 100644 (file)
@@ -1,7 +1,9 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
 #include <stddef.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -10,8 +12,7 @@ foo ()
   void *ctx, *buf;
   size_t buf_len;
   
-  ret = __builtin_bpf_helper_sysctl_set_new_value (ctx, buf,
-                                                  buf_len);
+  ret = bpf_sysctl_set_new_value (ctx, buf, buf_len);
 }
 
 /* { dg-final { scan-assembler "call\t104" } } */
index 618064f..0f35b00 100644 (file)
@@ -1,14 +1,17 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
+  int ret;
   void *ctx, *prog_array_map;
   uint32_t index;
 
-  __builtin_bpf_helper_tail_call (ctx, prog_array_map, index);
+  ret = bpf_tail_call (ctx, prog_array_map, index);
 }
 
 /* { dg-final { scan-assembler "call\t12" } } */
index 95846c6..bada09f 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,9 +11,9 @@ foo ()
   void *sk, *iph, *th;
   uint32_t iph_len, th_len;
   
-  ret = __builtin_bpf_helper_tcp_check_syncookie (sk, iph,
-                                                 iph_len,
-                                                 th, th_len);
+  ret = bpf_tcp_check_syncookie (sk, iph,
+                                iph_len,
+                                th, th_len);
 }
 
 /* { dg-final { scan-assembler "call\t100" } } */
index ab8f2de..cd6d995 100644 (file)
@@ -1,13 +1,15 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
 {
   void *ret, *sk;
 
-  ret = __builtin_bpf_helper_tcp_sock (sk);
+  ret = bpf_tcp_sock (sk);
 }
 
 /* { dg-final { scan-assembler "call\t96" } } */
index fcf9d5c..135ae29 100644 (file)
@@ -1,4 +1,7 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
 
 char *map () { return 0; }
 
@@ -7,7 +10,7 @@ foo ()
 {
   int ret;
 
-  ret = __builtin_bpf_helper_trace_printk ("foo %d %d", sizeof ("foo %d %d"), 10, 20);
+  ret = bpf_trace_printk ("foo %d %d", sizeof ("foo %d %d"), 10, 20);
 }
 
 /* { dg-final { scan-assembler "call\t6" } } */
index 3dce543..352d9d6 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *xdp_md;
   int delta;
   
-  ret = __builtin_bpf_helper_xdp_adjust_head (xdp_md, delta);
+  ret = bpf_xdp_adjust_head (xdp_md, delta);
 }
 
 /* { dg-final { scan-assembler "call\t44" } } */
index 38a1374..ef5da4b 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *xdp_md;
   int delta;
   
-  ret = __builtin_bpf_helper_xdp_adjust_meta (xdp_md, delta);
+  ret = bpf_xdp_adjust_meta (xdp_md, delta);
 }
 
 /* { dg-final { scan-assembler "call\t54" } } */
index 319b65a..db55168 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +10,7 @@ foo ()
   void *xdp_md;
   int delta;
 
-  ret = __builtin_bpf_helper_xdp_adjust_tail (xdp_md, delta);
+  ret = bpf_xdp_adjust_tail (xdp_md, delta);
 }
 
 /* { dg-final { scan-assembler "call\t65" } } */
index ce193ec..8e88c93 100644 (file)
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
 
 #include <stdint.h>
+#include <bpf-helpers.h>
 
 void
 foo ()
@@ -9,7 +11,7 @@ foo ()
   void *skb;
   int ancestor_level;
   
-  ret = __builtin_bpf_helper_skb_ancestor_cgroup_id (skb,
+  ret = bpf_skb_ancestor_cgroup_id (skb,
                                                     ancestor_level);
 }