summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_tee.c
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2000-08-10 22:52:40 +0000
committerarchie <archie@FreeBSD.org>2000-08-10 22:52:40 +0000
commit6c05154b7af6c0f9f67f10fa34be1aab93ca1793 (patch)
tree0da688b97eeab6caef1530fa6010ca7a35343068 /sys/netgraph/ng_tee.c
parent7ef7c5b0424a7a834fd168e7a662fd04c2a49937 (diff)
downloadFreeBSD-src-6c05154b7af6c0f9f67f10fa34be1aab93ca1793.zip
FreeBSD-src-6c05154b7af6c0f9f67f10fa34be1aab93ca1793.tar.gz
Add new control message to atomically get and clear statistics.
Diffstat (limited to 'sys/netgraph/ng_tee.c')
-rw-r--r--sys/netgraph/ng_tee.c61
1 files changed, 37 insertions, 24 deletions
diff --git a/sys/netgraph/ng_tee.c b/sys/netgraph/ng_tee.c
index 1553c60..68dd2fe 100644
--- a/sys/netgraph/ng_tee.c
+++ b/sys/netgraph/ng_tee.c
@@ -116,6 +116,13 @@ static const struct ng_cmdlist ng_tee_cmds[] = {
NULL,
NULL
},
+ {
+ NGM_TEE_COOKIE,
+ NGM_TEE_GETCLR_STATS,
+ "getclrstats",
+ NULL,
+ &ng_tee_stats_type
+ },
{ 0 }
};
@@ -204,34 +211,40 @@ ngt_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
case NGM_TEE_COOKIE:
switch (msg->header.cmd) {
case NGM_TEE_GET_STATS:
- {
+ case NGM_TEE_CLR_STATS:
+ case NGM_TEE_GETCLR_STATS:
+ {
struct ng_tee_stats *stats;
- NG_MKRESPONSE(resp, msg,
- sizeof(struct ng_tee_stats), M_NOWAIT);
- if (resp == NULL) {
- error = ENOMEM;
- goto done;
+ if (msg->header.cmd != NGM_TEE_CLR_STATS) {
+ NG_MKRESPONSE(resp, msg,
+ sizeof(*stats), M_NOWAIT);
+ if (resp == NULL) {
+ error = ENOMEM;
+ goto done;
+ }
+ stats = (struct ng_tee_stats *)resp->data;
+ bcopy(&sc->right.stats, &stats->right,
+ sizeof(stats->right));
+ bcopy(&sc->left.stats, &stats->left,
+ sizeof(stats->left));
+ bcopy(&sc->right2left.stats, &stats->right2left,
+ sizeof(stats->right2left));
+ bcopy(&sc->left2right.stats, &stats->left2right,
+ sizeof(stats->left2right));
+ }
+ if (msg->header.cmd != NGM_TEE_GET_STATS) {
+ bzero(&sc->right.stats,
+ sizeof(sc->right.stats));
+ bzero(&sc->left.stats,
+ sizeof(sc->left.stats));
+ bzero(&sc->right2left.stats,
+ sizeof(sc->right2left.stats));
+ bzero(&sc->left2right.stats,
+ sizeof(sc->left2right.stats));
}
- stats = (struct ng_tee_stats *) resp->data;
- bcopy(&sc->right.stats,
- &stats->right, sizeof(stats->right));
- bcopy(&sc->left.stats,
- &stats->left, sizeof(stats->left));
- bcopy(&sc->right2left.stats,
- &stats->right2left, sizeof(stats->right2left));
- bcopy(&sc->left2right.stats,
- &stats->left2right, sizeof(stats->left2right));
- break;
+ break;
}
- case NGM_TEE_CLR_STATS:
- bzero(&sc->right.stats, sizeof(sc->right.stats));
- bzero(&sc->left.stats, sizeof(sc->left.stats));
- bzero(&sc->right2left.stats,
- sizeof(sc->right2left.stats));
- bzero(&sc->left2right.stats,
- sizeof(sc->left2right.stats));
- break;
default:
error = EINVAL;
break;
OpenPOWER on IntegriCloud