Martin KaFai Lau | 6ac99e8 | 2019-04-26 16:39:39 -0700 | [diff] [blame] | 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 | |
KP Singh | f836a56 | 2020-08-25 20:29:15 +0200 | [diff] [blame] | 6 | #include <linux/rculist.h> |
| 7 | #include <linux/list.h> |
| 8 | #include <linux/hash.h> |
KP Singh | 4cc9ce4e | 2020-08-25 20:29:14 +0200 | [diff] [blame] | 9 | #include <linux/types.h> |
| 10 | #include <linux/spinlock.h> |
KP Singh | f836a56 | 2020-08-25 20:29:15 +0200 | [diff] [blame] | 11 | #include <linux/bpf.h> |
| 12 | #include <net/sock.h> |
| 13 | #include <uapi/linux/sock_diag.h> |
| 14 | #include <uapi/linux/btf.h> |
KP Singh | 450af8d | 2020-08-25 20:29:16 +0200 | [diff] [blame] | 15 | #include <linux/bpf_local_storage.h> |
KP Singh | 4cc9ce4e | 2020-08-25 20:29:14 +0200 | [diff] [blame] | 16 | |
Martin KaFai Lau | 6ac99e8 | 2019-04-26 16:39:39 -0700 | [diff] [blame] | 17 | struct sock; |
| 18 | |
| 19 | void bpf_sk_storage_free(struct sock *sk); |
| 20 | |
| 21 | extern const struct bpf_func_proto bpf_sk_storage_get_proto; |
| 22 | extern const struct bpf_func_proto bpf_sk_storage_delete_proto; |
Martin KaFai Lau | 8e4597c | 2020-11-12 13:13:13 -0800 | [diff] [blame] | 23 | extern const struct bpf_func_proto bpf_sk_storage_get_tracing_proto; |
| 24 | extern const struct bpf_func_proto bpf_sk_storage_delete_tracing_proto; |
Martin KaFai Lau | 6ac99e8 | 2019-04-26 16:39:39 -0700 | [diff] [blame] | 25 | |
KP Singh | f836a56 | 2020-08-25 20:29:15 +0200 | [diff] [blame] | 26 | struct bpf_local_storage_elem; |
Martin KaFai Lau | 1ed4d92 | 2020-02-25 15:04:21 -0800 | [diff] [blame] | 27 | struct bpf_sk_storage_diag; |
| 28 | struct sk_buff; |
| 29 | struct nlattr; |
Martin KaFai Lau | 1ed4d92 | 2020-02-25 15:04:21 -0800 | [diff] [blame] | 30 | |
Stanislav Fomichev | 8f51dfc | 2019-08-14 10:37:49 -0700 | [diff] [blame] | 31 | #ifdef CONFIG_BPF_SYSCALL |
| 32 | int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk); |
Martin KaFai Lau | 1ed4d92 | 2020-02-25 15:04:21 -0800 | [diff] [blame] | 33 | struct bpf_sk_storage_diag * |
| 34 | bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs); |
| 35 | void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag); |
| 36 | int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag, |
| 37 | struct sock *sk, struct sk_buff *skb, |
| 38 | int stg_array_type, |
| 39 | unsigned int *res_diag_size); |
Stanislav Fomichev | 8f51dfc | 2019-08-14 10:37:49 -0700 | [diff] [blame] | 40 | #else |
| 41 | static inline int bpf_sk_storage_clone(const struct sock *sk, |
| 42 | struct sock *newsk) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
Martin KaFai Lau | 1ed4d92 | 2020-02-25 15:04:21 -0800 | [diff] [blame] | 46 | static inline struct bpf_sk_storage_diag * |
| 47 | bpf_sk_storage_diag_alloc(const struct nlattr *nla) |
| 48 | { |
| 49 | return NULL; |
| 50 | } |
| 51 | static inline void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag) |
| 52 | { |
| 53 | } |
| 54 | static inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag, |
| 55 | struct sock *sk, struct sk_buff *skb, |
| 56 | int stg_array_type, |
| 57 | unsigned int *res_diag_size) |
| 58 | { |
| 59 | return 0; |
| 60 | } |
Stanislav Fomichev | 8f51dfc | 2019-08-14 10:37:49 -0700 | [diff] [blame] | 61 | #endif |
| 62 | |
Martin KaFai Lau | 6ac99e8 | 2019-04-26 16:39:39 -0700 | [diff] [blame] | 63 | #endif /* _BPF_SK_STORAGE_H */ |