FreeBSD kernel kern code
uipc_socket.c File Reference
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_zero.h"
#include "opt_compat.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/fcntl.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mac.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/domain.h>
#include <sys/file.h>
#include <sys/kernel.h>
#include <sys/event.h>
#include <sys/eventhandler.h>
#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/resourcevar.h>
#include <net/route.h>
#include <sys/signalvar.h>
#include <sys/stat.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/jail.h>
#include <sys/syslog.h>
#include <netinet/in.h>
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include <vm/uma.h>
Include dependency graph for uipc_socket.c:

Go to the source code of this file.

Macros

#define VNET_SO_ASSERT(so)
 
#define SBLOCKWAIT(f)   (((f) & MSG_DONTWAIT) ? 0 : SBL_WAIT)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static int soreceive_rcvoob (struct socket *so, struct uio *uio, int flags)
 
static void filt_sordetach (struct knote *kn)
 
static int filt_soread (struct knote *kn, long hint)
 
static void filt_sowdetach (struct knote *kn)
 
static int filt_sowrite (struct knote *kn, long hint)
 
static int filt_solisten (struct knote *kn, long hint)
 
 MALLOC_DEFINE (M_SONAME,"soname","socket name")
 
 MALLOC_DEFINE (M_PCB,"pcb","protocol control block")
 
static int sysctl_somaxconn (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_ipc, KIPC_SOMAXCONN, somaxconn, CTLTYPE_UINT|CTLFLAG_RW, 0, sizeof(int), sysctl_somaxconn,"I","Maximum listen socket pending connection accept queue size")
 
 SYSCTL_INT (_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD,&numopensockets, 0,"Number of open sockets")
 
 MTX_SYSINIT (accept_mtx,&accept_mtx,"accept", MTX_DEF)
 
 MTX_SYSINIT (so_global_mtx,&so_global_mtx,"so_glabel", MTX_DEF)
 
 SYSCTL_NODE (_kern, KERN_IPC, ipc, CTLFLAG_RW, 0,"IPC")
 
static void socket_zone_change (void *tag)
 
static void socket_init (void *tag)
 
 SYSINIT (socket, SI_SUB_PROTO_DOMAININIT, SI_ORDER_ANY, socket_init, NULL)
 
static void init_maxsockets (void *ignored)
 
 SYSINIT (param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL)
 
static int sysctl_maxsockets (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_ipc, OID_AUTO, maxsockets, CTLTYPE_INT|CTLFLAG_RW,&maxsockets, 0, sysctl_maxsockets,"IU","Maximum number of sockets avaliable")
 
static struct socket * soalloc (struct vnet *vnet)
 
static void sodealloc (struct socket *so)
 
int socreate (int dom, struct socket **aso, int type, int proto, struct ucred *cred, struct thread *td)
 
struct socket * sonewconn (struct socket *head, int connstatus)
 
int sobind (struct socket *so, struct sockaddr *nam, struct thread *td)
 
int solisten (struct socket *so, int backlog, struct thread *td)
 
int solisten_proto_check (struct socket *so)
 
void solisten_proto (struct socket *so, int backlog)
 
void sofree (struct socket *so)
 
int soclose (struct socket *so)
 
void soabort (struct socket *so)
 
int soaccept (struct socket *so, struct sockaddr **nam)
 
int soconnect (struct socket *so, struct sockaddr *nam, struct thread *td)
 
int soconnect2 (struct socket *so1, struct socket *so2)
 
int sodisconnect (struct socket *so)
 
int sosend_dgram (struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
 
int sosend_generic (struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
 
int sosend (struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
 
static __inline void sockbuf_pushsync (struct sockbuf *sb, struct mbuf *nextrecord)
 
int soreceive_generic (struct socket *so, struct sockaddr **psa, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
 
int soreceive_stream (struct socket *so, struct sockaddr **psa, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
 
int soreceive_dgram (struct socket *so, struct sockaddr **psa, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
 
int soreceive (struct socket *so, struct sockaddr **psa, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
 
int soshutdown (struct socket *so, int how)
 
void sorflush (struct socket *so)
 
int sooptcopyin (struct sockopt *sopt, void *buf, size_t len, size_t minlen)
 
int so_setsockopt (struct socket *so, int level, int optname, void *optval, size_t optlen)
 
int sosetopt (struct socket *so, struct sockopt *sopt)
 
int sooptcopyout (struct sockopt *sopt, const void *buf, size_t len)
 
int sogetopt (struct socket *so, struct sockopt *sopt)
 
int soopt_getm (struct sockopt *sopt, struct mbuf **mp)
 
int soopt_mcopyin (struct sockopt *sopt, struct mbuf *m)
 
int soopt_mcopyout (struct sockopt *sopt, struct mbuf *m)
 
void sohasoutofband (struct socket *so)
 
int sopoll (struct socket *so, int events, struct ucred *active_cred, struct thread *td)
 
int sopoll_generic (struct socket *so, int events, struct ucred *active_cred, struct thread *td)
 
int soo_kqfilter (struct file *fp, struct knote *kn)
 
int pru_accept_notsupp (struct socket *so, struct sockaddr **nam)
 
int pru_attach_notsupp (struct socket *so, int proto, struct thread *td)
 
int pru_bind_notsupp (struct socket *so, struct sockaddr *nam, struct thread *td)
 
int pru_connect_notsupp (struct socket *so, struct sockaddr *nam, struct thread *td)
 
int pru_connect2_notsupp (struct socket *so1, struct socket *so2)
 
int pru_control_notsupp (struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, struct thread *td)
 
int pru_disconnect_notsupp (struct socket *so)
 
int pru_listen_notsupp (struct socket *so, int backlog, struct thread *td)
 
int pru_peeraddr_notsupp (struct socket *so, struct sockaddr **nam)
 
int pru_rcvd_notsupp (struct socket *so, int flags)
 
int pru_rcvoob_notsupp (struct socket *so, struct mbuf *m, int flags)
 
int pru_send_notsupp (struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td)
 
int pru_sense_null (struct socket *so, struct stat *sb)
 
int pru_shutdown_notsupp (struct socket *so)
 
int pru_sockaddr_notsupp (struct socket *so, struct sockaddr **nam)
 
int pru_sosend_notsupp (struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
 
int pru_soreceive_notsupp (struct socket *so, struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
 
int pru_sopoll_notsupp (struct socket *so, int events, struct ucred *cred, struct thread *td)
 
int socheckuid (struct socket *so, uid_t uid)
 
void soisconnecting (struct socket *so)
 
void soisconnected (struct socket *so)
 
void soisdisconnecting (struct socket *so)
 
void soisdisconnected (struct socket *so)
 
struct sockaddr * sodupsockaddr (const struct sockaddr *sa, int mflags)
 
void soupcall_set (struct socket *so, int which, int(*func)(struct socket *, void *, int), void *arg)
 
void soupcall_clear (struct socket *so, int which)
 
void sotoxsocket (struct socket *so, struct xsocket *xso)
 
void so_listeners_apply_all (struct socket *so, void(*func)(struct socket *, void *), void *arg)
 
struct sockbuf * so_sockbuf_rcv (struct socket *so)
 
struct sockbuf * so_sockbuf_snd (struct socket *so)
 
int so_state_get (const struct socket *so)
 
void so_state_set (struct socket *so, int val)
 
int so_options_get (const struct socket *so)
 
void so_options_set (struct socket *so, int val)
 
int so_error_get (const struct socket *so)
 
void so_error_set (struct socket *so, int val)
 
int so_linger_get (const struct socket *so)
 
void so_linger_set (struct socket *so, int val)
 
struct protosw * so_protosw_get (const struct socket *so)
 
void so_protosw_set (struct socket *so, struct protosw *val)
 
void so_sorwakeup (struct socket *so)
 
void so_sowwakeup (struct socket *so)
 
void so_sorwakeup_locked (struct socket *so)
 
void so_sowwakeup_locked (struct socket *so)
 
void so_lock (struct socket *so)
 
void so_unlock (struct socket *so)
 

Variables

static struct filterops solisten_filtops
 
static struct filterops soread_filtops
 
static struct filterops sowrite_filtops
 
so_gen_t so_gencnt
 
static int somaxconn = SOMAXCONN
 
static int numopensockets
 
struct mtx accept_mtx
 
static struct mtx so_global_mtx
 
uma_zone_t socket_zone
 
int maxsockets
 

Macro Definition Documentation

#define SBLOCKWAIT (   f)    (((f) & MSG_DONTWAIT) ? 0 : SBL_WAIT)

Definition at line 1054 of file uipc_socket.c.

Referenced by soreceive_generic(), soreceive_stream(), and sosend_generic().

#define VNET_SO_ASSERT (   so)
Value:
VNET_ASSERT(curvnet != NULL, \
("%s:%d curvnet is NULL, so=%p", __func__, __LINE__, (so)));

Definition at line 183 of file uipc_socket.c.

Referenced by soabort(), sodisconnect(), sofree(), sonewconn(), soreceive_generic(), soreceive_rcvoob(), soreceive_stream(), sorflush(), sosend_dgram(), and sosend_generic().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int filt_solisten ( struct knote kn,
long  hint 
)
static

Definition at line 3325 of file uipc_socket.c.

static void filt_sordetach ( struct knote kn)
static

Definition at line 3254 of file uipc_socket.c.

References knlist_empty(), and knlist_remove().

Here is the call graph for this function:

static int filt_soread ( struct knote kn,
long  hint 
)
static

Definition at line 3267 of file uipc_socket.c.

static void filt_sowdetach ( struct knote kn)
static

Definition at line 3288 of file uipc_socket.c.

References knlist_empty(), and knlist_remove().

Here is the call graph for this function:

static int filt_sowrite ( struct knote kn,
long  hint 
)
static

Definition at line 3301 of file uipc_socket.c.

static void init_maxsockets ( void *  ignored)
static

Definition at line 281 of file uipc_socket.c.

References maxfiles.

MALLOC_DEFINE ( M_SONAME  ,
"soname"  ,
"socket name  
)
MALLOC_DEFINE ( M_PCB  ,
"pcb"  ,
"protocol control block"   
)
MTX_SYSINIT ( accept_mtx  ,
accept_mtx,
"accept"  ,
MTX_DEF   
)
MTX_SYSINIT ( so_global_mtx  ,
so_global_mtx,
"so_glabel"  ,
MTX_DEF   
)
int pru_accept_notsupp ( struct socket *  so,
struct sockaddr **  nam 
)

Definition at line 3118 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_attach_notsupp ( struct socket *  so,
int  proto,
struct thread *  td 
)

Definition at line 3125 of file uipc_socket.c.

Referenced by socreate().

Here is the caller graph for this function:

int pru_bind_notsupp ( struct socket *  so,
struct sockaddr *  nam,
struct thread *  td 
)

Definition at line 3132 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_connect2_notsupp ( struct socket *  so1,
struct socket *  so2 
)

Definition at line 3146 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_connect_notsupp ( struct socket *  so,
struct sockaddr *  nam,
struct thread *  td 
)

Definition at line 3139 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_control_notsupp ( struct socket *  so,
u_long  cmd,
caddr_t  data,
struct ifnet *  ifp,
struct thread *  td 
)

Definition at line 3153 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_disconnect_notsupp ( struct socket *  so)

Definition at line 3161 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_listen_notsupp ( struct socket *  so,
int  backlog,
struct thread *  td 
)

Definition at line 3168 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_peeraddr_notsupp ( struct socket *  so,
struct sockaddr **  nam 
)

Definition at line 3175 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_rcvd_notsupp ( struct socket *  so,
int  flags 
)

Definition at line 3182 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_rcvoob_notsupp ( struct socket *  so,
struct mbuf *  m,
int  flags 
)

Definition at line 3189 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_send_notsupp ( struct socket *  so,
int  flags,
struct mbuf *  m,
struct sockaddr *  addr,
struct mbuf *  control,
struct thread *  td 
)

Definition at line 3196 of file uipc_socket.c.

int pru_sense_null ( struct socket *  so,
struct stat *  sb 
)

Definition at line 3208 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_shutdown_notsupp ( struct socket *  so)

Definition at line 3216 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_sockaddr_notsupp ( struct socket *  so,
struct sockaddr **  nam 
)

Definition at line 3223 of file uipc_socket.c.

Referenced by protosw_init().

Here is the caller graph for this function:

int pru_sopoll_notsupp ( struct socket *  so,
int  events,
struct ucred *  cred,
struct thread *  td 
)

Definition at line 3246 of file uipc_socket.c.

int pru_soreceive_notsupp ( struct socket *  so,
struct sockaddr **  paddr,
struct uio *  uio,
struct mbuf **  mp0,
struct mbuf **  controlp,
int *  flagsp 
)

Definition at line 3238 of file uipc_socket.c.

int pru_sosend_notsupp ( struct socket *  so,
struct sockaddr *  addr,
struct uio *  uio,
struct mbuf *  top,
struct mbuf *  control,
int  flags,
struct thread *  td 
)

Definition at line 3230 of file uipc_socket.c.

int so_error_get ( const struct socket *  so)

Definition at line 3628 of file uipc_socket.c.

void so_error_set ( struct socket *  so,
int  val 
)

Definition at line 3635 of file uipc_socket.c.

int so_linger_get ( const struct socket *  so)

Definition at line 3642 of file uipc_socket.c.

void so_linger_set ( struct socket *  so,
int  val 
)

Definition at line 3649 of file uipc_socket.c.

void so_listeners_apply_all ( struct socket *  so,
void(*)(struct socket *, void *)  func,
void *  arg 
)

Definition at line 3578 of file uipc_socket.c.

void so_lock ( struct socket *  so)

Definition at line 3698 of file uipc_socket.c.

int so_options_get ( const struct socket *  so)

Definition at line 3614 of file uipc_socket.c.

void so_options_set ( struct socket *  so,
int  val 
)

Definition at line 3621 of file uipc_socket.c.

struct protosw* so_protosw_get ( const struct socket *  so)

Definition at line 3656 of file uipc_socket.c.

void so_protosw_set ( struct socket *  so,
struct protosw *  val 
)

Definition at line 3663 of file uipc_socket.c.

int so_setsockopt ( struct socket *  so,
int  level,
int  optname,
void *  optval,
size_t  optlen 
)

Definition at line 2494 of file uipc_socket.c.

References level, and sosetopt().

Here is the call graph for this function:

struct sockbuf* so_sockbuf_rcv ( struct socket *  so)

Definition at line 3586 of file uipc_socket.c.

struct sockbuf* so_sockbuf_snd ( struct socket *  so)

Definition at line 3593 of file uipc_socket.c.

void so_sorwakeup ( struct socket *  so)

Definition at line 3670 of file uipc_socket.c.

void so_sorwakeup_locked ( struct socket *  so)

Definition at line 3684 of file uipc_socket.c.

void so_sowwakeup ( struct socket *  so)

Definition at line 3677 of file uipc_socket.c.

void so_sowwakeup_locked ( struct socket *  so)

Definition at line 3691 of file uipc_socket.c.

int so_state_get ( const struct socket *  so)

Definition at line 3600 of file uipc_socket.c.

void so_state_set ( struct socket *  so,
int  val 
)

Definition at line 3607 of file uipc_socket.c.

void so_unlock ( struct socket *  so)

Definition at line 3704 of file uipc_socket.c.

void soabort ( struct socket *  so)

Definition at line 852 of file uipc_socket.c.

References sofree(), and VNET_SO_ASSERT.

Referenced by soclose(), and sonewconn().

Here is the call graph for this function:

Here is the caller graph for this function:

int soaccept ( struct socket *  so,
struct sockaddr **  nam 
)

Definition at line 876 of file uipc_socket.c.

Referenced by kern_accept().

Here is the caller graph for this function:

static struct socket* soalloc ( struct vnet *  vnet)
static

Definition at line 329 of file uipc_socket.c.

References numopensockets, so_gencnt, and so_global_mtx.

Referenced by socreate(), and sonewconn().

Here is the caller graph for this function:

int sobind ( struct socket *  so,
struct sockaddr *  nam,
struct thread *  td 
)

Definition at line 609 of file uipc_socket.c.

Referenced by kern_bind().

Here is the caller graph for this function:

int socheckuid ( struct socket *  so,
uid_t  uid 
)

Definition at line 3334 of file uipc_socket.c.

static __inline void sockbuf_pushsync ( struct sockbuf *  sb,
struct mbuf *  nextrecord 
)
static

Definition at line 1483 of file uipc_socket.c.

Referenced by soreceive_dgram(), and soreceive_generic().

Here is the caller graph for this function:

static void socket_init ( void *  tag)
static

Definition at line 265 of file uipc_socket.c.

References socket_zone_change().

Here is the call graph for this function:

static void socket_zone_change ( void *  tag)
static

Definition at line 258 of file uipc_socket.c.

Referenced by socket_init().

Here is the caller graph for this function:

int soclose ( struct socket *  so)

Definition at line 765 of file uipc_socket.c.

References funsetown(), hz, soabort(), and sodisconnect().

Referenced by kern_socketpair(), and soo_close().

Here is the call graph for this function:

Here is the caller graph for this function:

int soconnect ( struct socket *  so,
struct sockaddr *  nam,
struct thread *  td 
)

Definition at line 892 of file uipc_socket.c.

References sodisconnect().

Referenced by kern_connect().

Here is the call graph for this function:

Here is the caller graph for this function:

int soconnect2 ( struct socket *  so1,
struct socket *  so2 
)

Definition at line 923 of file uipc_socket.c.

Referenced by kern_socketpair().

Here is the caller graph for this function:

int socreate ( int  dom,
struct socket **  aso,
int  type,
int  proto,
struct ucred *  cred,
struct thread *  td 
)

Definition at line 408 of file uipc_socket.c.

References crhold(), knlist_init_mtx(), pffindproto(), pffindtype(), prison_check_af(), pru_attach_notsupp(), soalloc(), sodealloc(), and type.

Referenced by kern_socketpair(), and sys_socket().

Here is the call graph for this function:

Here is the caller graph for this function:

static void sodealloc ( struct socket *  so)
static

Definition at line 366 of file uipc_socket.c.

References chgsbsize(), crfree(), do_setopt_accept_filter(), numopensockets, so_gencnt, so_global_mtx, and sx_destroy().

Referenced by socreate(), sofree(), and sonewconn().

Here is the call graph for this function:

Here is the caller graph for this function:

int sodisconnect ( struct socket *  so)

Definition at line 934 of file uipc_socket.c.

References VNET_SO_ASSERT.

Referenced by soclose(), and soconnect().

Here is the caller graph for this function:

struct sockaddr* sodupsockaddr ( const struct sockaddr *  sa,
int  mflags 
)

Definition at line 3476 of file uipc_socket.c.

References malloc().

Referenced by soreceive_dgram(), soreceive_generic(), and uipc_bind().

Here is the call graph for this function:

Here is the caller graph for this function:

void sofree ( struct socket *  so)

Definition at line 687 of file uipc_socket.c.

References knlist_destroy(), pr, sbdestroy(), seldrain(), sodealloc(), and VNET_SO_ASSERT.

Referenced by soabort(), and sonewconn().

Here is the call graph for this function:

Here is the caller graph for this function:

int sogetopt ( struct socket *  so,
struct sockopt *  sopt 
)

Definition at line 2744 of file uipc_socket.c.

References do_getopt_accept_filter(), hz, sooptcopyin(), sooptcopyout(), and tick.

Referenced by kern_getsockopt().

Here is the call graph for this function:

Here is the caller graph for this function:

void sohasoutofband ( struct socket *  so)

Definition at line 3018 of file uipc_socket.c.

References pgsigio(), and selwakeuppri().

Here is the call graph for this function:

void soisconnected ( struct socket *  so)

Definition at line 3387 of file uipc_socket.c.

References soupcall_clear(), soupcall_set(), wakeup(), and wakeup_one().

Referenced by sowakeup(), and unp_connect2().

Here is the call graph for this function:

Here is the caller graph for this function:

void soisconnecting ( struct socket *  so)

Definition at line 3377 of file uipc_socket.c.

Referenced by unp_connect2().

Here is the caller graph for this function:

void soisdisconnected ( struct socket *  so)

Definition at line 3453 of file uipc_socket.c.

References sbdrop_locked(), and wakeup().

Referenced by unp_disconnect().

Here is the call graph for this function:

Here is the caller graph for this function:

void soisdisconnecting ( struct socket *  so)

Definition at line 3434 of file uipc_socket.c.

References wakeup().

Here is the call graph for this function:

int solisten ( struct socket *  so,
int  backlog,
struct thread *  td 
)

Definition at line 632 of file uipc_socket.c.

Referenced by sys_listen().

Here is the caller graph for this function:

void solisten_proto ( struct socket *  so,
int  backlog 
)

Definition at line 655 of file uipc_socket.c.

References somaxconn.

Referenced by uipc_listen().

Here is the caller graph for this function:

int solisten_proto_check ( struct socket *  so)

Definition at line 643 of file uipc_socket.c.

Referenced by uipc_listen().

Here is the caller graph for this function:

struct socket* sonewconn ( struct socket *  head,
int  connstatus 
)

Definition at line 484 of file uipc_socket.c.

References crhold(), knlist_init_mtx(), log(), ratecheck(), soabort(), soalloc(), sodealloc(), sofree(), soreserve(), VNET_SO_ASSERT, and wakeup_one().

Referenced by sys_sctp_peeloff(), and unp_connect().

Here is the call graph for this function:

Here is the caller graph for this function:

int soo_kqfilter ( struct file *  fp,
struct knote kn 
)

Definition at line 3085 of file uipc_socket.c.

References knlist_add(), solisten_filtops, soread_filtops, and sowrite_filtops.

Here is the call graph for this function:

int soopt_getm ( struct sockopt *  sopt,
struct mbuf **  mp 
)

Definition at line 2902 of file uipc_socket.c.

References m_freem().

Here is the call graph for this function:

int soopt_mcopyin ( struct sockopt *  sopt,
struct mbuf *  m 
)

Definition at line 2951 of file uipc_socket.c.

References m_freem(), and panic().

Here is the call graph for this function:

int soopt_mcopyout ( struct sockopt *  sopt,
struct mbuf *  m 
)

Definition at line 2980 of file uipc_socket.c.

References m_freem().

Here is the call graph for this function:

int sooptcopyin ( struct sockopt *  sopt,
void *  buf,
size_t  len,
size_t  minlen 
)

Definition at line 2466 of file uipc_socket.c.

Referenced by do_setopt_accept_filter(), sogetopt(), sosetopt(), and uipc_ctloutput().

Here is the caller graph for this function:

int sooptcopyout ( struct sockopt *  sopt,
const void *  buf,
size_t  len 
)

Definition at line 2717 of file uipc_socket.c.

Referenced by do_getopt_accept_filter(), sogetopt(), and uipc_ctloutput().

Here is the caller graph for this function:

int sopoll ( struct socket *  so,
int  events,
struct ucred *  active_cred,
struct thread *  td 
)

Definition at line 3027 of file uipc_socket.c.

Referenced by selsocket(), and soo_poll().

Here is the caller graph for this function:

int sopoll_generic ( struct socket *  so,
int  events,
struct ucred *  active_cred,
struct thread *  td 
)

Definition at line 3040 of file uipc_socket.c.

References selrecord().

Referenced by protosw_init().

Here is the call graph for this function:

Here is the caller graph for this function:

int soreceive ( struct socket *  so,
struct sockaddr **  psa,
struct uio *  uio,
struct mbuf **  mp0,
struct mbuf **  controlp,
int *  flagsp 
)

Definition at line 2373 of file uipc_socket.c.

Referenced by kern_recvit(), and soo_read().

Here is the caller graph for this function:

int soreceive_dgram ( struct socket *  so,
struct sockaddr **  psa,
struct uio *  uio,
struct mbuf **  mp0,
struct mbuf **  controlp,
int *  flagsp 
)

Definition at line 2191 of file uipc_socket.c.

References m_freem(), pr, sbwait(), sockbuf_pushsync(), sodupsockaddr(), soreceive_generic(), and uiomove().

Here is the call graph for this function:

int soreceive_generic ( struct socket *  so,
struct sockaddr **  psa,
struct uio *  uio,
struct mbuf **  mp0,
struct mbuf **  controlp,
int *  flagsp 
)

Definition at line 1527 of file uipc_socket.c.

References m_copym(), m_freem(), pr, sbdroprecord_locked(), sblock(), SBLOCKWAIT, sbunlock(), sbwait(), sockbuf_pushsync(), sodupsockaddr(), soreceive_rcvoob(), type, uiomove(), and VNET_SO_ASSERT.

Referenced by protosw_init(), and soreceive_dgram().

Here is the call graph for this function:

Here is the caller graph for this function:

static int soreceive_rcvoob ( struct socket *  so,
struct uio *  uio,
int  flags 
)
static

Definition at line 1435 of file uipc_socket.c.

References m_freem(), pr, uiomove(), and VNET_SO_ASSERT.

Referenced by soreceive_generic(), and soreceive_stream().

Here is the call graph for this function:

Here is the caller graph for this function:

int soreceive_stream ( struct socket *  so,
struct sockaddr **  psa,
struct uio *  uio,
struct mbuf **  mp0,
struct mbuf **  controlp,
int *  flagsp 
)

Definition at line 1990 of file uipc_socket.c.

References m_cat(), m_copym(), m_mbuftouio(), sbdrop_locked(), sblock(), SBLOCKWAIT, sbunlock(), sbwait(), soreceive_rcvoob(), and VNET_SO_ASSERT.

Here is the call graph for this function:

void sorflush ( struct socket *  so)

Definition at line 2412 of file uipc_socket.c.

References pr, sblock(), sbrelease_internal(), sbunlock(), socantrcvmore(), and VNET_SO_ASSERT.

Referenced by soshutdown(), and unp_gc().

Here is the call graph for this function:

Here is the caller graph for this function:

int sosend ( struct socket *  so,
struct sockaddr *  addr,
struct uio *  uio,
struct mbuf *  top,
struct mbuf *  control,
int  flags,
struct thread *  td 
)

Definition at line 1414 of file uipc_socket.c.

Referenced by kern_sendit(), and soo_write().

Here is the caller graph for this function:

int sosend_dgram ( struct socket *  so,
struct sockaddr *  addr,
struct uio *  uio,
struct mbuf *  top,
struct mbuf *  control,
int  flags,
struct thread *  td 
)

Definition at line 1057 of file uipc_socket.c.

References m_freem(), m_uiotombuf(), max_hdr, and VNET_SO_ASSERT.

Here is the call graph for this function:

int sosend_generic ( struct socket *  so,
struct sockaddr *  addr,
struct uio *  uio,
struct mbuf *  top,
struct mbuf *  control,
int  flags,
struct thread *  td 
)

Definition at line 1230 of file uipc_socket.c.

References m_freem(), m_uiotombuf(), max_hdr, sblock(), SBLOCKWAIT, sbunlock(), sbwait(), and VNET_SO_ASSERT.

Referenced by protosw_init().

Here is the call graph for this function:

Here is the caller graph for this function:

int sosetopt ( struct socket *  so,
struct sockopt *  sopt 
)

Definition at line 2509 of file uipc_socket.c.

References do_setopt_accept_filter(), sbreserve(), sooptcopyin(), and tvtohz().

Referenced by kern_setsockopt(), and so_setsockopt().

Here is the call graph for this function:

Here is the caller graph for this function:

int soshutdown ( struct socket *  so,
int  how 
)

Definition at line 2386 of file uipc_socket.c.

References pr, sorflush(), and wakeup().

Referenced by sys_shutdown().

Here is the call graph for this function:

Here is the caller graph for this function:

void sotoxsocket ( struct socket *  so,
struct xsocket *  xso 
)

Definition at line 3546 of file uipc_socket.c.

References sbtoxsockbuf().

Referenced by unp_pcblist().

Here is the call graph for this function:

Here is the caller graph for this function:

void soupcall_clear ( struct socket *  so,
int  which 
)

Definition at line 3516 of file uipc_socket.c.

References panic().

Referenced by soisconnected(), and sowakeup().

Here is the call graph for this function:

Here is the caller graph for this function:

void soupcall_set ( struct socket *  so,
int  which,
int(*)(struct socket *, void *, int)  func,
void *  arg 
)

Definition at line 3490 of file uipc_socket.c.

References panic().

Referenced by soisconnected().

Here is the call graph for this function:

Here is the caller graph for this function:

SYSCTL_INT ( _kern_ipc  ,
OID_AUTO  ,
numopensockets  ,
CTLFLAG_RD  ,
numopensockets,
,
"Number of open sockets"   
)
static int sysctl_maxsockets ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 294 of file uipc_socket.c.

References maxfiles, maxsockets, and sysctl_handle_int().

Here is the call graph for this function:

SYSCTL_NODE ( _kern  ,
KERN_IPC  ,
ipc  ,
CTLFLAG_RW  ,
,
"IPC"   
)
SYSCTL_PROC ( _kern_ipc  ,
KIPC_SOMAXCONN  ,
somaxconn  ,
CTLTYPE_UINT|  CTLFLAG_RW,
,
sizeof(int)  ,
sysctl_somaxconn  ,
"I"  ,
"Maximum listen socket pending connection accept queue size"   
)
SYSCTL_PROC ( _kern_ipc  ,
OID_AUTO  ,
maxsockets  ,
CTLTYPE_INT|  CTLFLAG_RW,
maxsockets,
,
sysctl_maxsockets  ,
"IU"  ,
"Maximum number of sockets avaliable"   
)
static int sysctl_somaxconn ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 194 of file uipc_socket.c.

References somaxconn, and sysctl_handle_int().

Here is the call graph for this function:

SYSINIT ( socket  ,
SI_SUB_PROTO_DOMAININIT  ,
SI_ORDER_ANY  ,
socket_init  ,
NULL   
)
SYSINIT ( param  ,
SI_SUB_TUNABLES  ,
SI_ORDER_ANY  ,
init_maxsockets  ,
NULL   
)

Variable Documentation

struct mtx accept_mtx

Definition at line 234 of file uipc_socket.c.

Referenced by kern_accept().

int maxsockets

Definition at line 255 of file uipc_socket.c.

Referenced by sysctl_maxsockets(), unp_init(), and unp_zone_change().

int numopensockets
static

Definition at line 214 of file uipc_socket.c.

Referenced by soalloc(), and sodealloc().

so_gen_t so_gencnt

Definition at line 178 of file uipc_socket.c.

Referenced by soalloc(), sodealloc(), and unp_pcblist().

struct mtx so_global_mtx
static

Definition at line 241 of file uipc_socket.c.

Referenced by soalloc(), and sodealloc().

uma_zone_t socket_zone

Definition at line 254 of file uipc_socket.c.

struct filterops solisten_filtops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_sordetach,
.f_event = filt_solisten,
}
static int filt_solisten(struct knote *kn, long hint)
Definition: uipc_socket.c:3325
static void filt_sordetach(struct knote *kn)
Definition: uipc_socket.c:3254

Definition at line 162 of file uipc_socket.c.

Referenced by soo_kqfilter().

int somaxconn = SOMAXCONN
static

Definition at line 191 of file uipc_socket.c.

Referenced by solisten_proto(), and sysctl_somaxconn().

struct filterops soread_filtops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_sordetach,
.f_event = filt_soread,
}
static void filt_sordetach(struct knote *kn)
Definition: uipc_socket.c:3254
static int filt_soread(struct knote *kn, long hint)
Definition: uipc_socket.c:3267

Definition at line 167 of file uipc_socket.c.

Referenced by soo_kqfilter().

struct filterops sowrite_filtops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_sowdetach,
.f_event = filt_sowrite,
}
static int filt_sowrite(struct knote *kn, long hint)
Definition: uipc_socket.c:3301
static void filt_sowdetach(struct knote *kn)
Definition: uipc_socket.c:3288

Definition at line 172 of file uipc_socket.c.

Referenced by soo_kqfilter().