xref: /openbmc/linux/include/net/bpf_sk_storage.h (revision 8be98d2f2a0a262f8bf8a0bc1fdf522b3c7aab17)
16ac99e8fSMartin KaFai Lau /* SPDX-License-Identifier: GPL-2.0 */
26ac99e8fSMartin KaFai Lau /* Copyright (c) 2019 Facebook */
36ac99e8fSMartin KaFai Lau #ifndef _BPF_SK_STORAGE_H
46ac99e8fSMartin KaFai Lau #define _BPF_SK_STORAGE_H
56ac99e8fSMartin KaFai Lau 
6f836a56eSKP Singh #include <linux/rculist.h>
7f836a56eSKP Singh #include <linux/list.h>
8f836a56eSKP Singh #include <linux/hash.h>
94cc9ce4eSKP Singh #include <linux/types.h>
104cc9ce4eSKP Singh #include <linux/spinlock.h>
11f836a56eSKP Singh #include <linux/bpf.h>
12f836a56eSKP Singh #include <net/sock.h>
13f836a56eSKP Singh #include <uapi/linux/sock_diag.h>
14f836a56eSKP Singh #include <uapi/linux/btf.h>
15450af8d0SKP Singh #include <linux/bpf_local_storage.h>
164cc9ce4eSKP Singh 
176ac99e8fSMartin KaFai Lau struct sock;
186ac99e8fSMartin KaFai Lau 
196ac99e8fSMartin KaFai Lau void bpf_sk_storage_free(struct sock *sk);
206ac99e8fSMartin KaFai Lau 
216ac99e8fSMartin KaFai Lau extern const struct bpf_func_proto bpf_sk_storage_get_proto;
226ac99e8fSMartin KaFai Lau extern const struct bpf_func_proto bpf_sk_storage_delete_proto;
23*8e4597c6SMartin KaFai Lau extern const struct bpf_func_proto bpf_sk_storage_get_tracing_proto;
24*8e4597c6SMartin KaFai Lau extern const struct bpf_func_proto bpf_sk_storage_delete_tracing_proto;
256ac99e8fSMartin KaFai Lau 
26f836a56eSKP Singh struct bpf_local_storage_elem;
271ed4d924SMartin KaFai Lau struct bpf_sk_storage_diag;
281ed4d924SMartin KaFai Lau struct sk_buff;
291ed4d924SMartin KaFai Lau struct nlattr;
301ed4d924SMartin KaFai Lau 
318f51dfc7SStanislav Fomichev #ifdef CONFIG_BPF_SYSCALL
328f51dfc7SStanislav Fomichev int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk);
331ed4d924SMartin KaFai Lau struct bpf_sk_storage_diag *
341ed4d924SMartin KaFai Lau bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs);
351ed4d924SMartin KaFai Lau void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag);
361ed4d924SMartin KaFai Lau int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
371ed4d924SMartin KaFai Lau 			    struct sock *sk, struct sk_buff *skb,
381ed4d924SMartin KaFai Lau 			    int stg_array_type,
391ed4d924SMartin KaFai Lau 			    unsigned int *res_diag_size);
408f51dfc7SStanislav Fomichev #else
bpf_sk_storage_clone(const struct sock * sk,struct sock * newsk)418f51dfc7SStanislav Fomichev static inline int bpf_sk_storage_clone(const struct sock *sk,
428f51dfc7SStanislav Fomichev 				       struct sock *newsk)
438f51dfc7SStanislav Fomichev {
448f51dfc7SStanislav Fomichev 	return 0;
458f51dfc7SStanislav Fomichev }
461ed4d924SMartin KaFai Lau static inline struct bpf_sk_storage_diag *
bpf_sk_storage_diag_alloc(const struct nlattr * nla)471ed4d924SMartin KaFai Lau bpf_sk_storage_diag_alloc(const struct nlattr *nla)
481ed4d924SMartin KaFai Lau {
491ed4d924SMartin KaFai Lau 	return NULL;
501ed4d924SMartin KaFai Lau }
bpf_sk_storage_diag_free(struct bpf_sk_storage_diag * diag)511ed4d924SMartin KaFai Lau static inline void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag)
521ed4d924SMartin KaFai Lau {
531ed4d924SMartin KaFai Lau }
bpf_sk_storage_diag_put(struct bpf_sk_storage_diag * diag,struct sock * sk,struct sk_buff * skb,int stg_array_type,unsigned int * res_diag_size)541ed4d924SMartin KaFai Lau static inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
551ed4d924SMartin KaFai Lau 					  struct sock *sk, struct sk_buff *skb,
561ed4d924SMartin KaFai Lau 					  int stg_array_type,
571ed4d924SMartin KaFai Lau 					  unsigned int *res_diag_size)
581ed4d924SMartin KaFai Lau {
591ed4d924SMartin KaFai Lau 	return 0;
601ed4d924SMartin KaFai Lau }
618f51dfc7SStanislav Fomichev #endif
628f51dfc7SStanislav Fomichev 
636ac99e8fSMartin KaFai Lau #endif /* _BPF_SK_STORAGE_H */
64