linux/net/kcm/kcmsock.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Kernel Connection Multiplexor
 *
 * Copyright (c) 2016 Tom Herbert <[email protected]>
 */

#include <linux/bpf.h>
#include <linux/errno.h>
#include <linux/errqueue.h>
#include <linux/file.h>
#include <linux/filter.h>
#include <linux/in.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/net.h>
#include <linux/netdevice.h>
#include <linux/poll.h>
#include <linux/rculist.h>
#include <linux/skbuff.h>
#include <linux/socket.h>
#include <linux/uaccess.h>
#include <linux/workqueue.h>
#include <linux/syscalls.h>
#include <linux/sched/signal.h>

#include <net/kcm.h>
#include <net/netns/generic.h>
#include <net/sock.h>
#include <uapi/linux/kcm.h>
#include <trace/events/sock.h>

unsigned int kcm_net_id;

static struct kmem_cache *kcm_psockp __read_mostly;
static struct kmem_cache *kcm_muxp __read_mostly;
static struct workqueue_struct *kcm_wq;

static inline struct kcm_sock *kcm_sk(const struct sock *sk)
{}

static inline struct kcm_tx_msg *kcm_tx_msg(struct sk_buff *skb)
{}

static void report_csk_error(struct sock *csk, int err)
{}

static void kcm_abort_tx_psock(struct kcm_psock *psock, int err,
			       bool wakeup_kcm)
{}

/* RX mux lock held. */
static void kcm_update_rx_mux_stats(struct kcm_mux *mux,
				    struct kcm_psock *psock)
{}

static void kcm_update_tx_mux_stats(struct kcm_mux *mux,
				    struct kcm_psock *psock)
{}

static int kcm_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);

/* KCM is ready to receive messages on its queue-- either the KCM is new or
 * has become unblocked after being blocked on full socket buffer. Queue any
 * pending ready messages on a psock. RX mux lock held.
 */
static void kcm_rcv_ready(struct kcm_sock *kcm)
{}

static void kcm_rfree(struct sk_buff *skb)
{}

static int kcm_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
{}

/* Requeue received messages for a kcm socket to other kcm sockets. This is
 * called with a kcm socket is receive disabled.
 * RX mux lock held.
 */
static void requeue_rx_msgs(struct kcm_mux *mux, struct sk_buff_head *head)
{}

/* Lower sock lock held */
static struct kcm_sock *reserve_rx_kcm(struct kcm_psock *psock,
				       struct sk_buff *head)
{}

static void kcm_done(struct kcm_sock *kcm);

static void kcm_done_work(struct work_struct *w)
{}

/* Lower sock held */
static void unreserve_rx_kcm(struct kcm_psock *psock,
			     bool rcv_ready)
{}

/* Lower sock lock held */
static void psock_data_ready(struct sock *sk)
{}

/* Called with lower sock held */
static void kcm_rcv_strparser(struct strparser *strp, struct sk_buff *skb)
{}

static int kcm_parse_func_strparser(struct strparser *strp, struct sk_buff *skb)
{}

static int kcm_read_sock_done(struct strparser *strp, int err)
{}

static void psock_state_change(struct sock *sk)
{}

static void psock_write_space(struct sock *sk)
{}

static void unreserve_psock(struct kcm_sock *kcm);

/* kcm sock is locked. */
static struct kcm_psock *reserve_psock(struct kcm_sock *kcm)
{}

/* mux lock held */
static void psock_now_avail(struct kcm_psock *psock)
{}

/* kcm sock is locked. */
static void unreserve_psock(struct kcm_sock *kcm)
{}

static void kcm_report_tx_retry(struct kcm_sock *kcm)
{}

/* Write any messages ready on the kcm socket.  Called with kcm sock lock
 * held.  Return bytes actually sent or error.
 */
static int kcm_write_msgs(struct kcm_sock *kcm)
{}

static void kcm_tx_work(struct work_struct *w)
{}

static void kcm_push(struct kcm_sock *kcm)
{}

static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
{}

static void kcm_splice_eof(struct socket *sock)
{}

static int kcm_recvmsg(struct socket *sock, struct msghdr *msg,
		       size_t len, int flags)
{}

static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos,
			       struct pipe_inode_info *pipe, size_t len,
			       unsigned int flags)
{}

/* kcm sock lock held */
static void kcm_recv_disable(struct kcm_sock *kcm)
{}

/* kcm sock lock held */
static void kcm_recv_enable(struct kcm_sock *kcm)
{}

static int kcm_setsockopt(struct socket *sock, int level, int optname,
			  sockptr_t optval, unsigned int optlen)
{}

static int kcm_getsockopt(struct socket *sock, int level, int optname,
			  char __user *optval, int __user *optlen)
{}

static void init_kcm_sock(struct kcm_sock *kcm, struct kcm_mux *mux)
{}

static int kcm_attach(struct socket *sock, struct socket *csock,
		      struct bpf_prog *prog)
{}

static int kcm_attach_ioctl(struct socket *sock, struct kcm_attach *info)
{}

static void kcm_unattach(struct kcm_psock *psock)
{}

static int kcm_unattach_ioctl(struct socket *sock, struct kcm_unattach *info)
{}

static struct proto kcm_proto =;

/* Clone a kcm socket. */
static struct file *kcm_clone(struct socket *osock)
{}

static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{}

static void free_mux(struct rcu_head *rcu)
{}

static void release_mux(struct kcm_mux *mux)
{}

static void kcm_done(struct kcm_sock *kcm)
{}

/* Called by kcm_release to close a KCM socket.
 * If this is the last KCM socket on the MUX, destroy the MUX.
 */
static int kcm_release(struct socket *sock)
{}

static const struct proto_ops kcm_dgram_ops =;

static const struct proto_ops kcm_seqpacket_ops =;

/* Create proto operation for kcm sockets */
static int kcm_create(struct net *net, struct socket *sock,
		      int protocol, int kern)
{}

static const struct net_proto_family kcm_family_ops =;

static __net_init int kcm_init_net(struct net *net)
{}

static __net_exit void kcm_exit_net(struct net *net)
{}

static struct pernet_operations kcm_net_ops =;

static int __init kcm_init(void)
{}

static void __exit kcm_exit(void)
{}

module_init();
module_exit(kcm_exit);

MODULE_LICENSE();
MODULE_DESCRIPTION();
MODULE_ALIAS_NETPROTO();