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
6#include <linux/rculist.h>
7#include <linux/list.h>
8#include <linux/hash.h>
9#include <linux/types.h>
10#include <linux/spinlock.h>
11#include <linux/bpf.h>
12#include <net/sock.h>
13#include <uapi/linux/sock_diag.h>
14#include <uapi/linux/btf.h>
15#include <linux/bpf_local_storage.h>
16
17struct sock;
18
19void bpf_sk_storage_free(struct sock *sk);
20
21extern const struct bpf_func_proto bpf_sk_storage_get_proto;
22extern const struct bpf_func_proto bpf_sk_storage_delete_proto;
23
24struct bpf_local_storage_elem;
25struct bpf_sk_storage_diag;
26struct sk_buff;
27struct nlattr;
28struct sock;
29
30#ifdef CONFIG_BPF_SYSCALL
31int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk);
32struct bpf_sk_storage_diag *
33bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs);
34void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag);
35int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
36			    struct sock *sk, struct sk_buff *skb,
37			    int stg_array_type,
38			    unsigned int *res_diag_size);
39#else
40static inline int bpf_sk_storage_clone(const struct sock *sk,
41				       struct sock *newsk)
42{
43	return 0;
44}
45static inline struct bpf_sk_storage_diag *
46bpf_sk_storage_diag_alloc(const struct nlattr *nla)
47{
48	return NULL;
49}
50static inline void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag)
51{
52}
53static inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
54					  struct sock *sk, struct sk_buff *skb,
55					  int stg_array_type,
56					  unsigned int *res_diag_size)
57{
58	return 0;
59}
60#endif
61
62#endif /* _BPF_SK_STORAGE_H */
63