0001
0002
0003 #ifndef _BPF_SK_STORAGE_H
0004 #define _BPF_SK_STORAGE_H
0005
0006 #include <linux/rculist.h>
0007 #include <linux/list.h>
0008 #include <linux/hash.h>
0009 #include <linux/types.h>
0010 #include <linux/spinlock.h>
0011 #include <linux/bpf.h>
0012 #include <net/sock.h>
0013 #include <uapi/linux/sock_diag.h>
0014 #include <uapi/linux/btf.h>
0015 #include <linux/bpf_local_storage.h>
0016
0017 struct sock;
0018
0019 void bpf_sk_storage_free(struct sock *sk);
0020
0021 extern const struct bpf_func_proto bpf_sk_storage_get_proto;
0022 extern const struct bpf_func_proto bpf_sk_storage_delete_proto;
0023 extern const struct bpf_func_proto bpf_sk_storage_get_tracing_proto;
0024 extern const struct bpf_func_proto bpf_sk_storage_delete_tracing_proto;
0025
0026 struct bpf_local_storage_elem;
0027 struct bpf_sk_storage_diag;
0028 struct sk_buff;
0029 struct nlattr;
0030
0031 #ifdef CONFIG_BPF_SYSCALL
0032 int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk);
0033 struct bpf_sk_storage_diag *
0034 bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs);
0035 void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag);
0036 int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
0037 struct sock *sk, struct sk_buff *skb,
0038 int stg_array_type,
0039 unsigned int *res_diag_size);
0040 #else
0041 static inline int bpf_sk_storage_clone(const struct sock *sk,
0042 struct sock *newsk)
0043 {
0044 return 0;
0045 }
0046 static inline struct bpf_sk_storage_diag *
0047 bpf_sk_storage_diag_alloc(const struct nlattr *nla)
0048 {
0049 return NULL;
0050 }
0051 static inline void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag)
0052 {
0053 }
0054 static inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
0055 struct sock *sk, struct sk_buff *skb,
0056 int stg_array_type,
0057 unsigned int *res_diag_size)
0058 {
0059 return 0;
0060 }
0061 #endif
0062
0063 #endif