FreeBSD kernel kern code
sys_socket.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/aio.h>
#include <sys/domain.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/sigio.h>
#include <sys/signal.h>
#include <sys/signalvar.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/filio.h>
#include <sys/sockio.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/sysproto.h>
#include <sys/taskqueue.h>
#include <sys/uio.h>
#include <sys/ucred.h>
#include <sys/un.h>
#include <sys/unpcb.h>
#include <sys/user.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
Include dependency graph for sys_socket.c:

Go to the source code of this file.

Macros

#define aio_done   backend3
 

Functions

 __FBSDID ("$FreeBSD$")
 
static SYSCTL_NODE (_kern_ipc, OID_AUTO, aio, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "socket AIO stats")
 
 SYSCTL_INT (_kern_ipc_aio, OID_AUTO, empty_results, CTLFLAG_RD, &empty_results, 0, "socket operation returned EAGAIN")
 
 SYSCTL_INT (_kern_ipc_aio, OID_AUTO, empty_retries, CTLFLAG_RD, &empty_retries, 0, "socket operation retries")
 
static void soo_aio_cancel (struct kaiocb *job)
 
static int soo_read (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int soo_write (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int soo_ioctl (struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td)
 
static int soo_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td)
 
static int soo_stat (struct file *fp, struct stat *ub, struct ucred *active_cred)
 
static int soo_close (struct file *fp, struct thread *td)
 
static int soo_fill_kinfo (struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
 
static STAILQ_HEAD (task)
 
static void soaio_kproc_create (void *context, int pending)
 
void soaio_enqueue (struct task *task)
 
static void soaio_init (void)
 
 SYSINIT (soaio, SI_SUB_VFS, SI_ORDER_ANY, soaio_init, NULL)
 
static __inline int soaio_ready (struct socket *so, struct sockbuf *sb)
 
static void soaio_process_job (struct socket *so, struct sockbuf *sb, struct kaiocb *job)
 
static void soaio_process_sb (struct socket *so, struct sockbuf *sb)
 
void soaio_rcv (void *context, int pending)
 
void soaio_snd (void *context, int pending)
 
void sowakeup_aio (struct socket *so, struct sockbuf *sb)
 
static int soo_aio_queue (struct file *fp, struct kaiocb *job)
 

Variables

static int empty_results
 
static int empty_retries
 
static fo_rdwr_t soo_read
 
static fo_rdwr_t soo_write
 
static fo_ioctl_t soo_ioctl
 
static fo_poll_t soo_poll
 
fo_kqfilter_t soo_kqfilter
 
static fo_stat_t soo_stat
 
static fo_close_t soo_close
 
static fo_fill_kinfo_t soo_fill_kinfo
 
static fo_aio_queue_t soo_aio_queue
 
struct fileops socketops
 

Macro Definition Documentation

◆ aio_done

#define aio_done   backend3

Definition at line 437 of file sys_socket.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ soaio_enqueue()

void soaio_enqueue ( struct task *  task)

Definition at line 562 of file sys_socket.c.

References taskqueue_enqueue(), and wakeup_one().

Referenced by sowakeup_aio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soaio_init()

static void soaio_init ( void  )
static

Definition at line 578 of file sys_socket.c.

References new_unrhdr(), and soaio_kproc_create().

Here is the call graph for this function:

◆ soaio_kproc_create()

static void soaio_kproc_create ( void *  context,
int  pending 
)
static

Definition at line 520 of file sys_socket.c.

References alloc_unr(), free_unr(), and kproc_create().

Referenced by soaio_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soaio_process_job()

static void soaio_process_job ( struct socket *  so,
struct sockbuf *  sb,
struct kaiocb *  job 
)
static

Definition at line 596 of file sys_socket.c.

References aio_cancel(), aio_complete(), aio_set_cancel_function(), aio_switch_vmspace(), empty_results, empty_retries, flags, kern_psignal(), soaio_ready(), soo_aio_cancel(), soreceive(), and sosend().

Referenced by soaio_process_sb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soaio_process_sb()

static void soaio_process_sb ( struct socket *  so,
struct sockbuf *  sb 
)
static

Definition at line 705 of file sys_socket.c.

References aio_clear_cancel_function(), soaio_process_job(), and soaio_ready().

Referenced by soaio_rcv(), and soaio_snd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soaio_rcv()

void soaio_rcv ( void *  context,
int  pending 
)

Definition at line 735 of file sys_socket.c.

References soaio_process_sb().

Referenced by soalloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soaio_ready()

static __inline int soaio_ready ( struct socket *  so,
struct sockbuf *  sb 
)
static

Definition at line 590 of file sys_socket.c.

Referenced by soaio_process_job(), soaio_process_sb(), and soo_aio_queue().

Here is the caller graph for this function:

◆ soaio_snd()

void soaio_snd ( void *  context,
int  pending 
)

Definition at line 744 of file sys_socket.c.

References soaio_process_sb().

Referenced by soalloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soo_aio_cancel()

static void soo_aio_cancel ( struct kaiocb *  job)
static

Definition at line 766 of file sys_socket.c.

References aio_cancel(), aio_cancel_cleared(), and aio_complete().

Referenced by soaio_process_job(), and soo_aio_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ soo_aio_queue()

static int soo_aio_queue ( struct file *  fp,
struct kaiocb *  job 
)
static

Definition at line 797 of file sys_socket.c.

References aio_set_cancel_function(), panic(), soaio_ready(), soo_aio_cancel(), and sowakeup_aio().

Here is the call graph for this function:

◆ soo_close()

static int soo_close ( struct file *  fp,
struct thread *  td 
)
static

Definition at line 351 of file sys_socket.c.

References badfileops, and soclose().

Here is the call graph for this function:

◆ soo_fill_kinfo()

static int soo_fill_kinfo ( struct file *  fp,
struct kinfo_file *  kif,
struct filedesc *  fdp 
)
static

Definition at line 366 of file sys_socket.c.

References free().

Here is the call graph for this function:

◆ soo_ioctl()

static int soo_ioctl ( struct file *  fp,
u_long  cmd,
void *  data,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 158 of file sys_socket.c.

References data, fgetown(), and fsetown().

Here is the call graph for this function:

◆ soo_poll()

static int soo_poll ( struct file *  fp,
int  events,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 289 of file sys_socket.c.

References sopoll().

Here is the call graph for this function:

◆ soo_read()

static int soo_read ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 121 of file sys_socket.c.

References soreceive().

Here is the call graph for this function:

◆ soo_stat()

static int soo_stat ( struct file *  fp,
struct stat *  ub,
struct ucred *  active_cred 
)
static

Definition at line 304 of file sys_socket.c.

◆ soo_write()

static int soo_write ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 137 of file sys_socket.c.

References sosend(), and tdsignal().

Here is the call graph for this function:

◆ sowakeup_aio()

void sowakeup_aio ( struct socket *  so,
struct sockbuf *  sb 
)

Definition at line 753 of file sys_socket.c.

References soaio_enqueue().

Referenced by soo_aio_queue(), and sowakeup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ STAILQ_HEAD()

static STAILQ_HEAD ( task  )
static

Definition at line 439 of file sys_socket.c.

◆ SYSCTL_INT() [1/2]

SYSCTL_INT ( _kern_ipc_aio  ,
OID_AUTO  ,
empty_results  ,
CTLFLAG_RD  ,
empty_results,
,
"socket operation returned EAGAIN"   
)

◆ SYSCTL_INT() [2/2]

SYSCTL_INT ( _kern_ipc_aio  ,
OID_AUTO  ,
empty_retries  ,
CTLFLAG_RD  ,
empty_retries,
,
"socket operation retries"   
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _kern_ipc  ,
OID_AUTO  ,
aio  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
"socket AIO stats"   
)
static

◆ SYSINIT()

SYSINIT ( soaio  ,
SI_SUB_VFS  ,
SI_ORDER_ANY  ,
soaio_init  ,
NULL   
)

Variable Documentation

◆ empty_results

int empty_results
static

Definition at line 83 of file sys_socket.c.

Referenced by soaio_process_job().

◆ empty_retries

int empty_retries
static

Definition at line 87 of file sys_socket.c.

Referenced by soaio_process_job().

◆ socketops

struct fileops socketops
Initial value:
= {
.fo_read = soo_read,
.fo_write = soo_write,
.fo_truncate = invfo_truncate,
.fo_ioctl = soo_ioctl,
.fo_poll = soo_poll,
.fo_kqfilter = soo_kqfilter,
.fo_stat = soo_stat,
.fo_close = soo_close,
.fo_chmod = invfo_chmod,
.fo_chown = invfo_chown,
.fo_sendfile = invfo_sendfile,
.fo_fill_kinfo = soo_fill_kinfo,
.fo_aio_queue = soo_aio_queue,
.fo_flags = DFLAG_PASSABLE
}
int invfo_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
int invfo_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td)
int invfo_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, struct uio *trl_uio, off_t offset, size_t nbytes, off_t *sent, int flags, struct thread *td)
int invfo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
static fo_close_t soo_close
Definition: sys_socket.c:97
static fo_poll_t soo_poll
Definition: sys_socket.c:94
fo_kqfilter_t soo_kqfilter
Definition: uipc_socket.c:180
static fo_stat_t soo_stat
Definition: sys_socket.c:96
static fo_aio_queue_t soo_aio_queue
Definition: sys_socket.c:99
static fo_rdwr_t soo_read
Definition: sys_socket.c:91
static fo_rdwr_t soo_write
Definition: sys_socket.c:92
static fo_fill_kinfo_t soo_fill_kinfo
Definition: sys_socket.c:98
static fo_ioctl_t soo_ioctl
Definition: sys_socket.c:93

Definition at line 103 of file sys_socket.c.

Referenced by kern_accept4(), kern_socket(), and kern_socketpair().

◆ soo_aio_queue

fo_aio_queue_t soo_aio_queue
static

Definition at line 99 of file sys_socket.c.

◆ soo_close

fo_close_t soo_close
static

Definition at line 97 of file sys_socket.c.

◆ soo_fill_kinfo

fo_fill_kinfo_t soo_fill_kinfo
static

Definition at line 98 of file sys_socket.c.

◆ soo_ioctl

fo_ioctl_t soo_ioctl
static

Definition at line 93 of file sys_socket.c.

◆ soo_kqfilter

fo_kqfilter_t soo_kqfilter
extern

Definition at line 180 of file uipc_socket.c.

◆ soo_poll

fo_poll_t soo_poll
static

Definition at line 94 of file sys_socket.c.

◆ soo_read

fo_rdwr_t soo_read
static

Definition at line 91 of file sys_socket.c.

◆ soo_stat

fo_stat_t soo_stat
static

Definition at line 96 of file sys_socket.c.

◆ soo_write

fo_rdwr_t soo_write
static

Definition at line 92 of file sys_socket.c.