FreeBSD kernel netgraph code
ng_car.c File Reference
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <netgraph/ng_message.h>
#include <netgraph/ng_parse.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_car.h>
#include "qos.h"
Include dependency graph for ng_car.c:

Go to the source code of this file.

Data Structures

struct  hookinfo
 
struct  privdata
 

Macros

#define NG_CAR_QUEUE_SIZE   100 /* Maximum queue size for SHAPE mode */
 
#define NG_CAR_QUEUE_MIN_TH   8 /* Minimum RED threshold for SHAPE mode */
 
#define NG_CAR_PERFORM_MATCH_ACTION(a, col)
 

Typedefs

typedef struct privdatapriv_p
 

Functions

static void ng_car_refillhook (struct hookinfo *h)
 
static void ng_car_schedule (struct hookinfo *h)
 
void ng_car_q_event (node_p node, hook_p hook, void *arg, int arg2)
 
static void ng_car_enqueue (struct hookinfo *h, item_p item)
 
 NETGRAPH_INIT (car, &ng_car_typestruct)
 
static int ng_car_constructor (node_p node)
 
static int ng_car_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_car_rcvdata (hook_p hook, item_p item)
 
static int ng_car_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ng_car_shutdown (node_p node)
 
static int ng_car_disconnect (hook_p hook)
 

Variables

static ng_constructor_t ng_car_constructor
 
static ng_rcvmsg_t ng_car_rcvmsg
 
static ng_shutdown_t ng_car_shutdown
 
static ng_newhook_t ng_car_newhook
 
static ng_rcvdata_t ng_car_rcvdata
 
static ng_disconnect_t ng_car_disconnect
 
static const struct ng_parse_struct_field ng_car_hookstats_type_fields [] = NG_CAR_HOOKSTATS
 
static const struct ng_parse_type ng_car_hookstats_type
 
static const struct ng_parse_struct_field ng_car_bulkstats_type_fields [] = NG_CAR_BULKSTATS(&ng_car_hookstats_type)
 
static const struct ng_parse_type ng_car_bulkstats_type
 
static const struct ng_parse_struct_field ng_car_hookconf_type_fields [] = NG_CAR_HOOKCONF
 
static const struct ng_parse_type ng_car_hookconf_type
 
static const struct ng_parse_struct_field ng_car_bulkconf_type_fields [] = NG_CAR_BULKCONF(&ng_car_hookconf_type)
 
static const struct ng_parse_type ng_car_bulkconf_type
 
static struct ng_cmdlist ng_car_cmdlist []
 
static struct ng_type ng_car_typestruct
 

Macro Definition Documentation

◆ NG_CAR_PERFORM_MATCH_ACTION

#define NG_CAR_PERFORM_MATCH_ACTION (   a,
  col 
)
Value:
do { \
switch (a) { \
/* Do nothing. */ \
break; \
if (colp == NULL) { \
colp = (void *)m_tag_alloc( \
MTAG_SIZE(m_qos_color), M_NOWAIT); \
if (colp != NULL) \
m_tag_prepend(m, &colp->tag); \
} \
if (colp != NULL) \
colp->color = col; \
break; \
default: \
/* Drop packet and return. */ \
NG_FREE_ITEM(item); \
++hinfo->stats.dropped_pkts; \
return (0); \
} \
} while (0)
@ NG_CAR_ACTION_DROP
Definition: ng_car.h:105
@ NG_CAR_ACTION_MARK
Definition: ng_car.h:106
@ NG_CAR_ACTION_FORWARD
Definition: ng_car.h:104
#define M_QOS_COLOR
Definition: qos.h:58
#define M_QOS_COOKIE
Definition: qos.h:36
#define MTAG_SIZE(X)
Definition: qos.h:37

◆ NG_CAR_QUEUE_MIN_TH

#define NG_CAR_QUEUE_MIN_TH   8 /* Minimum RED threshold for SHAPE mode */

Definition at line 57 of file ng_car.c.

◆ NG_CAR_QUEUE_SIZE

#define NG_CAR_QUEUE_SIZE   100 /* Maximum queue size for SHAPE mode */

Definition at line 56 of file ng_car.c.

Typedef Documentation

◆ priv_p

typedef struct privdata* priv_p

Definition at line 84 of file ng_car.c.

Function Documentation

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( car  ,
ng_car_typestruct 
)

◆ ng_car_constructor()

static int ng_car_constructor ( node_p  node)
static

◆ ng_car_disconnect()

static int ng_car_disconnect ( hook_p  hook)
static

◆ ng_car_enqueue()

◆ ng_car_newhook()

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

◆ ng_car_q_event()

void ng_car_q_event ( node_p  node,
hook_p  hook,
void *  arg,
int  arg2 
)

◆ ng_car_rcvdata()

◆ ng_car_rcvmsg()

◆ ng_car_refillhook()

static void ng_car_refillhook ( struct hookinfo h)
static

◆ ng_car_schedule()

static void ng_car_schedule ( struct hookinfo h)
static

Definition at line 684 of file ng_car.c.

References ng_car_hookconf::cir, hookinfo::conf, hookinfo::hook, ng_callout(), ng_car_q_event(), NG_HOOK_NODE, hookinfo::q_callout, and hookinfo::tc.

Referenced by ng_car_enqueue(), and ng_car_q_event().

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

◆ ng_car_shutdown()

static int ng_car_shutdown ( node_p  node)
static

Definition at line 567 of file ng_car.c.

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

Here is the call graph for this function:

Variable Documentation

◆ ng_car_bulkconf_type

const struct ng_parse_type ng_car_bulkconf_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_car_bulkconf_type_fields[]
Definition: ng_car.c:124
const struct ng_parse_type ng_parse_struct_type
Definition: ng_parse.c:222

Definition at line 125 of file ng_car.c.

◆ ng_car_bulkconf_type_fields

const struct ng_parse_struct_field ng_car_bulkconf_type_fields[] = NG_CAR_BULKCONF(&ng_car_hookconf_type)
static

Definition at line 123 of file ng_car.c.

◆ ng_car_bulkstats_type

const struct ng_parse_type ng_car_bulkstats_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_car_bulkstats_type_fields[]
Definition: ng_car.c:108

Definition at line 109 of file ng_car.c.

◆ ng_car_bulkstats_type_fields

const struct ng_parse_struct_field ng_car_bulkstats_type_fields[] = NG_CAR_BULKSTATS(&ng_car_hookstats_type)
static

Definition at line 107 of file ng_car.c.

◆ ng_car_cmdlist

struct ng_cmdlist ng_car_cmdlist[]
static

Definition at line 131 of file ng_car.c.

◆ ng_car_constructor

ng_constructor_t ng_car_constructor
static

Definition at line 86 of file ng_car.c.

◆ ng_car_disconnect

ng_disconnect_t ng_car_disconnect
static

Definition at line 91 of file ng_car.c.

◆ ng_car_hookconf_type

const struct ng_parse_type ng_car_hookconf_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_car_hookconf_type_fields[]
Definition: ng_car.c:116

Definition at line 117 of file ng_car.c.

◆ ng_car_hookconf_type_fields

const struct ng_parse_struct_field ng_car_hookconf_type_fields[] = NG_CAR_HOOKCONF
static

Definition at line 115 of file ng_car.c.

◆ ng_car_hookstats_type

const struct ng_parse_type ng_car_hookstats_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_car_hookstats_type_fields[]
Definition: ng_car.c:100

Definition at line 101 of file ng_car.c.

◆ ng_car_hookstats_type_fields

const struct ng_parse_struct_field ng_car_hookstats_type_fields[] = NG_CAR_HOOKSTATS
static

Definition at line 99 of file ng_car.c.

◆ ng_car_newhook

ng_newhook_t ng_car_newhook
static

Definition at line 89 of file ng_car.c.

◆ ng_car_rcvdata

ng_rcvdata_t ng_car_rcvdata
static

Definition at line 90 of file ng_car.c.

◆ ng_car_rcvmsg

ng_rcvmsg_t ng_car_rcvmsg
static

Definition at line 87 of file ng_car.c.

◆ ng_car_shutdown

ng_shutdown_t ng_car_shutdown
static

Definition at line 88 of file ng_car.c.

◆ ng_car_typestruct

struct ng_type ng_car_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ng_car_constructor,
.rcvmsg = ng_car_rcvmsg,
.shutdown = ng_car_shutdown,
.newhook = ng_car_newhook,
.rcvdata = ng_car_rcvdata,
.disconnect = ng_car_disconnect,
.cmdlist = ng_car_cmdlist,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_rcvdata_t ng_car_rcvdata
Definition: ng_car.c:90
static ng_newhook_t ng_car_newhook
Definition: ng_car.c:89
static ng_disconnect_t ng_car_disconnect
Definition: ng_car.c:91
static ng_shutdown_t ng_car_shutdown
Definition: ng_car.c:88
static struct ng_cmdlist ng_car_cmdlist[]
Definition: ng_car.c:131
static ng_constructor_t ng_car_constructor
Definition: ng_car.c:86
static ng_rcvmsg_t ng_car_rcvmsg
Definition: ng_car.c:87
#define NG_CAR_NODE_TYPE
Definition: ng_car.h:35

Definition at line 172 of file ng_car.c.