blob: 119f4c9c3a9cc0e8b4c8cc5800b0796e95adb4c9 [file] [log] [blame]
Martin KaFai Lau6ac99e82019-04-26 16:39:39 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2019 Facebook */
3#ifndef _BPF_SK_STORAGE_H
4#define _BPF_SK_STORAGE_H
5
KP Singhf836a562020-08-25 20:29:15 +02006#include <linux/rculist.h>
7#include <linux/list.h>
8#include <linux/hash.h>
KP Singh4cc9ce42020-08-25 20:29:14 +02009#include <linux/types.h>
10#include <linux/spinlock.h>
KP Singhf836a562020-08-25 20:29:15 +020011#include <linux/bpf.h>
12#include <net/sock.h>
13#include <uapi/linux/sock_diag.h>
14#include <uapi/linux/btf.h>
KP Singh450af8d2020-08-25 20:29:16 +020015#include <linux/bpf_local_storage.h>
KP Singh4cc9ce42020-08-25 20:29:14 +020016
Martin KaFai Lau6ac99e82019-04-26 16:39:39 -070017struct 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;
KP Singh30897832020-08-25 20:29:18 +020023extern const struct bpf_func_proto sk_storage_get_btf_proto;
24extern const struct bpf_func_proto sk_storage_delete_btf_proto;
Martin KaFai Lau6ac99e82019-04-26 16:39:39 -070025
KP Singhf836a562020-08-25 20:29:15 +020026struct bpf_local_storage_elem;
Martin KaFai Lau1ed4d922020-02-25 15:04:21 -080027struct bpf_sk_storage_diag;
28struct sk_buff;
29struct nlattr;
30struct sock;
31
Stanislav Fomichev8f51dfc2019-08-14 10:37:49 -070032#ifdef CONFIG_BPF_SYSCALL
33int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk);
Martin KaFai Lau1ed4d922020-02-25 15:04:21 -080034struct bpf_sk_storage_diag *
35bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs);
36void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag);
37int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
38 struct sock *sk, struct sk_buff *skb,
39 int stg_array_type,
40 unsigned int *res_diag_size);
Stanislav Fomichev8f51dfc2019-08-14 10:37:49 -070041#else
42static inline int bpf_sk_storage_clone(const struct sock *sk,
43 struct sock *newsk)
44{
45 return 0;
46}
Martin KaFai Lau1ed4d922020-02-25 15:04:21 -080047static inline struct bpf_sk_storage_diag *
48bpf_sk_storage_diag_alloc(const struct nlattr *nla)
49{
50 return NULL;
51}
52static inline void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag)
53{
54}
55static inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag,
56 struct sock *sk, struct sk_buff *skb,
57 int stg_array_type,
58 unsigned int *res_diag_size)
59{
60 return 0;
61}
Stanislav Fomichev8f51dfc2019-08-14 10:37:49 -070062#endif
63
Martin KaFai Lau6ac99e82019-04-26 16:39:39 -070064#endif /* _BPF_SK_STORAGE_H */