Changeset View
Changeset View
Standalone View
Standalone View
sys/netgraph/ng_base.c
Show First 20 Lines • Show All 2,766 Lines • ▼ Show 20 Lines | LIST_FOREACH(type, &ng_typelist, types) { | ||||
tl->numtypes++; | tl->numtypes++; | ||||
} | } | ||||
TYPELIST_RUNLOCK(); | TYPELIST_RUNLOCK(); | ||||
break; | break; | ||||
} | } | ||||
case NGM_BINARY2ASCII: | case NGM_BINARY2ASCII: | ||||
{ | { | ||||
int bufSize = 20 * 1024; /* XXX hard coded constant */ | int bufSize = 1024; | ||||
afedorov: Do you really think that this is enough for almost all normal cases?
It seems that, only… | |||||
donnerAuthorUnsubmitted Done Inline ActionsI tried it with a network for A10NSP termination incl. a (netgraph emulated) testbed for 12 double-tagged 10G-lines holding 400 CPEs with two vlans each. Type name Number of living nodes --------- ---------------------- car 429 patch 12 tag 13 one2many 13 bridge 2 bpf 1 tee 13 vlan_rotate 1 vlan 545 eiface 962 socket 2 Each bridge node holds about 430 connections. I had not a single buffer expansion request during setup and debugging. Only "msg bridge: gettable" needs a buffer size of >1M. So I'm pretty sure, that the 1k limit is sufficient for most use cases. Let's conserve kernel memory. donner: I tried it with a network for A10NSP termination incl. a (netgraph emulated) testbed for 12… | |||||
donnerAuthorUnsubmitted Done Inline Actions40 CPEs. My fault. donner: 40 CPEs. My fault. | |||||
const struct ng_parse_type *argstype; | const struct ng_parse_type *argstype; | ||||
const struct ng_cmdlist *c; | const struct ng_cmdlist *c; | ||||
struct ng_mesg *binary, *ascii; | struct ng_mesg *binary, *ascii; | ||||
/* Data area must contain a valid netgraph message */ | /* Data area must contain a valid netgraph message */ | ||||
binary = (struct ng_mesg *)msg->data; | binary = (struct ng_mesg *)msg->data; | ||||
if (msg->header.arglen < sizeof(struct ng_mesg) || | if (msg->header.arglen < sizeof(struct ng_mesg) || | ||||
(msg->header.arglen - sizeof(struct ng_mesg) < | (msg->header.arglen - sizeof(struct ng_mesg) < | ||||
binary->header.arglen)) { | binary->header.arglen)) { | ||||
TRAP_ERROR(); | TRAP_ERROR(); | ||||
error = EINVAL; | error = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
retry_b2a: | |||||
/* Get a response message with lots of room */ | /* Get a response message with lots of room */ | ||||
NG_MKRESPONSE(resp, msg, sizeof(*ascii) + bufSize, M_NOWAIT); | NG_MKRESPONSE(resp, msg, sizeof(*ascii) + bufSize, M_NOWAIT); | ||||
if (resp == NULL) { | if (resp == NULL) { | ||||
error = ENOMEM; | error = ENOMEM; | ||||
break; | break; | ||||
} | } | ||||
ascii = (struct ng_mesg *)resp->data; | ascii = (struct ng_mesg *)resp->data; | ||||
Show All 25 Lines | snprintf(ascii->header.cmdstr, sizeof(ascii->header.cmdstr), | ||||
"%s", c->name); | "%s", c->name); | ||||
/* Convert command arguments to ASCII */ | /* Convert command arguments to ASCII */ | ||||
argstype = (binary->header.flags & NGF_RESP) ? | argstype = (binary->header.flags & NGF_RESP) ? | ||||
c->respType : c->mesgType; | c->respType : c->mesgType; | ||||
if (argstype == NULL) { | if (argstype == NULL) { | ||||
*ascii->data = '\0'; | *ascii->data = '\0'; | ||||
} else { | } else { | ||||
if ((error = ng_unparse(argstype, | error = ng_unparse(argstype, (u_char *)binary->data, | ||||
(u_char *)binary->data, | ascii->data, bufSize); | ||||
ascii->data, bufSize)) != 0) { | if (error == ERANGE) { | ||||
NG_FREE_MSG(resp); | |||||
bufSize *= 2; | |||||
goto retry_b2a; | |||||
} else if (error) { | |||||
NG_FREE_MSG(resp); | NG_FREE_MSG(resp); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* Return the result as struct ng_mesg plus ASCII string */ | /* Return the result as struct ng_mesg plus ASCII string */ | ||||
bufSize = strlen(ascii->data) + 1; | bufSize = strlen(ascii->data) + 1; | ||||
ascii->header.arglen = bufSize; | ascii->header.arglen = bufSize; | ||||
▲ Show 20 Lines • Show All 1,016 Lines • Show Last 20 Lines |
Do you really think that this is enough for almost all normal cases?
It seems that, only ng_bridge getstats return 80+ bytes per link.