bpf_kfuncs.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef __BPF_KFUNCS__
  2. #define __BPF_KFUNCS__
  3. struct bpf_sock_addr_kern;
  4. /* Description
  5. * Initializes an skb-type dynptr
  6. * Returns
  7. * Error code
  8. */
  9. extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
  10. struct bpf_dynptr *ptr__uninit) __ksym __weak;
  11. /* Description
  12. * Initializes an xdp-type dynptr
  13. * Returns
  14. * Error code
  15. */
  16. extern int bpf_dynptr_from_xdp(struct xdp_md *xdp, __u64 flags,
  17. struct bpf_dynptr *ptr__uninit) __ksym __weak;
  18. /* Description
  19. * Obtain a read-only pointer to the dynptr's data
  20. * Returns
  21. * Either a direct pointer to the dynptr data or a pointer to the user-provided
  22. * buffer if unable to obtain a direct pointer
  23. */
  24. extern void *bpf_dynptr_slice(const struct bpf_dynptr *ptr, __u32 offset,
  25. void *buffer, __u32 buffer__szk) __ksym __weak;
  26. /* Description
  27. * Obtain a read-write pointer to the dynptr's data
  28. * Returns
  29. * Either a direct pointer to the dynptr data or a pointer to the user-provided
  30. * buffer if unable to obtain a direct pointer
  31. */
  32. extern void *bpf_dynptr_slice_rdwr(const struct bpf_dynptr *ptr, __u32 offset,
  33. void *buffer, __u32 buffer__szk) __ksym __weak;
  34. extern int bpf_dynptr_adjust(const struct bpf_dynptr *ptr, __u32 start, __u32 end) __ksym __weak;
  35. extern bool bpf_dynptr_is_null(const struct bpf_dynptr *ptr) __ksym __weak;
  36. extern bool bpf_dynptr_is_rdonly(const struct bpf_dynptr *ptr) __ksym __weak;
  37. extern __u32 bpf_dynptr_size(const struct bpf_dynptr *ptr) __ksym __weak;
  38. extern int bpf_dynptr_clone(const struct bpf_dynptr *ptr, struct bpf_dynptr *clone__init) __ksym __weak;
  39. /* Description
  40. * Modify the address of a AF_UNIX sockaddr.
  41. * Returns
  42. * -EINVAL if the address size is too big or, 0 if the sockaddr was successfully modified.
  43. */
  44. extern int bpf_sock_addr_set_sun_path(struct bpf_sock_addr_kern *sa_kern,
  45. const __u8 *sun_path, __u32 sun_path__sz) __ksym;
  46. /* Description
  47. * Allocate and configure a reqsk and link it with a listener and skb.
  48. * Returns
  49. * Error code
  50. */
  51. struct sock;
  52. struct bpf_tcp_req_attrs;
  53. extern int bpf_sk_assign_tcp_reqsk(struct __sk_buff *skb, struct sock *sk,
  54. struct bpf_tcp_req_attrs *attrs, int attrs__sz) __ksym;
  55. void *bpf_cast_to_kern_ctx(void *) __ksym;
  56. extern void *bpf_rdonly_cast(const void *obj, __u32 btf_id) __ksym __weak;
  57. extern int bpf_get_file_xattr(struct file *file, const char *name,
  58. struct bpf_dynptr *value_ptr) __ksym;
  59. extern int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr *digest_ptr) __ksym;
  60. extern struct bpf_key *bpf_lookup_user_key(__u32 serial, __u64 flags) __ksym;
  61. extern struct bpf_key *bpf_lookup_system_key(__u64 id) __ksym;
  62. extern void bpf_key_put(struct bpf_key *key) __ksym;
  63. extern int bpf_verify_pkcs7_signature(struct bpf_dynptr *data_ptr,
  64. struct bpf_dynptr *sig_ptr,
  65. struct bpf_key *trusted_keyring) __ksym;
  66. extern bool bpf_session_is_return(void) __ksym __weak;
  67. extern __u64 *bpf_session_cookie(void) __ksym __weak;
  68. struct dentry;
  69. /* Description
  70. * Returns xattr of a dentry
  71. * Returns
  72. * Error code
  73. */
  74. extern int bpf_get_dentry_xattr(struct dentry *dentry, const char *name,
  75. struct bpf_dynptr *value_ptr) __ksym __weak;
  76. #endif