+++ /dev/null
-/* 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:
-*/
#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
{
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
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. */
bpf_target_macros (cpp_reader *pfile)
{
builtin_define ("__BPF__");
-
+
if (TARGET_BIG_ENDIAN)
builtin_define ("__BPF_BIG_ENDIAN__");
else
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__=",
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,
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);
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
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. */
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
* ARM Function Attributes::
* AVR Function Attributes::
* Blackfin Function Attributes::
+* BPF Function Attributes::
* CR16 Function Attributes::
* C-SKY Function Attributes::
* Epiphany Function Attributes::
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
* 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::
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
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { 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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
}
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
char *map () { return 0; }
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
char *map () { return 0; }
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
char *map () { return 0; }
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
char *map () { return 0; }
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" } } */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
+#include <bpf-helpers.h>
+
char *map () { return 0; }
void
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" } } */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
+#include <bpf-helpers.h>
+
char *map () { return 0; }
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
}
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
}
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
foo ()
uint32_t protocol, toggle;
uint64_t scancode;
- ret = __builtin_bpf_helper_rc_keydown (ctx, protocol,
+ ret = bpf_rc_keydown (ctx, protocol,
scancode, toggle);
}
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
foo ()
int ret;
void *ctx;
- ret = __builtin_bpf_helper_rc_repeat (ctx);
+ ret = bpf_rc_repeat (ctx);
}
/* { dg-final { scan-assembler "call\t77" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
foo ()
int ret;
void *sock;
- ret = __builtin_bpf_helper_sk_release (sock);
+ ret = bpf_sk_release (sock);
}
/* { dg-final { scan-assembler "call\t86" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
}
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
}
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
}
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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);
}
/* { 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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
#include <stddef.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
#include <stddef.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
#include <stddef.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
#include <stddef.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
#include <stddef.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
#include <stddef.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { 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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <bpf-helpers.h>
char *map () { return 0; }
{
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
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" } } */
/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
#include <stdint.h>
+#include <bpf-helpers.h>
void
foo ()
void *skb;
int ancestor_level;
- ret = __builtin_bpf_helper_skb_ancestor_cgroup_id (skb,
+ ret = bpf_skb_ancestor_cgroup_id (skb,
ancestor_level);
}