#ifndef _LINUX_SKMSG_H
#define _LINUX_SKMSG_H
#include <linux/bpf.h>
#include <linux/filter.h>
#include <linux/scatterlist.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/tcp.h>
#include <net/strparser.h>
#define MAX_MSG_FRAGS …
#define NR_MSG_FRAG_IDS …
enum __sk_action { … };
struct sk_msg_sg { … };
struct sk_msg { … };
struct sk_psock_progs { … };
enum sk_psock_state_bits { … };
struct sk_psock_link { … };
struct sk_psock_work_state { … };
struct sk_psock { … };
int sk_msg_alloc(struct sock *sk, struct sk_msg *msg, int len,
int elem_first_coalesce);
int sk_msg_clone(struct sock *sk, struct sk_msg *dst, struct sk_msg *src,
u32 off, u32 len);
void sk_msg_trim(struct sock *sk, struct sk_msg *msg, int len);
int sk_msg_free(struct sock *sk, struct sk_msg *msg);
int sk_msg_free_nocharge(struct sock *sk, struct sk_msg *msg);
void sk_msg_free_partial(struct sock *sk, struct sk_msg *msg, u32 bytes);
void sk_msg_free_partial_nocharge(struct sock *sk, struct sk_msg *msg,
u32 bytes);
void sk_msg_return(struct sock *sk, struct sk_msg *msg, int bytes);
void sk_msg_return_zero(struct sock *sk, struct sk_msg *msg, int bytes);
int sk_msg_zerocopy_from_iter(struct sock *sk, struct iov_iter *from,
struct sk_msg *msg, u32 bytes);
int sk_msg_memcopy_from_iter(struct sock *sk, struct iov_iter *from,
struct sk_msg *msg, u32 bytes);
int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,
int len, int flags);
bool sk_msg_is_readable(struct sock *sk);
static inline void sk_msg_check_to_free(struct sk_msg *msg, u32 i, u32 bytes)
{ … }
static inline void sk_msg_apply_bytes(struct sk_psock *psock, u32 bytes)
{ … }
static inline u32 sk_msg_iter_dist(u32 start, u32 end)
{ … }
#define sk_msg_iter_var_prev(var) …
#define sk_msg_iter_var_next(var) …
#define sk_msg_iter_prev(msg, which) …
#define sk_msg_iter_next(msg, which) …
static inline void sk_msg_init(struct sk_msg *msg)
{ … }
static inline void sk_msg_xfer(struct sk_msg *dst, struct sk_msg *src,
int which, u32 size)
{ … }
static inline void sk_msg_xfer_full(struct sk_msg *dst, struct sk_msg *src)
{ … }
static inline bool sk_msg_full(const struct sk_msg *msg)
{ … }
static inline u32 sk_msg_elem_used(const struct sk_msg *msg)
{ … }
static inline struct scatterlist *sk_msg_elem(struct sk_msg *msg, int which)
{ … }
static inline struct scatterlist sk_msg_elem_cpy(struct sk_msg *msg, int which)
{ … }
static inline struct page *sk_msg_page(struct sk_msg *msg, int which)
{ … }
static inline bool sk_msg_to_ingress(const struct sk_msg *msg)
{ … }
static inline void sk_msg_compute_data_pointers(struct sk_msg *msg)
{ … }
static inline void sk_msg_page_add(struct sk_msg *msg, struct page *page,
u32 len, u32 offset)
{ … }
static inline void sk_msg_sg_copy(struct sk_msg *msg, u32 i, bool copy_state)
{ … }
static inline void sk_msg_sg_copy_set(struct sk_msg *msg, u32 start)
{ … }
static inline void sk_msg_sg_copy_clear(struct sk_msg *msg, u32 start)
{ … }
static inline struct sk_psock *sk_psock(const struct sock *sk)
{ … }
static inline void sk_psock_set_state(struct sk_psock *psock,
enum sk_psock_state_bits bit)
{ … }
static inline void sk_psock_clear_state(struct sk_psock *psock,
enum sk_psock_state_bits bit)
{ … }
static inline bool sk_psock_test_state(const struct sk_psock *psock,
enum sk_psock_state_bits bit)
{ … }
static inline void sock_drop(struct sock *sk, struct sk_buff *skb)
{ … }
static inline void sk_psock_queue_msg(struct sk_psock *psock,
struct sk_msg *msg)
{ … }
static inline struct sk_msg *sk_psock_dequeue_msg(struct sk_psock *psock)
{ … }
static inline struct sk_msg *sk_psock_peek_msg(struct sk_psock *psock)
{ … }
static inline struct sk_msg *sk_psock_next_msg(struct sk_psock *psock,
struct sk_msg *msg)
{ … }
static inline bool sk_psock_queue_empty(const struct sk_psock *psock)
{ … }
static inline void kfree_sk_msg(struct sk_msg *msg)
{ … }
static inline void sk_psock_report_error(struct sk_psock *psock, int err)
{ … }
struct sk_psock *sk_psock_init(struct sock *sk, int node);
void sk_psock_stop(struct sk_psock *psock);
#if IS_ENABLED(CONFIG_BPF_STREAM_PARSER)
int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock);
void sk_psock_start_strp(struct sock *sk, struct sk_psock *psock);
void sk_psock_stop_strp(struct sock *sk, struct sk_psock *psock);
#else
static inline int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)
{
return -EOPNOTSUPP;
}
static inline void sk_psock_start_strp(struct sock *sk, struct sk_psock *psock)
{
}
static inline void sk_psock_stop_strp(struct sock *sk, struct sk_psock *psock)
{
}
#endif
void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock);
void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock);
int sk_psock_msg_verdict(struct sock *sk, struct sk_psock *psock,
struct sk_msg *msg);
#define sk_psock_init_link() …
static inline void sk_psock_free_link(struct sk_psock_link *link)
{ … }
struct sk_psock_link *sk_psock_link_pop(struct sk_psock *psock);
static inline void sk_psock_cork_free(struct sk_psock *psock)
{ … }
static inline void sk_psock_restore_proto(struct sock *sk,
struct sk_psock *psock)
{ … }
static inline struct sk_psock *sk_psock_get(struct sock *sk)
{ … }
void sk_psock_drop(struct sock *sk, struct sk_psock *psock);
static inline void sk_psock_put(struct sock *sk, struct sk_psock *psock)
{ … }
static inline void sk_psock_data_ready(struct sock *sk, struct sk_psock *psock)
{ … }
static inline void psock_set_prog(struct bpf_prog **pprog,
struct bpf_prog *prog)
{ … }
static inline int psock_replace_prog(struct bpf_prog **pprog,
struct bpf_prog *prog,
struct bpf_prog *old)
{ … }
static inline void psock_progs_drop(struct sk_psock_progs *progs)
{ … }
int sk_psock_tls_strp_read(struct sk_psock *psock, struct sk_buff *skb);
static inline bool sk_psock_strp_enabled(struct sk_psock *psock)
{ … }
#if IS_ENABLED(CONFIG_NET_SOCK_MSG)
#define BPF_F_STRPARSER …
#define BPF_F_PTR_MASK …
static inline bool skb_bpf_strparser(const struct sk_buff *skb)
{ … }
static inline void skb_bpf_set_strparser(struct sk_buff *skb)
{ … }
static inline bool skb_bpf_ingress(const struct sk_buff *skb)
{ … }
static inline void skb_bpf_set_ingress(struct sk_buff *skb)
{ … }
static inline void skb_bpf_set_redir(struct sk_buff *skb, struct sock *sk_redir,
bool ingress)
{ … }
static inline struct sock *skb_bpf_redirect_fetch(const struct sk_buff *skb)
{ … }
static inline void skb_bpf_redirect_clear(struct sk_buff *skb)
{ … }
#endif
#endif