FreeBSD kernel netgraph code
ng_pipe.c File Reference
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/time.h>
#include <vm/uma.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_pipe.h>
Include dependency graph for ng_pipe.c:

Go to the source code of this file.

Data Structures

struct  ngp_hdr
 
struct  ngp_fifo
 
struct  hookinfo
 
struct  node_priv
 

Macros

#define FIFO_VTIME_SORT(plen)
 

Typedefs

typedef struct node_privpriv_p
 

Functions

static MALLOC_DEFINE (M_NG_PIPE, "ng_pipe", "ng_pipe")
 
 TAILQ_HEAD (p_head, ngp_hdr)
 
static void parse_cfg (struct ng_pipe_hookcfg *, struct ng_pipe_hookcfg *, struct hookinfo *, priv_p)
 
static void pipe_dequeue (struct hookinfo *, struct timeval *)
 
static void ngp_callout (node_p, hook_p, void *, int)
 
static int ngp_modevent (module_t, int, void *)
 
 NETGRAPH_INIT (pipe, &ng_pipe_typestruct)
 
static int ngp_constructor (node_p node)
 
static int ngp_newhook (node_p node, hook_p hook, const char *name)
 
static int ngp_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ip_hash (struct mbuf *m, int offset)
 
static int ngp_rcvdata (hook_p hook, item_p item)
 
static int ngp_shutdown (node_p node)
 
static int ngp_disconnect (hook_p hook)
 

Variables

static uma_zone_t ngp_zone
 
static ng_constructor_t ngp_constructor
 
static ng_rcvmsg_t ngp_rcvmsg
 
static ng_shutdown_t ngp_shutdown
 
static ng_newhook_t ngp_newhook
 
static ng_rcvdata_t ngp_rcvdata
 
static ng_disconnect_t ngp_disconnect
 
static const struct ng_parse_struct_field ng_pipe_hookstat_type_fields [] = NG_PIPE_HOOKSTAT_INFO
 
static const struct ng_parse_type ng_pipe_hookstat_type
 
static const struct ng_parse_struct_field ng_pipe_stats_type_fields []
 
static const struct ng_parse_type ng_pipe_stats_type
 
static const struct ng_parse_struct_field ng_pipe_hookrun_type_fields [] = NG_PIPE_HOOKRUN_INFO
 
static const struct ng_parse_type ng_pipe_hookrun_type
 
static const struct ng_parse_struct_field ng_pipe_run_type_fields [] = NG_PIPE_RUN_INFO(&ng_pipe_hookrun_type)
 
static const struct ng_parse_type ng_pipe_run_type
 
static const struct ng_parse_struct_field ng_pipe_hookcfg_type_fields [] = NG_PIPE_HOOKCFG_INFO
 
static const struct ng_parse_type ng_pipe_hookcfg_type
 
static const struct ng_parse_struct_field ng_pipe_cfg_type_fields [] = NG_PIPE_CFG_INFO(&ng_pipe_hookcfg_type)
 
static const struct ng_parse_type ng_pipe_cfg_type
 
static const struct ng_cmdlist ngp_cmds []
 
static struct ng_type ng_pipe_typestruct
 

Macro Definition Documentation

◆ FIFO_VTIME_SORT

#define FIFO_VTIME_SORT (   plen)
Value:
if (hinfo->cfg.wfq && hinfo->cfg.bandwidth) { \
ngp_f->vtime.tv_usec = now->tv_usec + ((uint64_t) (plen) \
+ priv->overhead ) * hinfo->run.fifo_queues * \
8000000 / hinfo->cfg.bandwidth; \
ngp_f->vtime.tv_sec = now->tv_sec + \
ngp_f->vtime.tv_usec / 1000000; \
ngp_f->vtime.tv_usec = ngp_f->vtime.tv_usec % 1000000; \
TAILQ_FOREACH(ngp_f1, &hinfo->fifo_head, fifo_le) \
if (ngp_f1->vtime.tv_sec > ngp_f->vtime.tv_sec || \
(ngp_f1->vtime.tv_sec == ngp_f->vtime.tv_sec && \
ngp_f1->vtime.tv_usec > ngp_f->vtime.tv_usec)) \
break; \
if (ngp_f1 == NULL) \
TAILQ_INSERT_TAIL(&hinfo->fifo_head, ngp_f, fifo_le); \
else \
TAILQ_INSERT_BEFORE(ngp_f1, ngp_f, fifo_le); \
} else \
TAILQ_INSERT_TAIL(&hinfo->fifo_head, ngp_f, fifo_le); \
Definition: ng_sscfu.c:66

Definition at line 110 of file ng_pipe.c.

Typedef Documentation

◆ priv_p

typedef struct node_priv* priv_p

Definition at line 107 of file ng_pipe.c.

Function Documentation

◆ ip_hash()

static int ip_hash ( struct mbuf *  m,
int  offset 
)
static

Definition at line 565 of file ng_pipe.c.

Referenced by ngp_rcvdata().

Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_NG_PIPE  ,
"ng_pipe"  ,
"ng_pipe"   
)
static

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( pipe  ,
ng_pipe_typestruct 
)

◆ ngp_callout()

static void ngp_callout ( node_p  node,
hook_p  hook,
void *  arg1,
int  arg2 
)
static

Definition at line 891 of file ng_pipe.c.

References priv::lower, NG_NODE_PRIVATE, pipe_dequeue(), and priv::upper.

Referenced by pipe_dequeue().

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

◆ ngp_constructor()

static int ngp_constructor ( node_p  node)
static

Definition at line 252 of file ng_pipe.c.

References ng_callout_init, NG_NODE_FORCE_WRITER, and NG_NODE_SET_PRIVATE.

◆ ngp_disconnect()

static int ngp_disconnect ( hook_p  hook)
static

Definition at line 936 of file ng_pipe.c.

References hookinfo::hook, NG_HOOK_PRIVATE, and ngp_zone.

◆ ngp_modevent()

static int ngp_modevent ( module_t  mod,
int  type,
void *  unused 
)
static

Definition at line 971 of file ng_pipe.c.

References ngp_zone, and type.

◆ ngp_newhook()

static int ngp_newhook ( node_p  node,
hook_p  hook,
const char *  name 
)
static

◆ ngp_rcvdata()

static int ngp_rcvdata ( hook_p  hook,
item_p  item 
)
static

◆ ngp_rcvmsg()

◆ ngp_shutdown()

static int ngp_shutdown ( node_p  node)
static

Definition at line 913 of file ng_pipe.c.

References priv::lower, ng_bypass(), NG_NODE_PRIVATE, NG_NODE_UNREF, ng_rmhook_self(), ng_uncallout(), and priv::upper.

Here is the call graph for this function:

◆ parse_cfg()

◆ pipe_dequeue()

static void pipe_dequeue ( struct hookinfo hinfo,
struct timeval *  now 
)
static

Definition at line 731 of file ng_pipe.c.

References hookinfo::dest, FIFO_VTIME_SORT, hookinfo::hook, priv::lower, ng_callout(), NG_HOOK_NODE, NG_NODE_PRIVATE, NG_SEND_DATA, ngp_callout(), ngp_zone, hookinfo::stats, and priv::upper.

Referenced by ngp_callout(), and ngp_rcvdata().

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

◆ TAILQ_HEAD()

TAILQ_HEAD ( p_head  ,
ngp_hdr   
)

Variable Documentation

◆ ng_pipe_cfg_type

const struct ng_parse_type ng_pipe_cfg_type
static
Initial value:
= {
}
const struct ng_parse_type ng_parse_struct_type
Definition: ng_parse.c:222
static const struct ng_parse_struct_field ng_pipe_cfg_type_fields[]
Definition: ng_pipe.c:189

Definition at line 190 of file ng_pipe.c.

◆ ng_pipe_cfg_type_fields

const struct ng_parse_struct_field ng_pipe_cfg_type_fields[] = NG_PIPE_CFG_INFO(&ng_pipe_hookcfg_type)
static

Definition at line 189 of file ng_pipe.c.

◆ ng_pipe_hookcfg_type

const struct ng_parse_type ng_pipe_hookcfg_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_pipe_hookcfg_type_fields[]
Definition: ng_pipe.c:181

Definition at line 182 of file ng_pipe.c.

◆ ng_pipe_hookcfg_type_fields

const struct ng_parse_struct_field ng_pipe_hookcfg_type_fields[] = NG_PIPE_HOOKCFG_INFO
static

Definition at line 181 of file ng_pipe.c.

◆ ng_pipe_hookrun_type

const struct ng_parse_type ng_pipe_hookrun_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_pipe_hookrun_type_fields[]
Definition: ng_pipe.c:165

Definition at line 166 of file ng_pipe.c.

◆ ng_pipe_hookrun_type_fields

const struct ng_parse_struct_field ng_pipe_hookrun_type_fields[] = NG_PIPE_HOOKRUN_INFO
static

Definition at line 165 of file ng_pipe.c.

◆ ng_pipe_hookstat_type

const struct ng_parse_type ng_pipe_hookstat_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_pipe_hookstat_type_fields[]
Definition: ng_pipe.c:149

Definition at line 150 of file ng_pipe.c.

◆ ng_pipe_hookstat_type_fields

const struct ng_parse_struct_field ng_pipe_hookstat_type_fields[] = NG_PIPE_HOOKSTAT_INFO
static

Definition at line 149 of file ng_pipe.c.

◆ ng_pipe_run_type

const struct ng_parse_type ng_pipe_run_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_pipe_run_type_fields[]
Definition: ng_pipe.c:173

Definition at line 174 of file ng_pipe.c.

◆ ng_pipe_run_type_fields

const struct ng_parse_struct_field ng_pipe_run_type_fields[] = NG_PIPE_RUN_INFO(&ng_pipe_hookrun_type)
static

Definition at line 173 of file ng_pipe.c.

◆ ng_pipe_stats_type

const struct ng_parse_type ng_pipe_stats_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_pipe_stats_type_fields[]
Definition: ng_pipe.c:156

Definition at line 158 of file ng_pipe.c.

◆ ng_pipe_stats_type_fields

const struct ng_parse_struct_field ng_pipe_stats_type_fields[]
static
Initial value:
=
static const struct ng_parse_type ng_pipe_hookstat_type
Definition: ng_pipe.c:150
#define NG_PIPE_STATS_INFO(hstype)
Definition: ng_pipe.h:77

Definition at line 156 of file ng_pipe.c.

◆ ng_pipe_typestruct

struct ng_type ng_pipe_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.mod_event = ngp_modevent,
.constructor = ngp_constructor,
.shutdown = ngp_shutdown,
.rcvmsg = ngp_rcvmsg,
.newhook = ngp_newhook,
.rcvdata = ngp_rcvdata,
.disconnect = ngp_disconnect,
.cmdlist = ngp_cmds
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_constructor_t ngp_constructor
Definition: ng_pipe.c:140
static ng_newhook_t ngp_newhook
Definition: ng_pipe.c:143
static ng_disconnect_t ngp_disconnect
Definition: ng_pipe.c:145
static ng_rcvdata_t ngp_rcvdata
Definition: ng_pipe.c:144
static ng_shutdown_t ngp_shutdown
Definition: ng_pipe.c:142
static const struct ng_cmdlist ngp_cmds[]
Definition: ng_pipe.c:196
static ng_rcvmsg_t ngp_rcvmsg
Definition: ng_pipe.c:141
static int ngp_modevent(module_t, int, void *)
Definition: ng_pipe.c:971
#define NG_PIPE_NODE_TYPE
Definition: ng_pipe.h:39

Definition at line 236 of file ng_pipe.c.

◆ ngp_cmds

const struct ng_cmdlist ngp_cmds[]
static

Definition at line 196 of file ng_pipe.c.

◆ ngp_constructor

ng_constructor_t ngp_constructor
static

Definition at line 140 of file ng_pipe.c.

◆ ngp_disconnect

ng_disconnect_t ngp_disconnect
static

Definition at line 145 of file ng_pipe.c.

◆ ngp_newhook

ng_newhook_t ngp_newhook
static

Definition at line 143 of file ng_pipe.c.

◆ ngp_rcvdata

ng_rcvdata_t ngp_rcvdata
static

Definition at line 144 of file ng_pipe.c.

◆ ngp_rcvmsg

ng_rcvmsg_t ngp_rcvmsg
static

Definition at line 141 of file ng_pipe.c.

◆ ngp_shutdown

ng_shutdown_t ngp_shutdown
static

Definition at line 142 of file ng_pipe.c.

◆ ngp_zone

uma_zone_t ngp_zone
static

Definition at line 137 of file ng_pipe.c.

Referenced by ngp_disconnect(), ngp_modevent(), ngp_rcvdata(), and pipe_dequeue().