FreeBSD kernel kern code
uipc_sockbuf.c File Reference
#include <sys/cdefs.h>
#include "opt_param.h"
#include <sys/param.h>
#include <sys/aio.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
Include dependency graph for uipc_sockbuf.c:

Go to the source code of this file.

Macros

#define SBLINKRECORD(sb, m0)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static void sbdrop_internal (struct sockbuf *sb, int len)
 
static void sbflush_internal (struct sockbuf *sb)
 
void socantsendmore_locked (struct socket *so)
 
void socantsendmore (struct socket *so)
 
void socantrcvmore_locked (struct socket *so)
 
void socantrcvmore (struct socket *so)
 
int sbwait (struct sockbuf *sb)
 
int sblock (struct sockbuf *sb, int flags)
 
void sbunlock (struct sockbuf *sb)
 
void sowakeup (struct socket *so, struct sockbuf *sb)
 
int soreserve (struct socket *so, u_long sndcc, u_long rcvcc)
 
static int sysctl_handle_sb_max (SYSCTL_HANDLER_ARGS)
 
int sbreserve_locked (struct sockbuf *sb, u_long cc, struct socket *so, struct thread *td)
 
int sbreserve (struct sockbuf *sb, u_long cc, struct socket *so, struct thread *td)
 
void sbrelease_internal (struct sockbuf *sb, struct socket *so)
 
void sbrelease_locked (struct sockbuf *sb, struct socket *so)
 
void sbrelease (struct sockbuf *sb, struct socket *so)
 
void sbdestroy (struct sockbuf *sb, struct socket *so)
 
void sbappend_locked (struct sockbuf *sb, struct mbuf *m)
 
void sbappend (struct sockbuf *sb, struct mbuf *m)
 
void sbappendstream_locked (struct sockbuf *sb, struct mbuf *m)
 
void sbappendstream (struct sockbuf *sb, struct mbuf *m)
 
void sbappendrecord_locked (struct sockbuf *sb, struct mbuf *m0)
 
void sbappendrecord (struct sockbuf *sb, struct mbuf *m0)
 
static int sbappendaddr_locked_internal (struct sockbuf *sb, const struct sockaddr *asa, struct mbuf *m0, struct mbuf *control, struct mbuf *ctrl_last)
 
int sbappendaddr_locked (struct sockbuf *sb, const struct sockaddr *asa, struct mbuf *m0, struct mbuf *control)
 
int sbappendaddr_nospacecheck_locked (struct sockbuf *sb, const struct sockaddr *asa, struct mbuf *m0, struct mbuf *control)
 
int sbappendaddr (struct sockbuf *sb, const struct sockaddr *asa, struct mbuf *m0, struct mbuf *control)
 
int sbappendcontrol_locked (struct sockbuf *sb, struct mbuf *m0, struct mbuf *control)
 
int sbappendcontrol (struct sockbuf *sb, struct mbuf *m0, struct mbuf *control)
 
void sbcompress (struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
 
void sbflush_locked (struct sockbuf *sb)
 
void sbflush (struct sockbuf *sb)
 
void sbdrop_locked (struct sockbuf *sb, int len)
 
void sbdrop (struct sockbuf *sb, int len)
 
struct mbuf * sbsndptr (struct sockbuf *sb, u_int off, u_int len, u_int *moff)
 
struct mbuf * sbsndmbuf (struct sockbuf *sb, u_int off, u_int *moff)
 
void sbdroprecord_locked (struct sockbuf *sb)
 
void sbdroprecord (struct sockbuf *sb)
 
struct mbuf * sbcreatecontrol (caddr_t p, int size, int type, int level)
 
void sbtoxsockbuf (struct sockbuf *sb, struct xsockbuf *xsb)
 
 SYSCTL_INT (_kern, KERN_DUMMY, dummy, CTLFLAG_RW,&dummy, 0,"")
 
 SYSCTL_OID (_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLTYPE_ULONG|CTLFLAG_RW,&sb_max, 0, sysctl_handle_sb_max,"LU","Maximum socket buffer size")
 
 SYSCTL_ULONG (_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW,&sb_efficiency, 0,"")
 

Variables

void(* aio_swake )(struct socket *, struct sockbuf *)
 
u_long sb_max = SB_MAX
 
u_long sb_max_adj
 
static u_long sb_efficiency = 8
 
static int dummy
 

Macro Definition Documentation

#define SBLINKRECORD (   sb,
  m0 
)
Value:
do { \
SOCKBUF_LOCK_ASSERT(sb); \
if ((sb)->sb_lastrecord != NULL) \
(sb)->sb_lastrecord->m_nextpkt = (m0); \
else \
(sb)->sb_mb = (m0); \
(sb)->sb_lastrecord = (m0); \
} while (/*CONSTCOND*/0)

Definition at line 442 of file uipc_sockbuf.c.

Referenced by sbappendaddr_locked_internal(), sbappendcontrol_locked(), and sbappendrecord_locked().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
void sbappend ( struct sockbuf *  sb,
struct mbuf *  m 
)

Definition at line 508 of file uipc_sockbuf.c.

References sbappend_locked().

Here is the call graph for this function:

void sbappend_locked ( struct sockbuf *  sb,
struct mbuf *  m 
)

Definition at line 457 of file uipc_sockbuf.c.

References sbappendrecord_locked(), and sbcompress().

Referenced by sbappend(), and uipc_send().

Here is the call graph for this function:

Here is the caller graph for this function:

int sbappendaddr ( struct sockbuf *  sb,
const struct sockaddr *  asa,
struct mbuf *  m0,
struct mbuf *  control 
)

Definition at line 704 of file uipc_sockbuf.c.

References sbappendaddr_locked().

Here is the call graph for this function:

int sbappendaddr_locked ( struct sockbuf *  sb,
const struct sockaddr *  asa,
struct mbuf *  m0,
struct mbuf *  control 
)

Definition at line 660 of file uipc_sockbuf.c.

References m_length(), panic(), and sbappendaddr_locked_internal().

Referenced by sbappendaddr(), and uipc_send().

Here is the call graph for this function:

Here is the caller graph for this function:

static int sbappendaddr_locked_internal ( struct sockbuf *  sb,
const struct sockaddr *  asa,
struct mbuf *  m0,
struct mbuf *  control,
struct mbuf *  ctrl_last 
)
static

Definition at line 622 of file uipc_sockbuf.c.

References SBLINKRECORD.

Referenced by sbappendaddr_locked(), and sbappendaddr_nospacecheck_locked().

Here is the caller graph for this function:

int sbappendaddr_nospacecheck_locked ( struct sockbuf *  sb,
const struct sockaddr *  asa,
struct mbuf *  m0,
struct mbuf *  control 
)

Definition at line 686 of file uipc_sockbuf.c.

References sbappendaddr_locked_internal().

Referenced by uipc_send().

Here is the call graph for this function:

Here is the caller graph for this function:

int sbappendcontrol ( struct sockbuf *  sb,
struct mbuf *  m0,
struct mbuf *  control 
)

Definition at line 748 of file uipc_sockbuf.c.

References sbappendcontrol_locked().

Here is the call graph for this function:

int sbappendcontrol_locked ( struct sockbuf *  sb,
struct mbuf *  m0,
struct mbuf *  control 
)

Definition at line 716 of file uipc_sockbuf.c.

References m_length(), panic(), and SBLINKRECORD.

Referenced by sbappendcontrol(), and uipc_send().

Here is the call graph for this function:

Here is the caller graph for this function:

void sbappendrecord ( struct sockbuf *  sb,
struct mbuf *  m0 
)

Definition at line 612 of file uipc_sockbuf.c.

References sbappendrecord_locked().

Here is the call graph for this function:

void sbappendrecord_locked ( struct sockbuf *  sb,
struct mbuf *  m0 
)

Definition at line 582 of file uipc_sockbuf.c.

References sbcompress(), and SBLINKRECORD.

Referenced by sbappend_locked(), and sbappendrecord().

Here is the call graph for this function:

Here is the caller graph for this function:

void sbappendstream ( struct sockbuf *  sb,
struct mbuf *  m 
)

Definition at line 543 of file uipc_sockbuf.c.

References sbappendstream_locked().

Here is the call graph for this function:

void sbappendstream_locked ( struct sockbuf *  sb,
struct mbuf *  m 
)

Definition at line 522 of file uipc_sockbuf.c.

References sbcompress().

Referenced by sbappendstream().

Here is the call graph for this function:

Here is the caller graph for this function:

void sbcompress ( struct sockbuf *  sb,
struct mbuf *  m,
struct mbuf *  n 
)

Definition at line 779 of file uipc_sockbuf.c.

Referenced by sbappend_locked(), sbappendrecord_locked(), and sbappendstream_locked().

Here is the caller graph for this function:

struct mbuf* sbcreatecontrol ( caddr_t  p,
int  size,
int  type,
int  level 
)

Definition at line 1062 of file uipc_sockbuf.c.

References level, and type.

Referenced by unp_addsockcred(), unp_externalize(), and unp_internalize().

Here is the caller graph for this function:

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

Definition at line 364 of file uipc_sockbuf.c.

References sbrelease_internal().

Referenced by sofree().

Here is the call graph for this function:

Here is the caller graph for this function:

void sbdrop ( struct sockbuf *  sb,
int  len 
)

Definition at line 936 of file uipc_sockbuf.c.

References sbdrop_locked().

Here is the call graph for this function:

static void sbdrop_internal ( struct sockbuf *  sb,
int  len 
)
static

Definition at line 873 of file uipc_sockbuf.c.

References panic().

Referenced by sbdrop_locked(), and sbflush_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

void sbdrop_locked ( struct sockbuf *  sb,
int  len 
)

Definition at line 927 of file uipc_sockbuf.c.

References sbdrop_internal().

Referenced by sbdrop(), soisdisconnected(), and soreceive_stream().

Here is the call graph for this function:

Here is the caller graph for this function:

void sbdroprecord ( struct sockbuf *  sb)

Definition at line 1049 of file uipc_sockbuf.c.

References sbdroprecord_locked().

Here is the call graph for this function:

void sbdroprecord_locked ( struct sockbuf *  sb)

Definition at line 1027 of file uipc_sockbuf.c.

Referenced by sbdroprecord(), and soreceive_generic().

Here is the caller graph for this function:

void sbflush ( struct sockbuf *  sb)

Definition at line 861 of file uipc_sockbuf.c.

References sbflush_locked().

Here is the call graph for this function:

static void sbflush_internal ( struct sockbuf *  sb)
static

Definition at line 835 of file uipc_sockbuf.c.

References panic(), and sbdrop_internal().

Referenced by sbflush_locked(), and sbrelease_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

void sbflush_locked ( struct sockbuf *  sb)

Definition at line 853 of file uipc_sockbuf.c.

References sbflush_internal().

Referenced by sbflush().

Here is the call graph for this function:

Here is the caller graph for this function:

int sblock ( struct sockbuf *  sb,
int  flags 
)

Definition at line 136 of file uipc_sockbuf.c.

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

Here is the caller graph for this function:

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

Definition at line 355 of file uipc_sockbuf.c.

References sbrelease_locked().

Here is the call graph for this function:

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

Definition at line 336 of file uipc_sockbuf.c.

References chgsbsize(), and sbflush_internal().

Referenced by sbdestroy(), sbrelease_locked(), and sorflush().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 346 of file uipc_sockbuf.c.

References sbrelease_internal().

Referenced by sbrelease(), and soreserve().

Here is the call graph for this function:

Here is the caller graph for this function:

int sbreserve ( struct sockbuf *  sb,
u_long  cc,
struct socket *  so,
struct thread *  td 
)

Definition at line 321 of file uipc_sockbuf.c.

References sbreserve_locked().

Referenced by sosetopt().

Here is the call graph for this function:

Here is the caller graph for this function:

int sbreserve_locked ( struct sockbuf *  sb,
u_long  cc,
struct socket *  so,
struct thread *  td 
)

Definition at line 289 of file uipc_sockbuf.c.

References chgsbsize(), lim_cur(), sb_max, and sb_max_adj.

Referenced by sbreserve(), and soreserve().

Here is the call graph for this function:

Here is the caller graph for this function:

struct mbuf* sbsndmbuf ( struct sockbuf *  sb,
u_int  off,
u_int *  moff 
)

Definition at line 996 of file uipc_sockbuf.c.

struct mbuf* sbsndptr ( struct sockbuf *  sb,
u_int  off,
u_int  len,
u_int *  moff 
)

Definition at line 949 of file uipc_sockbuf.c.

References panic().

Here is the call graph for this function:

void sbtoxsockbuf ( struct sockbuf *  sb,
struct xsockbuf *  xsb 
)

Definition at line 1101 of file uipc_sockbuf.c.

Referenced by sotoxsocket().

Here is the caller graph for this function:

void sbunlock ( struct sockbuf *  sb)

Definition at line 157 of file uipc_sockbuf.c.

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

Here is the caller graph for this function:

int sbwait ( struct sockbuf *  sb)

Definition at line 124 of file uipc_sockbuf.c.

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

Here is the caller graph for this function:

void socantrcvmore ( struct socket *  so)

Definition at line 112 of file uipc_sockbuf.c.

References socantrcvmore_locked().

Referenced by sorflush(), and unp_shutdown().

Here is the call graph for this function:

Here is the caller graph for this function:

void socantrcvmore_locked ( struct socket *  so)

Definition at line 101 of file uipc_sockbuf.c.

Referenced by socantrcvmore().

Here is the caller graph for this function:

void socantsendmore ( struct socket *  so)

Definition at line 92 of file uipc_sockbuf.c.

References socantsendmore_locked().

Referenced by uipc_send(), and uipc_shutdown().

Here is the call graph for this function:

Here is the caller graph for this function:

void socantsendmore_locked ( struct socket *  so)

Definition at line 81 of file uipc_sockbuf.c.

Referenced by socantsendmore().

Here is the caller graph for this function:

int soreserve ( struct socket *  so,
u_long  sndcc,
u_long  rcvcc 
)

Definition at line 241 of file uipc_sockbuf.c.

References sbrelease_locked(), and sbreserve_locked().

Referenced by sonewconn(), and uipc_attach().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 176 of file uipc_sockbuf.c.

References aio_swake, pgsigio(), selwakeuppri(), soisconnected(), soupcall_clear(), and wakeup().

Here is the call graph for this function:

static int sysctl_handle_sb_max ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 269 of file uipc_sockbuf.c.

References sb_max, sb_max_adj, and sysctl_handle_long().

Here is the call graph for this function:

SYSCTL_INT ( _kern  ,
KERN_DUMMY  ,
dummy  ,
CTLFLAG_RW  ,
dummy,
,
""   
)
SYSCTL_OID ( _kern_ipc  ,
KIPC_MAXSOCKBUF  ,
maxsockbuf  ,
CTLTYPE_ULONG|  CTLFLAG_RW,
sb_max,
,
sysctl_handle_sb_max  ,
"LU"  ,
"Maximum socket buffer size"   
)
SYSCTL_ULONG ( _kern_ipc  ,
KIPC_SOCKBUF_WASTE  ,
sockbuf_waste_factor  ,
CTLFLAG_RW  ,
sb_efficiency,
,
""   
)

Variable Documentation

void(* aio_swake) (struct socket *, struct sockbuf *)

Definition at line 56 of file uipc_sockbuf.c.

Referenced by aio_onceonly(), aio_unload(), and sowakeup().

int dummy
static

Definition at line 1116 of file uipc_sockbuf.c.

Referenced by buf_splay(), and lookup().

u_long sb_efficiency = 8
static

Definition at line 66 of file uipc_sockbuf.c.

u_long sb_max = SB_MAX

Definition at line 62 of file uipc_sockbuf.c.

Referenced by sbreserve_locked(), and sysctl_handle_sb_max().

u_long sb_max_adj
Initial value:
=
(quad_t)SB_MAX * MCLBYTES / (MSIZE + MCLBYTES)

Definition at line 63 of file uipc_sockbuf.c.

Referenced by sbreserve_locked(), and sysctl_handle_sb_max().