bpf_sk_storage.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2019 Facebook */
  3. #ifndef _BPF_SK_STORAGE_H
  4. #define _BPF_SK_STORAGE_H
  5. #include <linux/rculist.h>
  6. #include <linux/list.h>
  7. #include <linux/hash.h>
  8. #include <linux/types.h>
  9. #include <linux/spinlock.h>
  10. #include <linux/bpf.h>
  11. #include <net/sock.h>
  12. #include <uapi/linux/sock_diag.h>
  13. #include <uapi/linux/btf.h>
  14. #include <linux/bpf_local_storage.h>
  15. struct sock;
  16. void bpf_sk_storage_free(struct sock *sk);
  17. extern const struct bpf_func_proto bpf_sk_storage_get_proto;
  18. extern const struct bpf_func_proto bpf_sk_storage_delete_proto;
  19. extern const struct bpf_func_proto bpf_sk_storage_get_tracing_proto;
  20. extern const struct bpf_func_proto bpf_sk_storage_delete_tracing_proto;
  21. struct bpf_local_storage_elem;
  22. struct bpf_sk_storage_diag;
  23. struct sk_buff;
  24. struct nlattr;
  25. #ifdef CONFIG_BPF_SYSCALL
  26. int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk);
  27. struct bpf_sk_storage_diag *
  28. bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs);
  29. void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag);
  30. int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
  31. struct sock *sk, struct sk_buff *skb,
  32. int stg_array_type,
  33. unsigned int *res_diag_size);
  34. #else
  35. static inline int bpf_sk_storage_clone(const struct sock *sk,
  36. struct sock *newsk)
  37. {
  38. return 0;
  39. }
  40. static inline struct bpf_sk_storage_diag *
  41. bpf_sk_storage_diag_alloc(const struct nlattr *nla)
  42. {
  43. return NULL;
  44. }
  45. static inline void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag)
  46. {
  47. }
  48. static inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
  49. struct sock *sk, struct sk_buff *skb,
  50. int stg_array_type,
  51. unsigned int *res_diag_size)
  52. {
  53. return 0;
  54. }
  55. #endif
  56. #endif /* _BPF_SK_STORAGE_H */