53#include <sys/kernel.h>
54#include <sys/malloc.h>
190 priv = malloc(
sizeof(*
priv), M_NETGRAPH, M_WAITOK | M_ZERO);
220 if (!isdigit(*cp) || (cp[0] ==
'0' && cp[1] !=
'\0'))
222 i = strtoul(cp, &eptr, 10);
226 link = &
priv->many[linkNum];
234 if (link->
hook != NULL)
242 priv->conf.enabledLinks[linkNum] = 1;
301 bcopy(conf, &
priv->conf,
sizeof(*conf));
315 bcopy(&
priv->conf, conf,
sizeof(
priv->conf));
330 linkNum = *((int32_t *)msg->
data);
333 else if (linkNum >= 0
335 link = &
priv->many[linkNum];
344 sizeof(link->
stats), M_NOWAIT);
373 if (lasthook == NULL)
381 (
"%s: linkNum=%d", __func__, linkNum));
385 priv->conf.enabledLinks[linkNum] = 1;
389 priv->conf.enabledLinks[linkNum] = 0;
428 (
"%s: linkNum=%d", __func__, linkNum));
433 KASSERT(src->
hook != NULL, (
"%s: no src%d", __func__, linkNum));
441 if (
priv->numActiveMany == 0) {
445 switch(
priv->conf.xmitAlg) {
448 priv->nextMany = (
priv->nextMany + 1) %
priv->numActiveMany;
452 dst = &
priv->many[
priv->activeMany[0]];
457 for (i = 1; i <
priv->numActiveMany; i++) {
461 mdst = &
priv->many[
priv->activeMany[i]];
462 m2 = m_dup(m, M_NOWAIT);
476 dst = &
priv->many[
priv->activeMany[0]];
480 panic(
"%s: invalid xmitAlg", __func__);
504 KASSERT(
priv->numActiveMany == 0,
505 (
"%s: numActiveMany=%d", __func__,
priv->numActiveMany));
506 free(
priv, M_NETGRAPH);
525 (
"%s: linkNum=%d", __func__, linkNum));
529 priv->one.hook = NULL;
531 priv->many[linkNum].hook = NULL;
532 priv->conf.enabledLinks[linkNum] = 0;
553 uint16_t saveActive =
priv->numActiveMany;
557 priv->numActiveMany = 0;
559 switch (
priv->conf.failAlg) {
562 if (
priv->many[linkNum].hook != NULL
563 &&
priv->conf.enabledLinks[linkNum]) {
564 priv->activeMany[
priv->numActiveMany] = linkNum;
565 priv->numActiveMany++;
570 panic(
"%s: invalid failAlg", __func__);
575 if (
priv->numActiveMany == 0 && saveActive > 0)
578 if (saveActive == 0 &&
priv->numActiveMany > 0)
582 switch (
priv->conf.xmitAlg) {
584 if (
priv->numActiveMany > 0)
585 priv->nextMany %=
priv->numActiveMany;
592 panic(
"%s: invalid xmitAlg", __func__);
606 if (
priv->one.hook == NULL)
#define NG_HOOK_NODE(hook)
int ng_rcvmsg_t(node_p node, item_p item, hook_p lasthook)
#define NG_FWD_ITEM_HOOK(error, item, hook)
int ng_disconnect_t(hook_p hook)
#define NG_NODE_SET_PRIVATE(node, val)
#define NG_RESPOND_MSG(error, here, item, resp)
#define NG_NODE_IS_VALID(node)
#define NG_NODE_UNREF(node)
#define NG_HOOK_SET_PRIVATE(hook, val)
int ng_rmnode_self(node_p here)
#define NG_SEND_DATA_ONLY(error, hook, m)
int ng_rcvdata_t(hook_p hook, item_p item)
int ng_shutdown_t(node_p node)
#define NG_FREE_ITEM(item)
int ng_constructor_t(node_p node)
#define NG_NODE_NUMHOOKS(node)
#define NGI_GET_MSG(i, m)
#define NG_NODE_PRIVATE(node)
#define NG_SEND_MSG_HOOK(error, here, msg, hook, retaddr)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
#define NG_HOOK_PRIVATE(hook)
#define NG_MKRESPONSE(rsp, msg, len, how)
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how)
static struct ng_type ng_one2many_typestruct
NETGRAPH_INIT(one2many, &ng_one2many_typestruct)
static const struct ng_parse_type ng_one2many_enableLinks_array_type
static ng_constructor_t ng_one2many_constructor
struct ng_one2many_private * priv_p
static void ng_one2many_notify(priv_p priv, uint32_t cmd)
static const struct ng_parse_fixedarray_info ng_one2many_enableLinks_array_type_info
static ng_newhook_t ng_one2many_newhook
static const struct ng_parse_struct_field ng_one2many_link_stats_type_fields[]
static const struct ng_parse_struct_field ng_one2many_config_type_fields[]
static const struct ng_parse_type ng_one2many_config_type
static ng_shutdown_t ng_one2many_shutdown
static ng_rcvmsg_t ng_one2many_rcvmsg
static ng_rcvdata_t ng_one2many_rcvdata
static ng_disconnect_t ng_one2many_disconnect
static void ng_one2many_update_many(priv_p priv)
static const struct ng_parse_type ng_one2many_link_stats_type
static const struct ng_cmdlist ng_one2many_cmdlist[]
#define NG_ONE2MANY_CONFIG_TYPE_INFO(atype)
#define NG_ONE2MANY_XMIT_ALL
#define NG_ONE2MANY_FAIL_NOTIFY
#define NG_ONE2MANY_HOOK_ONE
#define NG_ONE2MANY_ONE_LINKNUM
#define NG_ONE2MANY_XMIT_ROUNDROBIN
#define NG_ONE2MANY_LINK_STATS_TYPE_INFO
#define NG_ONE2MANY_MAX_LINKS
#define NG_ONE2MANY_FAIL_MANUAL
#define NG_ONE2MANY_XMIT_FAILOVER
#define NGM_ONE2MANY_COOKIE
#define NG_ONE2MANY_NODE_TYPE
#define NG_ONE2MANY_HOOK_MANY_PREFIX
@ NGM_ONE2MANY_SET_CONFIG
@ NGM_ONE2MANY_GET_CONFIG
@ NGM_ONE2MANY_GETCLR_STATS
const struct ng_parse_type ng_parse_int32_type
const struct ng_parse_type ng_parse_fixedarray_type
const struct ng_parse_type ng_parse_struct_type
const struct ng_parse_type ng_parse_uint8_type
struct ng_mesg::ng_msghdr header
u_char enabledLinks[NG_ONE2MANY_MAX_LINKS]
struct ng_one2many_link_stats stats
struct ng_one2many_link one
u_int16_t activeMany[NG_ONE2MANY_MAX_LINKS]
struct ng_one2many_link many[NG_ONE2MANY_MAX_LINKS]
struct ng_one2many_config conf