18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2019 Facebook */ 38c2ecf20Sopenharmony_ci#ifndef _BPF_SK_STORAGE_H 48c2ecf20Sopenharmony_ci#define _BPF_SK_STORAGE_H 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/rculist.h> 78c2ecf20Sopenharmony_ci#include <linux/list.h> 88c2ecf20Sopenharmony_ci#include <linux/hash.h> 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 118c2ecf20Sopenharmony_ci#include <linux/bpf.h> 128c2ecf20Sopenharmony_ci#include <net/sock.h> 138c2ecf20Sopenharmony_ci#include <uapi/linux/sock_diag.h> 148c2ecf20Sopenharmony_ci#include <uapi/linux/btf.h> 158c2ecf20Sopenharmony_ci#include <linux/bpf_local_storage.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct sock; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_civoid bpf_sk_storage_free(struct sock *sk); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciextern const struct bpf_func_proto bpf_sk_storage_get_proto; 228c2ecf20Sopenharmony_ciextern const struct bpf_func_proto bpf_sk_storage_delete_proto; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct bpf_local_storage_elem; 258c2ecf20Sopenharmony_cistruct bpf_sk_storage_diag; 268c2ecf20Sopenharmony_cistruct sk_buff; 278c2ecf20Sopenharmony_cistruct nlattr; 288c2ecf20Sopenharmony_cistruct sock; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#ifdef CONFIG_BPF_SYSCALL 318c2ecf20Sopenharmony_ciint bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk); 328c2ecf20Sopenharmony_cistruct bpf_sk_storage_diag * 338c2ecf20Sopenharmony_cibpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs); 348c2ecf20Sopenharmony_civoid bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag); 358c2ecf20Sopenharmony_ciint bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag, 368c2ecf20Sopenharmony_ci struct sock *sk, struct sk_buff *skb, 378c2ecf20Sopenharmony_ci int stg_array_type, 388c2ecf20Sopenharmony_ci unsigned int *res_diag_size); 398c2ecf20Sopenharmony_ci#else 408c2ecf20Sopenharmony_cistatic inline int bpf_sk_storage_clone(const struct sock *sk, 418c2ecf20Sopenharmony_ci struct sock *newsk) 428c2ecf20Sopenharmony_ci{ 438c2ecf20Sopenharmony_ci return 0; 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_cistatic inline struct bpf_sk_storage_diag * 468c2ecf20Sopenharmony_cibpf_sk_storage_diag_alloc(const struct nlattr *nla) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci return NULL; 498c2ecf20Sopenharmony_ci} 508c2ecf20Sopenharmony_cistatic inline void bpf_sk_storage_diag_free(struct bpf_sk_storage_diag *diag) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_cistatic inline int bpf_sk_storage_diag_put(struct bpf_sk_storage_diag *diag, 548c2ecf20Sopenharmony_ci struct sock *sk, struct sk_buff *skb, 558c2ecf20Sopenharmony_ci int stg_array_type, 568c2ecf20Sopenharmony_ci unsigned int *res_diag_size) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci return 0; 598c2ecf20Sopenharmony_ci} 608c2ecf20Sopenharmony_ci#endif 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#endif /* _BPF_SK_STORAGE_H */ 63