bpf.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
  2. *
  3. * This program is free software; you can redistribute it and/or
  4. * modify it under the terms of version 2 of the GNU General Public
  5. * License as published by the Free Software Foundation.
  6. */
  7. #ifndef _LINUX_BPF_H
  8. #define _LINUX_BPF_H 1
  9. #include <uapi/linux/bpf.h>
  10. #include <linux/workqueue.h>
  11. #include <linux/file.h>
  12. #include <linux/percpu.h>
  13. #include <linux/err.h>
  14. #include <linux/rbtree_latch.h>
  15. #include <linux/numa.h>
  16. #include <linux/wait.h>
  17. struct perf_event;
  18. struct bpf_prog;
  19. struct bpf_map;
  20. /* map is generic key/value storage optionally accesible by eBPF programs */
  21. struct bpf_map_ops {
  22. /* funcs callable from userspace (via syscall) */
  23. struct bpf_map *(*map_alloc)(union bpf_attr *attr);
  24. void (*map_release)(struct bpf_map *map, struct file *map_file);
  25. void (*map_free)(struct bpf_map *map);
  26. int (*map_get_next_key)(struct bpf_map *map, void *key, void *next_key);
  27. /* funcs callable from userspace and from eBPF programs */
  28. void *(*map_lookup_elem)(struct bpf_map *map, void *key);
  29. int (*map_update_elem)(struct bpf_map *map, void *key, void *value, u64 flags);
  30. int (*map_delete_elem)(struct bpf_map *map, void *key);
  31. /* funcs called by prog_array and perf_event_array map */
  32. void *(*map_fd_get_ptr)(struct bpf_map *map, struct file *map_file,
  33. int fd);
  34. void (*map_fd_put_ptr)(void *ptr);
  35. u32 (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf);
  36. u32 (*map_fd_sys_lookup_elem)(void *ptr);
  37. };
  38. struct bpf_map {
  39. atomic_t refcnt;
  40. enum bpf_map_type map_type;
  41. u32 key_size;
  42. u32 value_size;
  43. u32 max_entries;
  44. u32 map_flags;
  45. u32 pages;
  46. u32 id;
  47. int numa_node;
  48. struct user_struct *user;
  49. const struct bpf_map_ops *ops;
  50. struct work_struct work;
  51. atomic_t usercnt;
  52. struct bpf_map *inner_map_meta;
  53. char name[BPF_OBJ_NAME_LEN];
  54. #ifdef CONFIG_SECURITY
  55. void *security;
  56. #endif
  57. };
  58. /* function argument constraints */
  59. enum bpf_arg_type {
  60. ARG_DONTCARE = 0, /* unused argument in helper function */
  61. /* the following constraints used to prototype
  62. * bpf_map_lookup/update/delete_elem() functions
  63. */
  64. ARG_CONST_MAP_PTR, /* const argument used as pointer to bpf_map */
  65. ARG_PTR_TO_MAP_KEY, /* pointer to stack used as map key */
  66. ARG_PTR_TO_MAP_VALUE, /* pointer to stack used as map value */
  67. /* the following constraints used to prototype bpf_memcmp() and other
  68. * functions that access data on eBPF program stack
  69. */
  70. ARG_PTR_TO_MEM, /* pointer to valid memory (stack, packet, map value) */
  71. ARG_PTR_TO_UNINIT_MEM, /* pointer to memory does not need to be initialized,
  72. * helper function must fill all bytes or clear
  73. * them in error case.
  74. */
  75. ARG_CONST_SIZE, /* number of bytes accessed from memory */
  76. ARG_CONST_SIZE_OR_ZERO, /* number of bytes accessed from memory or 0 */
  77. ARG_PTR_TO_CTX, /* pointer to context */
  78. ARG_ANYTHING, /* any (initialized) argument is ok */
  79. };
  80. /* type of values returned from helper functions */
  81. enum bpf_return_type {
  82. RET_INTEGER, /* function returns integer */
  83. RET_VOID, /* function doesn't return anything */
  84. RET_PTR_TO_MAP_VALUE_OR_NULL, /* returns a pointer to map elem value or NULL */
  85. };
  86. /* eBPF function prototype used by verifier to allow BPF_CALLs from eBPF programs
  87. * to in-kernel helper functions and for adjusting imm32 field in BPF_CALL
  88. * instructions after verifying
  89. */
  90. struct bpf_func_proto {
  91. u64 (*func)(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
  92. bool gpl_only;
  93. bool pkt_access;
  94. enum bpf_return_type ret_type;
  95. enum bpf_arg_type arg1_type;
  96. enum bpf_arg_type arg2_type;
  97. enum bpf_arg_type arg3_type;
  98. enum bpf_arg_type arg4_type;
  99. enum bpf_arg_type arg5_type;
  100. };
  101. /* bpf_context is intentionally undefined structure. Pointer to bpf_context is
  102. * the first argument to eBPF programs.
  103. * For socket filters: 'struct bpf_context *' == 'struct sk_buff *'
  104. */
  105. struct bpf_context;
  106. enum bpf_access_type {
  107. BPF_READ = 1,
  108. BPF_WRITE = 2
  109. };
  110. /* types of values stored in eBPF registers */
  111. /* Pointer types represent:
  112. * pointer
  113. * pointer + imm
  114. * pointer + (u16) var
  115. * pointer + (u16) var + imm
  116. * if (range > 0) then [ptr, ptr + range - off) is safe to access
  117. * if (id > 0) means that some 'var' was added
  118. * if (off > 0) means that 'imm' was added
  119. */
  120. enum bpf_reg_type {
  121. NOT_INIT = 0, /* nothing was written into register */
  122. SCALAR_VALUE, /* reg doesn't contain a valid pointer */
  123. PTR_TO_CTX, /* reg points to bpf_context */
  124. CONST_PTR_TO_MAP, /* reg points to struct bpf_map */
  125. PTR_TO_MAP_VALUE, /* reg points to map element value */
  126. PTR_TO_MAP_VALUE_OR_NULL,/* points to map elem value or NULL */
  127. PTR_TO_STACK, /* reg == frame_pointer + offset */
  128. PTR_TO_PACKET_META, /* skb->data - meta_len */
  129. PTR_TO_PACKET, /* reg points to skb->data */
  130. PTR_TO_PACKET_END, /* skb->data + headlen */
  131. };
  132. /* The information passed from prog-specific *_is_valid_access
  133. * back to the verifier.
  134. */
  135. struct bpf_insn_access_aux {
  136. enum bpf_reg_type reg_type;
  137. int ctx_field_size;
  138. };
  139. static inline void
  140. bpf_ctx_record_field_size(struct bpf_insn_access_aux *aux, u32 size)
  141. {
  142. aux->ctx_field_size = size;
  143. }
  144. struct bpf_prog_ops {
  145. int (*test_run)(struct bpf_prog *prog, const union bpf_attr *kattr,
  146. union bpf_attr __user *uattr);
  147. };
  148. struct bpf_verifier_ops {
  149. /* return eBPF function prototype for verification */
  150. const struct bpf_func_proto *(*get_func_proto)(enum bpf_func_id func_id);
  151. /* return true if 'size' wide access at offset 'off' within bpf_context
  152. * with 'type' (read or write) is allowed
  153. */
  154. bool (*is_valid_access)(int off, int size, enum bpf_access_type type,
  155. struct bpf_insn_access_aux *info);
  156. int (*gen_prologue)(struct bpf_insn *insn, bool direct_write,
  157. const struct bpf_prog *prog);
  158. u32 (*convert_ctx_access)(enum bpf_access_type type,
  159. const struct bpf_insn *src,
  160. struct bpf_insn *dst,
  161. struct bpf_prog *prog, u32 *target_size);
  162. };
  163. struct bpf_dev_offload {
  164. struct bpf_prog *prog;
  165. struct net_device *netdev;
  166. void *dev_priv;
  167. struct list_head offloads;
  168. bool dev_state;
  169. bool verifier_running;
  170. wait_queue_head_t verifier_done;
  171. };
  172. struct bpf_prog_aux {
  173. atomic_t refcnt;
  174. u32 used_map_cnt;
  175. u32 max_ctx_offset;
  176. u32 stack_depth;
  177. u32 id;
  178. struct latch_tree_node ksym_tnode;
  179. struct list_head ksym_lnode;
  180. const struct bpf_prog_ops *ops;
  181. struct bpf_map **used_maps;
  182. struct bpf_prog *prog;
  183. struct user_struct *user;
  184. u64 load_time; /* ns since boottime */
  185. char name[BPF_OBJ_NAME_LEN];
  186. #ifdef CONFIG_SECURITY
  187. void *security;
  188. #endif
  189. struct bpf_dev_offload *offload;
  190. union {
  191. struct work_struct work;
  192. struct rcu_head rcu;
  193. };
  194. };
  195. struct bpf_array {
  196. struct bpf_map map;
  197. u32 elem_size;
  198. /* 'ownership' of prog_array is claimed by the first program that
  199. * is going to use this map or by the first program which FD is stored
  200. * in the map to make sure that all callers and callees have the same
  201. * prog_type and JITed flag
  202. */
  203. enum bpf_prog_type owner_prog_type;
  204. bool owner_jited;
  205. union {
  206. char value[0] __aligned(8);
  207. void *ptrs[0] __aligned(8);
  208. void __percpu *pptrs[0] __aligned(8);
  209. };
  210. };
  211. #define MAX_TAIL_CALL_CNT 32
  212. struct bpf_event_entry {
  213. struct perf_event *event;
  214. struct file *perf_file;
  215. struct file *map_file;
  216. struct rcu_head rcu;
  217. };
  218. bool bpf_prog_array_compatible(struct bpf_array *array, const struct bpf_prog *fp);
  219. int bpf_prog_calc_tag(struct bpf_prog *fp);
  220. const struct bpf_func_proto *bpf_get_trace_printk_proto(void);
  221. typedef unsigned long (*bpf_ctx_copy_t)(void *dst, const void *src,
  222. unsigned long off, unsigned long len);
  223. u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
  224. void *ctx, u64 ctx_size, bpf_ctx_copy_t ctx_copy);
  225. int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
  226. union bpf_attr __user *uattr);
  227. int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
  228. union bpf_attr __user *uattr);
  229. /* an array of programs to be executed under rcu_lock.
  230. *
  231. * Typical usage:
  232. * ret = BPF_PROG_RUN_ARRAY(&bpf_prog_array, ctx, BPF_PROG_RUN);
  233. *
  234. * the structure returned by bpf_prog_array_alloc() should be populated
  235. * with program pointers and the last pointer must be NULL.
  236. * The user has to keep refcnt on the program and make sure the program
  237. * is removed from the array before bpf_prog_put().
  238. * The 'struct bpf_prog_array *' should only be replaced with xchg()
  239. * since other cpus are walking the array of pointers in parallel.
  240. */
  241. struct bpf_prog_array {
  242. struct rcu_head rcu;
  243. struct bpf_prog *progs[0];
  244. };
  245. struct bpf_prog_array __rcu *bpf_prog_array_alloc(u32 prog_cnt, gfp_t flags);
  246. void bpf_prog_array_free(struct bpf_prog_array __rcu *progs);
  247. int bpf_prog_array_length(struct bpf_prog_array __rcu *progs);
  248. int bpf_prog_array_copy_to_user(struct bpf_prog_array __rcu *progs,
  249. __u32 __user *prog_ids, u32 cnt);
  250. void bpf_prog_array_delete_safe(struct bpf_prog_array __rcu *progs,
  251. struct bpf_prog *old_prog);
  252. int bpf_prog_array_copy(struct bpf_prog_array __rcu *old_array,
  253. struct bpf_prog *exclude_prog,
  254. struct bpf_prog *include_prog,
  255. struct bpf_prog_array **new_array);
  256. #define __BPF_PROG_RUN_ARRAY(array, ctx, func, check_non_null) \
  257. ({ \
  258. struct bpf_prog **_prog, *__prog; \
  259. struct bpf_prog_array *_array; \
  260. u32 _ret = 1; \
  261. rcu_read_lock(); \
  262. _array = rcu_dereference(array); \
  263. if (unlikely(check_non_null && !_array))\
  264. goto _out; \
  265. _prog = _array->progs; \
  266. while ((__prog = READ_ONCE(*_prog))) { \
  267. _ret &= func(__prog, ctx); \
  268. _prog++; \
  269. } \
  270. _out: \
  271. rcu_read_unlock(); \
  272. _ret; \
  273. })
  274. #define BPF_PROG_RUN_ARRAY(array, ctx, func) \
  275. __BPF_PROG_RUN_ARRAY(array, ctx, func, false)
  276. #define BPF_PROG_RUN_ARRAY_CHECK(array, ctx, func) \
  277. __BPF_PROG_RUN_ARRAY(array, ctx, func, true)
  278. #ifdef CONFIG_BPF_SYSCALL
  279. DECLARE_PER_CPU(int, bpf_prog_active);
  280. extern const struct file_operations bpf_map_fops;
  281. extern const struct file_operations bpf_prog_fops;
  282. #define BPF_PROG_TYPE(_id, _name) \
  283. extern const struct bpf_prog_ops _name ## _prog_ops; \
  284. extern const struct bpf_verifier_ops _name ## _verifier_ops;
  285. #define BPF_MAP_TYPE(_id, _ops) \
  286. extern const struct bpf_map_ops _ops;
  287. #include <linux/bpf_types.h>
  288. #undef BPF_PROG_TYPE
  289. #undef BPF_MAP_TYPE
  290. extern const struct bpf_prog_ops bpf_offload_prog_ops;
  291. extern const struct bpf_verifier_ops tc_cls_act_analyzer_ops;
  292. extern const struct bpf_verifier_ops xdp_analyzer_ops;
  293. struct bpf_prog *bpf_prog_get(u32 ufd);
  294. struct bpf_prog *bpf_prog_get_type(u32 ufd, enum bpf_prog_type type);
  295. struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type,
  296. struct net_device *netdev);
  297. struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog, int i);
  298. void bpf_prog_sub(struct bpf_prog *prog, int i);
  299. struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog);
  300. struct bpf_prog * __must_check bpf_prog_inc_not_zero(struct bpf_prog *prog);
  301. void bpf_prog_put(struct bpf_prog *prog);
  302. int __bpf_prog_charge(struct user_struct *user, u32 pages);
  303. void __bpf_prog_uncharge(struct user_struct *user, u32 pages);
  304. struct bpf_map *bpf_map_get_with_uref(u32 ufd);
  305. struct bpf_map *__bpf_map_get(struct fd f);
  306. struct bpf_map * __must_check bpf_map_inc(struct bpf_map *map, bool uref);
  307. void bpf_map_put_with_uref(struct bpf_map *map);
  308. void bpf_map_put(struct bpf_map *map);
  309. int bpf_map_precharge_memlock(u32 pages);
  310. void *bpf_map_area_alloc(size_t size, int numa_node);
  311. void bpf_map_area_free(void *base);
  312. extern int sysctl_unprivileged_bpf_disabled;
  313. int bpf_map_new_fd(struct bpf_map *map, int flags);
  314. int bpf_prog_new_fd(struct bpf_prog *prog);
  315. int bpf_obj_pin_user(u32 ufd, const char __user *pathname);
  316. int bpf_obj_get_user(const char __user *pathname, int flags);
  317. int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value);
  318. int bpf_percpu_array_copy(struct bpf_map *map, void *key, void *value);
  319. int bpf_percpu_hash_update(struct bpf_map *map, void *key, void *value,
  320. u64 flags);
  321. int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value,
  322. u64 flags);
  323. int bpf_stackmap_copy(struct bpf_map *map, void *key, void *value);
  324. int bpf_fd_array_map_update_elem(struct bpf_map *map, struct file *map_file,
  325. void *key, void *value, u64 map_flags);
  326. int bpf_fd_array_map_lookup_elem(struct bpf_map *map, void *key, u32 *value);
  327. void bpf_fd_array_map_clear(struct bpf_map *map);
  328. int bpf_fd_htab_map_update_elem(struct bpf_map *map, struct file *map_file,
  329. void *key, void *value, u64 map_flags);
  330. int bpf_fd_htab_map_lookup_elem(struct bpf_map *map, void *key, u32 *value);
  331. int bpf_get_file_flag(int flags);
  332. /* memcpy that is used with 8-byte aligned pointers, power-of-8 size and
  333. * forced to use 'long' read/writes to try to atomically copy long counters.
  334. * Best-effort only. No barriers here, since it _will_ race with concurrent
  335. * updates from BPF programs. Called from bpf syscall and mostly used with
  336. * size 8 or 16 bytes, so ask compiler to inline it.
  337. */
  338. static inline void bpf_long_memcpy(void *dst, const void *src, u32 size)
  339. {
  340. const long *lsrc = src;
  341. long *ldst = dst;
  342. size /= sizeof(long);
  343. while (size--)
  344. *ldst++ = *lsrc++;
  345. }
  346. /* verify correctness of eBPF program */
  347. int bpf_check(struct bpf_prog **fp, union bpf_attr *attr);
  348. /* Map specifics */
  349. struct net_device *__dev_map_lookup_elem(struct bpf_map *map, u32 key);
  350. void __dev_map_insert_ctx(struct bpf_map *map, u32 index);
  351. void __dev_map_flush(struct bpf_map *map);
  352. struct bpf_cpu_map_entry *__cpu_map_lookup_elem(struct bpf_map *map, u32 key);
  353. void __cpu_map_insert_ctx(struct bpf_map *map, u32 index);
  354. void __cpu_map_flush(struct bpf_map *map);
  355. struct xdp_buff;
  356. int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp,
  357. struct net_device *dev_rx);
  358. /* Return map's numa specified by userspace */
  359. static inline int bpf_map_attr_numa_node(const union bpf_attr *attr)
  360. {
  361. return (attr->map_flags & BPF_F_NUMA_NODE) ?
  362. attr->numa_node : NUMA_NO_NODE;
  363. }
  364. #else /* !CONFIG_BPF_SYSCALL */
  365. static inline struct bpf_prog *bpf_prog_get(u32 ufd)
  366. {
  367. return ERR_PTR(-EOPNOTSUPP);
  368. }
  369. static inline struct bpf_prog *bpf_prog_get_type(u32 ufd,
  370. enum bpf_prog_type type)
  371. {
  372. return ERR_PTR(-EOPNOTSUPP);
  373. }
  374. static inline struct bpf_prog *bpf_prog_get_type_dev(u32 ufd,
  375. enum bpf_prog_type type,
  376. struct net_device *netdev)
  377. {
  378. return ERR_PTR(-EOPNOTSUPP);
  379. }
  380. static inline struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog,
  381. int i)
  382. {
  383. return ERR_PTR(-EOPNOTSUPP);
  384. }
  385. static inline void bpf_prog_sub(struct bpf_prog *prog, int i)
  386. {
  387. }
  388. static inline void bpf_prog_put(struct bpf_prog *prog)
  389. {
  390. }
  391. static inline struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog)
  392. {
  393. return ERR_PTR(-EOPNOTSUPP);
  394. }
  395. static inline struct bpf_prog *__must_check
  396. bpf_prog_inc_not_zero(struct bpf_prog *prog)
  397. {
  398. return ERR_PTR(-EOPNOTSUPP);
  399. }
  400. static inline int __bpf_prog_charge(struct user_struct *user, u32 pages)
  401. {
  402. return 0;
  403. }
  404. static inline void __bpf_prog_uncharge(struct user_struct *user, u32 pages)
  405. {
  406. }
  407. static inline int bpf_obj_get_user(const char __user *pathname, int flags)
  408. {
  409. return -EOPNOTSUPP;
  410. }
  411. static inline struct net_device *__dev_map_lookup_elem(struct bpf_map *map,
  412. u32 key)
  413. {
  414. return NULL;
  415. }
  416. static inline void __dev_map_insert_ctx(struct bpf_map *map, u32 index)
  417. {
  418. }
  419. static inline void __dev_map_flush(struct bpf_map *map)
  420. {
  421. }
  422. static inline
  423. struct bpf_cpu_map_entry *__cpu_map_lookup_elem(struct bpf_map *map, u32 key)
  424. {
  425. return NULL;
  426. }
  427. static inline void __cpu_map_insert_ctx(struct bpf_map *map, u32 index)
  428. {
  429. }
  430. static inline void __cpu_map_flush(struct bpf_map *map)
  431. {
  432. }
  433. struct xdp_buff;
  434. static inline int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu,
  435. struct xdp_buff *xdp,
  436. struct net_device *dev_rx)
  437. {
  438. return 0;
  439. }
  440. #endif /* CONFIG_BPF_SYSCALL */
  441. int bpf_prog_offload_compile(struct bpf_prog *prog);
  442. void bpf_prog_offload_destroy(struct bpf_prog *prog);
  443. u32 bpf_prog_offload_ifindex(struct bpf_prog *prog);
  444. #if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)
  445. int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr);
  446. static inline bool bpf_prog_is_dev_bound(struct bpf_prog_aux *aux)
  447. {
  448. return aux->offload;
  449. }
  450. #else
  451. static inline int bpf_prog_offload_init(struct bpf_prog *prog,
  452. union bpf_attr *attr)
  453. {
  454. return -EOPNOTSUPP;
  455. }
  456. static inline bool bpf_prog_is_dev_bound(struct bpf_prog_aux *aux)
  457. {
  458. return false;
  459. }
  460. #endif /* CONFIG_NET && CONFIG_BPF_SYSCALL */
  461. #if defined(CONFIG_STREAM_PARSER) && defined(CONFIG_BPF_SYSCALL)
  462. struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key);
  463. int sock_map_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type);
  464. #else
  465. static inline struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key)
  466. {
  467. return NULL;
  468. }
  469. static inline int sock_map_prog(struct bpf_map *map,
  470. struct bpf_prog *prog,
  471. u32 type)
  472. {
  473. return -EOPNOTSUPP;
  474. }
  475. #endif
  476. /* verifier prototypes for helper functions called from eBPF programs */
  477. extern const struct bpf_func_proto bpf_map_lookup_elem_proto;
  478. extern const struct bpf_func_proto bpf_map_update_elem_proto;
  479. extern const struct bpf_func_proto bpf_map_delete_elem_proto;
  480. extern const struct bpf_func_proto bpf_get_prandom_u32_proto;
  481. extern const struct bpf_func_proto bpf_get_smp_processor_id_proto;
  482. extern const struct bpf_func_proto bpf_get_numa_node_id_proto;
  483. extern const struct bpf_func_proto bpf_tail_call_proto;
  484. extern const struct bpf_func_proto bpf_ktime_get_ns_proto;
  485. extern const struct bpf_func_proto bpf_get_current_pid_tgid_proto;
  486. extern const struct bpf_func_proto bpf_get_current_uid_gid_proto;
  487. extern const struct bpf_func_proto bpf_get_current_comm_proto;
  488. extern const struct bpf_func_proto bpf_skb_vlan_push_proto;
  489. extern const struct bpf_func_proto bpf_skb_vlan_pop_proto;
  490. extern const struct bpf_func_proto bpf_get_stackid_proto;
  491. extern const struct bpf_func_proto bpf_sock_map_update_proto;
  492. /* Shared helpers among cBPF and eBPF. */
  493. void bpf_user_rnd_init_once(void);
  494. u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
  495. #endif /* _LINUX_BPF_H */