mirror of
https://github.com/OISF/suricata.git
synced 2026-10-11 22:09:53 +00:00
counters: move regular counter id to dedicated type
This commit is contained in:
@@ -43,8 +43,8 @@
|
||||
* the adapter.
|
||||
*/
|
||||
typedef struct FlowStatsCounters_ {
|
||||
uint16_t active_bypass_flows;
|
||||
uint16_t total_bypass_flows;
|
||||
StatsCounterId active_bypass_flows;
|
||||
StatsCounterId total_bypass_flows;
|
||||
} FlowStatsCounters;
|
||||
|
||||
static int bypass_supported;
|
||||
|
||||
@@ -86,9 +86,9 @@ struct PfringThreadVars_ {
|
||||
uint64_t bytes;
|
||||
uint64_t pkts;
|
||||
|
||||
uint16_t capture_kernel_packets;
|
||||
uint16_t capture_kernel_drops;
|
||||
uint16_t capture_bypassed;
|
||||
StatsCounterId capture_kernel_packets;
|
||||
StatsCounterId capture_kernel_drops;
|
||||
StatsCounterId capture_bypassed;
|
||||
|
||||
uint32_t flags;
|
||||
|
||||
|
||||
+22
-22
@@ -87,12 +87,12 @@ typedef struct AppLayerCounterNames_ {
|
||||
} AppLayerCounterNames;
|
||||
|
||||
typedef struct AppLayerCounters_ {
|
||||
uint16_t counter_id;
|
||||
uint16_t counter_tx_id;
|
||||
uint16_t gap_error_id;
|
||||
uint16_t parser_error_id;
|
||||
uint16_t internal_error_id;
|
||||
uint16_t alloc_error_id;
|
||||
StatsCounterId counter_id;
|
||||
StatsCounterId counter_tx_id;
|
||||
StatsCounterId gap_error_id;
|
||||
StatsCounterId parser_error_id;
|
||||
StatsCounterId internal_error_id;
|
||||
StatsCounterId alloc_error_id;
|
||||
ExceptionPolicyCounters eps_error;
|
||||
} AppLayerCounters;
|
||||
|
||||
@@ -148,48 +148,48 @@ static inline int ProtoDetectDone(const Flow *f, const TcpSession *ssn, uint8_t
|
||||
*/
|
||||
static void AppLayerIncFlowCounter(ThreadVars *tv, Flow *f)
|
||||
{
|
||||
const uint16_t id = applayer_counters[f->alproto][f->protomap].counter_id;
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = applayer_counters[f->alproto][f->protomap].counter_id;
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
void AppLayerIncTxCounter(ThreadVars *tv, Flow *f, uint64_t step)
|
||||
{
|
||||
const uint16_t id = applayer_counters[f->alproto][f->protomap].counter_tx_id;
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = applayer_counters[f->alproto][f->protomap].counter_tx_id;
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsAddUI64(tv, id, step);
|
||||
}
|
||||
}
|
||||
|
||||
void AppLayerIncGapErrorCounter(ThreadVars *tv, Flow *f)
|
||||
{
|
||||
const uint16_t id = applayer_counters[f->alproto][f->protomap].gap_error_id;
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = applayer_counters[f->alproto][f->protomap].gap_error_id;
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
void AppLayerIncAllocErrorCounter(ThreadVars *tv, Flow *f)
|
||||
{
|
||||
const uint16_t id = applayer_counters[f->alproto][f->protomap].alloc_error_id;
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = applayer_counters[f->alproto][f->protomap].alloc_error_id;
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
void AppLayerIncParserErrorCounter(ThreadVars *tv, Flow *f)
|
||||
{
|
||||
const uint16_t id = applayer_counters[f->alproto][f->protomap].parser_error_id;
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = applayer_counters[f->alproto][f->protomap].parser_error_id;
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
void AppLayerIncInternalErrorCounter(ThreadVars *tv, Flow *f)
|
||||
{
|
||||
const uint16_t id = applayer_counters[f->alproto][f->protomap].internal_error_id;
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = applayer_counters[f->alproto][f->protomap].internal_error_id;
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
@@ -201,14 +201,14 @@ static void AppLayerIncrErrorExcPolicyCounter(ThreadVars *tv, Flow *f, enum Exce
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
uint16_t id = applayer_counters[f->alproto][f->protomap].eps_error.eps_id[policy];
|
||||
StatsCounterId id = applayer_counters[f->alproto][f->protomap].eps_error.eps_id[policy];
|
||||
/* for the summary values */
|
||||
uint16_t g_id = eps_error_summary.eps_id[policy];
|
||||
StatsCounterId g_id = eps_error_summary.eps_id[policy];
|
||||
|
||||
if (likely(id > 0)) {
|
||||
if (likely(id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
if (likely(g_id > 0)) {
|
||||
if (likely(g_id.id > 0)) {
|
||||
StatsIncr(tv, g_id);
|
||||
}
|
||||
}
|
||||
|
||||
+80
-114
@@ -143,7 +143,7 @@ static void StatsPublicThreadContextCleanup(StatsPublicThreadContext *t)
|
||||
* \param pca Counter array that holds the local counter for this TM
|
||||
* \param x Value to add to this local counter
|
||||
*/
|
||||
void StatsAddUI64(ThreadVars *tv, uint16_t id, uint64_t x)
|
||||
void StatsAddUI64(ThreadVars *tv, StatsCounterId id, uint64_t x)
|
||||
{
|
||||
StatsPrivateThreadContext *pca = &tv->perf_private_ctx;
|
||||
#if defined (UNITTESTS) || defined (FUZZ)
|
||||
@@ -151,9 +151,9 @@ void StatsAddUI64(ThreadVars *tv, uint16_t id, uint64_t x)
|
||||
return;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
BUG_ON ((id < 1) || (id > pca->size));
|
||||
BUG_ON((id.id < 1) || (id.id > pca->size));
|
||||
#endif
|
||||
pca->head[id].value += x;
|
||||
pca->head[id.id].value += x;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,7 @@ void StatsAddUI64(ThreadVars *tv, uint16_t id, uint64_t x)
|
||||
* \param id Index of the counter in the counter array
|
||||
* \param pca Counter array that holds the local counters for this TM
|
||||
*/
|
||||
void StatsIncr(ThreadVars *tv, uint16_t id)
|
||||
void StatsIncr(ThreadVars *tv, StatsCounterId id)
|
||||
{
|
||||
StatsPrivateThreadContext *pca = &tv->perf_private_ctx;
|
||||
#if defined (UNITTESTS) || defined (FUZZ)
|
||||
@@ -170,9 +170,9 @@ void StatsIncr(ThreadVars *tv, uint16_t id)
|
||||
return;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
BUG_ON ((id < 1) || (id > pca->size));
|
||||
BUG_ON((id.id < 1) || (id.id > pca->size));
|
||||
#endif
|
||||
pca->head[id].value++;
|
||||
pca->head[id.id].value++;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ void StatsIncr(ThreadVars *tv, uint16_t id)
|
||||
* \param id Index of the counter in the counter array
|
||||
* \param pca Counter array that holds the local counters for this TM
|
||||
*/
|
||||
void StatsDecr(ThreadVars *tv, uint16_t id)
|
||||
void StatsDecr(ThreadVars *tv, StatsCounterId id)
|
||||
{
|
||||
StatsPrivateThreadContext *pca = &tv->perf_private_ctx;
|
||||
#if defined(UNITTESTS) || defined(FUZZ)
|
||||
@@ -189,9 +189,9 @@ void StatsDecr(ThreadVars *tv, uint16_t id)
|
||||
return;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
BUG_ON((id < 1) || (id > pca->size));
|
||||
BUG_ON((id.id < 1) || (id.id > pca->size));
|
||||
#endif
|
||||
pca->head[id].value--;
|
||||
pca->head[id.id].value--;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +201,7 @@ void StatsDecr(ThreadVars *tv, uint16_t id)
|
||||
* \param pca Pointer to the StatsPrivateThreadContext
|
||||
* \param x The value to set for the counter
|
||||
*/
|
||||
void StatsSetUI64(ThreadVars *tv, uint16_t id, uint64_t x)
|
||||
void StatsSetUI64(ThreadVars *tv, StatsCounterId id, uint64_t x)
|
||||
{
|
||||
StatsPrivateThreadContext *pca = &tv->perf_private_ctx;
|
||||
#if defined (UNITTESTS) || defined (FUZZ)
|
||||
@@ -209,9 +209,9 @@ void StatsSetUI64(ThreadVars *tv, uint16_t id, uint64_t x)
|
||||
return;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
BUG_ON ((id < 1) || (id > pca->size));
|
||||
BUG_ON((id.id < 1) || (id.id > pca->size));
|
||||
#endif
|
||||
pca->head[id].value = x;
|
||||
pca->head[id.id].value = x;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -992,13 +992,14 @@ void StatsSpawnThreads(void)
|
||||
* \retval id Counter id for the newly registered counter, or the already
|
||||
* present counter
|
||||
*/
|
||||
uint16_t StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
|
||||
StatsCounterId StatsRegisterCounter(const char *name, struct ThreadVars_ *tv)
|
||||
{
|
||||
uint16_t id = StatsRegisterQualifiedCounter(name,
|
||||
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->printable_name,
|
||||
&tv->perf_public_ctx,
|
||||
STATS_TYPE_NORMAL, NULL);
|
||||
return id;
|
||||
StatsCounterId s = { .id = id };
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1298,13 +1299,13 @@ int StatsUpdateCounterArray(StatsPrivateThreadContext *pca, StatsPublicThreadCon
|
||||
* \retval 0 on success.
|
||||
* \retval -1 on error.
|
||||
*/
|
||||
uint64_t StatsGetLocalCounterValue(ThreadVars *tv, uint16_t id)
|
||||
uint64_t StatsGetLocalCounterValue(ThreadVars *tv, StatsCounterId id)
|
||||
{
|
||||
StatsPrivateThreadContext *pca = &tv->perf_private_ctx;
|
||||
#ifdef DEBUG
|
||||
BUG_ON ((id < 1) || (id > pca->size));
|
||||
BUG_ON((id.id < 1) || (id.id > pca->size));
|
||||
#endif
|
||||
return pca->head[id].value;
|
||||
return pca->head[id.id].value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1373,56 +1374,52 @@ void StatsThreadCleanup(ThreadVars *tv)
|
||||
* \retval id Counter id for the newly registered counter, or the already
|
||||
* present counter
|
||||
*/
|
||||
static uint16_t RegisterCounter(const char *name, const char *tm_name,
|
||||
StatsPublicThreadContext *pctx)
|
||||
static StatsCounterId RegisterCounter(
|
||||
const char *name, const char *tm_name, StatsPublicThreadContext *pctx)
|
||||
{
|
||||
uint16_t id = StatsRegisterQualifiedCounter(name, tm_name, pctx,
|
||||
STATS_TYPE_NORMAL, NULL);
|
||||
return id;
|
||||
StatsCounterId s = { .id = id };
|
||||
return s;
|
||||
}
|
||||
|
||||
static int StatsTestCounterReg02(void)
|
||||
{
|
||||
StatsPublicThreadContext pctx;
|
||||
|
||||
memset(&pctx, 0, sizeof(StatsPublicThreadContext));
|
||||
|
||||
return RegisterCounter(NULL, NULL, &pctx) == 0;
|
||||
StatsCounterId id = RegisterCounter(NULL, NULL, &pctx);
|
||||
FAIL_IF_NOT(id.id == 0);
|
||||
PASS;
|
||||
}
|
||||
|
||||
static int StatsTestCounterReg03(void)
|
||||
{
|
||||
StatsPublicThreadContext pctx;
|
||||
int result;
|
||||
|
||||
memset(&pctx, 0, sizeof(StatsPublicThreadContext));
|
||||
|
||||
result = RegisterCounter("t1", "c1", &pctx);
|
||||
|
||||
FAIL_IF_NOT(result);
|
||||
StatsCounterId id = RegisterCounter("t1", "c1", &pctx);
|
||||
FAIL_IF_NOT(id.id == 1);
|
||||
|
||||
StatsReleaseCounters(pctx.head);
|
||||
|
||||
PASS;
|
||||
}
|
||||
|
||||
static int StatsTestCounterReg04(void)
|
||||
{
|
||||
StatsPublicThreadContext pctx;
|
||||
int result;
|
||||
|
||||
memset(&pctx, 0, sizeof(StatsPublicThreadContext));
|
||||
|
||||
RegisterCounter("t1", "c1", &pctx);
|
||||
RegisterCounter("t2", "c2", &pctx);
|
||||
RegisterCounter("t3", "c3", &pctx);
|
||||
|
||||
result = RegisterCounter("t1", "c1", &pctx);
|
||||
|
||||
FAIL_IF_NOT(result);
|
||||
StatsCounterId c1 = RegisterCounter("t1", "c1", &pctx);
|
||||
FAIL_IF_NOT(c1.id == 1);
|
||||
StatsCounterId c2 = RegisterCounter("t2", "c2", &pctx);
|
||||
FAIL_IF_NOT(c2.id == 2);
|
||||
StatsCounterId c3 = RegisterCounter("t3", "c3", &pctx);
|
||||
FAIL_IF_NOT(c3.id == 3);
|
||||
StatsCounterId id = RegisterCounter("t1", "c1", &pctx);
|
||||
FAIL_IF_NOT(id.id == 1);
|
||||
|
||||
StatsReleaseCounters(pctx.head);
|
||||
|
||||
PASS;
|
||||
}
|
||||
|
||||
@@ -1430,8 +1427,8 @@ static int StatsTestGetCntArray05(void)
|
||||
{
|
||||
ThreadVars tv;
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
int id = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
FAIL_IF(id != 1);
|
||||
StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
FAIL_IF(c1.id != 1);
|
||||
int r = StatsGetAllCountersArray(NULL, &tv.perf_private_ctx);
|
||||
FAIL_IF_NOT(r == -1);
|
||||
StatsReleaseCounters(tv.perf_public_ctx.head);
|
||||
@@ -1442,39 +1439,30 @@ static int StatsTestGetCntArray05(void)
|
||||
static int StatsTestGetCntArray06(void)
|
||||
{
|
||||
ThreadVars tv;
|
||||
int id;
|
||||
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
|
||||
id = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
FAIL_IF(id != 1);
|
||||
|
||||
StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
FAIL_IF(c1.id != 1);
|
||||
int r = StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
|
||||
FAIL_IF_NOT(r == 0);
|
||||
|
||||
StatsReleaseCounters(tv.perf_public_ctx.head);
|
||||
StatsReleasePrivateThreadContext(&tv.perf_private_ctx);
|
||||
|
||||
PASS;
|
||||
}
|
||||
|
||||
static int StatsTestCntArraySize07(void)
|
||||
{
|
||||
ThreadVars tv;
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
StatsPrivateThreadContext *pca = NULL;
|
||||
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
|
||||
//pca = (StatsPrivateThreadContext *)&tv.perf_private_ctx;
|
||||
|
||||
RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
RegisterCounter("t2", "c2", &tv.perf_public_ctx);
|
||||
StatsCounterId id1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
StatsCounterId id2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx);
|
||||
|
||||
StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
|
||||
pca = &tv.perf_private_ctx;
|
||||
|
||||
StatsIncr(&tv, 1);
|
||||
StatsIncr(&tv, 2);
|
||||
StatsIncr(&tv, id1);
|
||||
StatsIncr(&tv, id2);
|
||||
|
||||
FAIL_IF_NOT(pca->size == 2);
|
||||
|
||||
@@ -1487,48 +1475,39 @@ static int StatsTestCntArraySize07(void)
|
||||
static int StatsTestUpdateCounter08(void)
|
||||
{
|
||||
ThreadVars tv;
|
||||
StatsPrivateThreadContext *pca = NULL;
|
||||
int id;
|
||||
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
|
||||
id = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
|
||||
StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
|
||||
pca = &tv.perf_private_ctx;
|
||||
StatsPrivateThreadContext *pca = &tv.perf_private_ctx;
|
||||
|
||||
StatsIncr(&tv, id);
|
||||
StatsAddUI64(&tv, id, 100);
|
||||
|
||||
FAIL_IF_NOT(pca->head[id].value == 101);
|
||||
StatsIncr(&tv, c1);
|
||||
StatsAddUI64(&tv, c1, 100);
|
||||
FAIL_IF_NOT(pca->head[c1.id].value == 101);
|
||||
|
||||
StatsReleaseCounters(tv.perf_public_ctx.head);
|
||||
StatsReleasePrivateThreadContext(pca);
|
||||
|
||||
PASS;
|
||||
}
|
||||
|
||||
static int StatsTestUpdateCounter09(void)
|
||||
{
|
||||
ThreadVars tv;
|
||||
StatsPrivateThreadContext *pca = NULL;
|
||||
uint16_t id1, id2;
|
||||
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
|
||||
id1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
RegisterCounter("t2", "c2", &tv.perf_public_ctx);
|
||||
RegisterCounter("t3", "c3", &tv.perf_public_ctx);
|
||||
RegisterCounter("t4", "c4", &tv.perf_public_ctx);
|
||||
id2 = RegisterCounter("t5", "c5", &tv.perf_public_ctx);
|
||||
StatsCounterId c5 = RegisterCounter("t5", "c5", &tv.perf_public_ctx);
|
||||
|
||||
StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
|
||||
pca = &tv.perf_private_ctx;
|
||||
StatsPrivateThreadContext *pca = &tv.perf_private_ctx;
|
||||
|
||||
StatsIncr(&tv, id2);
|
||||
StatsAddUI64(&tv, id2, 100);
|
||||
StatsIncr(&tv, c5);
|
||||
StatsAddUI64(&tv, c5, 100);
|
||||
|
||||
FAIL_IF_NOT((pca->head[id1].value == 0) && (pca->head[id2].value == 101));
|
||||
FAIL_IF_NOT(pca->head[c1.id].value == 0);
|
||||
FAIL_IF_NOT(pca->head[c5.id].value == 101);
|
||||
|
||||
StatsReleaseCounters(tv.perf_public_ctx.head);
|
||||
StatsReleasePrivateThreadContext(pca);
|
||||
@@ -1539,31 +1518,25 @@ static int StatsTestUpdateCounter09(void)
|
||||
static int StatsTestUpdateGlobalCounter10(void)
|
||||
{
|
||||
ThreadVars tv;
|
||||
StatsPrivateThreadContext *pca = NULL;
|
||||
|
||||
int result = 1;
|
||||
uint16_t id1, id2, id3;
|
||||
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
|
||||
id1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
id2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx);
|
||||
id3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx);
|
||||
StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
StatsCounterId c2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx);
|
||||
StatsCounterId c3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx);
|
||||
|
||||
StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
|
||||
pca = &tv.perf_private_ctx;
|
||||
StatsPrivateThreadContext *pca = &tv.perf_private_ctx;
|
||||
|
||||
StatsIncr(&tv, id1);
|
||||
StatsAddUI64(&tv, id2, 100);
|
||||
StatsIncr(&tv, id3);
|
||||
StatsAddUI64(&tv, id3, 100);
|
||||
StatsIncr(&tv, c1);
|
||||
StatsAddUI64(&tv, c2, 100);
|
||||
StatsIncr(&tv, c3);
|
||||
StatsAddUI64(&tv, c3, 100);
|
||||
|
||||
StatsUpdateCounterArray(pca, &tv.perf_public_ctx);
|
||||
|
||||
result = (1 == tv.perf_public_ctx.head->value);
|
||||
result &= (100 == tv.perf_public_ctx.head->next->value);
|
||||
result &= (101 == tv.perf_public_ctx.head->next->next->value);
|
||||
FAIL_IF_NOT(result);
|
||||
FAIL_IF_NOT(1 == tv.perf_public_ctx.head->value);
|
||||
FAIL_IF_NOT(100 == tv.perf_public_ctx.head->next->value);
|
||||
FAIL_IF_NOT(101 == tv.perf_public_ctx.head->next->next->value);
|
||||
|
||||
StatsReleaseCounters(tv.perf_public_ctx.head);
|
||||
StatsReleasePrivateThreadContext(pca);
|
||||
@@ -1574,37 +1547,30 @@ static int StatsTestUpdateGlobalCounter10(void)
|
||||
static int StatsTestCounterValues11(void)
|
||||
{
|
||||
ThreadVars tv;
|
||||
StatsPrivateThreadContext *pca = NULL;
|
||||
|
||||
int result = 1;
|
||||
uint16_t id1, id2, id3, id4;
|
||||
|
||||
memset(&tv, 0, sizeof(ThreadVars));
|
||||
|
||||
id1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
id2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx);
|
||||
id3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx);
|
||||
id4 = RegisterCounter("t4", "c4", &tv.perf_public_ctx);
|
||||
StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
|
||||
StatsCounterId c2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx);
|
||||
StatsCounterId c3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx);
|
||||
StatsCounterId c4 = RegisterCounter("t4", "c4", &tv.perf_public_ctx);
|
||||
|
||||
StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
|
||||
pca = &tv.perf_private_ctx;
|
||||
StatsPrivateThreadContext *pca = &tv.perf_private_ctx;
|
||||
|
||||
StatsIncr(&tv, id1);
|
||||
StatsAddUI64(&tv, id2, 256);
|
||||
StatsAddUI64(&tv, id3, 257);
|
||||
StatsAddUI64(&tv, id4, 16843024);
|
||||
StatsIncr(&tv, c1);
|
||||
StatsAddUI64(&tv, c2, 256);
|
||||
StatsAddUI64(&tv, c3, 257);
|
||||
StatsAddUI64(&tv, c4, 16843024);
|
||||
|
||||
StatsUpdateCounterArray(pca, &tv.perf_public_ctx);
|
||||
|
||||
result &= (1 == tv.perf_public_ctx.head->value);
|
||||
result &= (256 == tv.perf_public_ctx.head->next->value);
|
||||
result &= (257 == tv.perf_public_ctx.head->next->next->value);
|
||||
result &= (16843024 == tv.perf_public_ctx.head->next->next->next->value);
|
||||
FAIL_IF_NOT(result);
|
||||
FAIL_IF_NOT(1 == tv.perf_public_ctx.head->value);
|
||||
FAIL_IF_NOT(256 == tv.perf_public_ctx.head->next->value);
|
||||
FAIL_IF_NOT(257 == tv.perf_public_ctx.head->next->next->value);
|
||||
FAIL_IF_NOT(16843024 == tv.perf_public_ctx.head->next->next->next->value);
|
||||
|
||||
StatsReleaseCounters(tv.perf_public_ctx.head);
|
||||
StatsReleasePrivateThreadContext(pca);
|
||||
|
||||
PASS;
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -30,6 +30,10 @@
|
||||
/* forward declaration of the ThreadVars structure */
|
||||
struct ThreadVars_;
|
||||
|
||||
typedef struct StatsCounterId {
|
||||
uint16_t id;
|
||||
} StatsCounterId;
|
||||
|
||||
typedef struct StatsCounterAvgId {
|
||||
uint16_t id;
|
||||
} StatsCounterAvgId;
|
||||
@@ -127,23 +131,23 @@ bool StatsEnabled(void);
|
||||
void StatsReleaseResources(void);
|
||||
|
||||
/* counter registration functions */
|
||||
uint16_t StatsRegisterCounter(const char *, struct ThreadVars_ *);
|
||||
StatsCounterId StatsRegisterCounter(const char *, struct ThreadVars_ *);
|
||||
StatsCounterAvgId StatsRegisterAvgCounter(const char *, struct ThreadVars_ *);
|
||||
StatsCounterMaxId StatsRegisterMaxCounter(const char *, struct ThreadVars_ *);
|
||||
StatsCounterGlobalId StatsRegisterGlobalCounter(const char *cname, uint64_t (*Func)(void));
|
||||
|
||||
/* functions used to update local counter values */
|
||||
void StatsAddUI64(struct ThreadVars_ *, uint16_t, uint64_t);
|
||||
void StatsSetUI64(struct ThreadVars_ *, uint16_t, uint64_t);
|
||||
void StatsIncr(struct ThreadVars_ *, uint16_t);
|
||||
void StatsDecr(struct ThreadVars_ *, uint16_t);
|
||||
void StatsAddUI64(struct ThreadVars_ *, StatsCounterId, uint64_t);
|
||||
void StatsSetUI64(struct ThreadVars_ *, StatsCounterId, uint64_t);
|
||||
void StatsIncr(struct ThreadVars_ *, StatsCounterId);
|
||||
void StatsDecr(struct ThreadVars_ *, StatsCounterId);
|
||||
|
||||
void StatsCounterMaxUpdateI64(struct ThreadVars_ *tv, StatsCounterMaxId id, int64_t x);
|
||||
void StatsCounterAvgAddI64(struct ThreadVars_ *tv, StatsCounterAvgId id, int64_t x);
|
||||
|
||||
/* utility functions */
|
||||
int StatsUpdateCounterArray(StatsPrivateThreadContext *, StatsPublicThreadContext *);
|
||||
uint64_t StatsGetLocalCounterValue(struct ThreadVars_ *, uint16_t);
|
||||
uint64_t StatsGetLocalCounterValue(struct ThreadVars_ *, StatsCounterId);
|
||||
int StatsSetupPrivate(struct ThreadVars_ *);
|
||||
void StatsThreadCleanup(struct ThreadVars_ *);
|
||||
|
||||
|
||||
+5
-5
@@ -1006,12 +1006,12 @@ static const char *PacketDropReasonToJsonString(enum PacketDropReason r)
|
||||
}
|
||||
|
||||
typedef struct CaptureStats_ {
|
||||
uint16_t counter_ips_accepted;
|
||||
uint16_t counter_ips_blocked;
|
||||
uint16_t counter_ips_rejected;
|
||||
uint16_t counter_ips_replaced;
|
||||
StatsCounterId counter_ips_accepted;
|
||||
StatsCounterId counter_ips_blocked;
|
||||
StatsCounterId counter_ips_rejected;
|
||||
StatsCounterId counter_ips_replaced;
|
||||
|
||||
uint16_t counter_drop_reason[PKT_DROP_REASON_MAX];
|
||||
StatsCounterId counter_drop_reason[PKT_DROP_REASON_MAX];
|
||||
} CaptureStats;
|
||||
|
||||
thread_local CaptureStats t_capture_stats;
|
||||
|
||||
+70
-70
@@ -965,92 +965,92 @@ typedef struct DecodeThreadVars_
|
||||
AppLayerThreadCtx *app_tctx;
|
||||
|
||||
/** stats/counters */
|
||||
uint16_t counter_pkts;
|
||||
uint16_t counter_bytes;
|
||||
StatsCounterId counter_pkts;
|
||||
StatsCounterId counter_bytes;
|
||||
StatsCounterAvgId counter_avg_pkt_size;
|
||||
StatsCounterMaxId counter_max_pkt_size;
|
||||
StatsCounterMaxId counter_max_mac_addrs_src;
|
||||
StatsCounterMaxId counter_max_mac_addrs_dst;
|
||||
|
||||
uint16_t counter_invalid;
|
||||
StatsCounterId counter_invalid;
|
||||
|
||||
uint16_t counter_eth;
|
||||
uint16_t counter_chdlc;
|
||||
uint16_t counter_ipv4;
|
||||
uint16_t counter_ipv6;
|
||||
uint16_t counter_tcp;
|
||||
uint16_t counter_tcp_syn;
|
||||
uint16_t counter_tcp_synack;
|
||||
uint16_t counter_tcp_rst;
|
||||
uint16_t counter_tcp_urg;
|
||||
uint16_t counter_udp;
|
||||
uint16_t counter_icmpv4;
|
||||
uint16_t counter_icmpv6;
|
||||
uint16_t counter_arp;
|
||||
uint16_t counter_ethertype_unknown;
|
||||
StatsCounterId counter_eth;
|
||||
StatsCounterId counter_chdlc;
|
||||
StatsCounterId counter_ipv4;
|
||||
StatsCounterId counter_ipv6;
|
||||
StatsCounterId counter_tcp;
|
||||
StatsCounterId counter_tcp_syn;
|
||||
StatsCounterId counter_tcp_synack;
|
||||
StatsCounterId counter_tcp_rst;
|
||||
StatsCounterId counter_tcp_urg;
|
||||
StatsCounterId counter_udp;
|
||||
StatsCounterId counter_icmpv4;
|
||||
StatsCounterId counter_icmpv6;
|
||||
StatsCounterId counter_arp;
|
||||
StatsCounterId counter_ethertype_unknown;
|
||||
|
||||
uint16_t counter_sll;
|
||||
uint16_t counter_sll2;
|
||||
uint16_t counter_raw;
|
||||
uint16_t counter_null;
|
||||
uint16_t counter_sctp;
|
||||
uint16_t counter_esp;
|
||||
uint16_t counter_ppp;
|
||||
uint16_t counter_geneve;
|
||||
uint16_t counter_gre;
|
||||
uint16_t counter_vlan;
|
||||
uint16_t counter_vlan_qinq;
|
||||
uint16_t counter_vlan_qinqinq;
|
||||
uint16_t counter_vxlan;
|
||||
uint16_t counter_vntag;
|
||||
uint16_t counter_etag;
|
||||
uint16_t counter_ieee8021ah;
|
||||
uint16_t counter_pppoe;
|
||||
uint16_t counter_teredo;
|
||||
uint16_t counter_mpls;
|
||||
uint16_t counter_ipv4inipv4;
|
||||
uint16_t counter_ipv6inipv4;
|
||||
uint16_t counter_ipv4inipv6;
|
||||
uint16_t counter_ipv6inipv6;
|
||||
uint16_t counter_erspan;
|
||||
uint16_t counter_nsh;
|
||||
StatsCounterId counter_sll;
|
||||
StatsCounterId counter_sll2;
|
||||
StatsCounterId counter_raw;
|
||||
StatsCounterId counter_null;
|
||||
StatsCounterId counter_sctp;
|
||||
StatsCounterId counter_esp;
|
||||
StatsCounterId counter_ppp;
|
||||
StatsCounterId counter_geneve;
|
||||
StatsCounterId counter_gre;
|
||||
StatsCounterId counter_vlan;
|
||||
StatsCounterId counter_vlan_qinq;
|
||||
StatsCounterId counter_vlan_qinqinq;
|
||||
StatsCounterId counter_vxlan;
|
||||
StatsCounterId counter_vntag;
|
||||
StatsCounterId counter_etag;
|
||||
StatsCounterId counter_ieee8021ah;
|
||||
StatsCounterId counter_pppoe;
|
||||
StatsCounterId counter_teredo;
|
||||
StatsCounterId counter_mpls;
|
||||
StatsCounterId counter_ipv4inipv4;
|
||||
StatsCounterId counter_ipv6inipv4;
|
||||
StatsCounterId counter_ipv4inipv6;
|
||||
StatsCounterId counter_ipv6inipv6;
|
||||
StatsCounterId counter_erspan;
|
||||
StatsCounterId counter_nsh;
|
||||
|
||||
/** frag stats - defrag runs in the context of the decoder. */
|
||||
uint16_t counter_defrag_ipv4_fragments;
|
||||
uint16_t counter_defrag_ipv4_reassembled;
|
||||
uint16_t counter_defrag_ipv6_fragments;
|
||||
uint16_t counter_defrag_ipv6_reassembled;
|
||||
uint16_t counter_defrag_max_hit;
|
||||
uint16_t counter_defrag_no_frags;
|
||||
uint16_t counter_defrag_tracker_soft_reuse;
|
||||
uint16_t counter_defrag_tracker_hard_reuse;
|
||||
uint16_t counter_defrag_tracker_timeout;
|
||||
StatsCounterId counter_defrag_ipv4_fragments;
|
||||
StatsCounterId counter_defrag_ipv4_reassembled;
|
||||
StatsCounterId counter_defrag_ipv6_fragments;
|
||||
StatsCounterId counter_defrag_ipv6_reassembled;
|
||||
StatsCounterId counter_defrag_max_hit;
|
||||
StatsCounterId counter_defrag_no_frags;
|
||||
StatsCounterId counter_defrag_tracker_soft_reuse;
|
||||
StatsCounterId counter_defrag_tracker_hard_reuse;
|
||||
StatsCounterId counter_defrag_tracker_timeout;
|
||||
ExceptionPolicyCounters counter_defrag_memcap_eps;
|
||||
|
||||
uint16_t counter_flow_memcap;
|
||||
StatsCounterId counter_flow_memcap;
|
||||
ExceptionPolicyCounters counter_flow_memcap_eps;
|
||||
|
||||
uint16_t counter_tcp_active_sessions;
|
||||
uint16_t counter_flow_total;
|
||||
uint16_t counter_flow_active;
|
||||
uint16_t counter_flow_tcp;
|
||||
uint16_t counter_flow_udp;
|
||||
uint16_t counter_flow_icmp4;
|
||||
uint16_t counter_flow_icmp6;
|
||||
uint16_t counter_flow_tcp_reuse;
|
||||
uint16_t counter_flow_elephant;
|
||||
uint16_t counter_flow_get_used;
|
||||
uint16_t counter_flow_get_used_eval;
|
||||
uint16_t counter_flow_get_used_eval_reject;
|
||||
uint16_t counter_flow_get_used_eval_busy;
|
||||
uint16_t counter_flow_get_used_failed;
|
||||
StatsCounterId counter_tcp_active_sessions;
|
||||
StatsCounterId counter_flow_total;
|
||||
StatsCounterId counter_flow_active;
|
||||
StatsCounterId counter_flow_tcp;
|
||||
StatsCounterId counter_flow_udp;
|
||||
StatsCounterId counter_flow_icmp4;
|
||||
StatsCounterId counter_flow_icmp6;
|
||||
StatsCounterId counter_flow_tcp_reuse;
|
||||
StatsCounterId counter_flow_elephant;
|
||||
StatsCounterId counter_flow_get_used;
|
||||
StatsCounterId counter_flow_get_used_eval;
|
||||
StatsCounterId counter_flow_get_used_eval_reject;
|
||||
StatsCounterId counter_flow_get_used_eval_busy;
|
||||
StatsCounterId counter_flow_get_used_failed;
|
||||
|
||||
uint16_t counter_flow_spare_sync;
|
||||
uint16_t counter_flow_spare_sync_empty;
|
||||
uint16_t counter_flow_spare_sync_incomplete;
|
||||
StatsCounterId counter_flow_spare_sync;
|
||||
StatsCounterId counter_flow_spare_sync_empty;
|
||||
StatsCounterId counter_flow_spare_sync_incomplete;
|
||||
StatsCounterAvgId counter_flow_spare_sync_avg;
|
||||
|
||||
uint16_t counter_engine_events[DECODE_EVENT_MAX];
|
||||
StatsCounterId counter_engine_events[DECODE_EVENT_MAX];
|
||||
|
||||
/* thread data for flow logging api: only used at forced
|
||||
* flow recycle during lookups */
|
||||
|
||||
+2
-2
@@ -452,8 +452,8 @@ static inline int DefragTrackerCompare(DefragTracker *t, Packet *p)
|
||||
static void DefragExceptionPolicyStatsIncr(
|
||||
ThreadVars *tv, DecodeThreadVars *dtv, enum ExceptionPolicy policy)
|
||||
{
|
||||
uint16_t id = dtv->counter_defrag_memcap_eps.eps_id[policy];
|
||||
if (likely(id > 0)) {
|
||||
StatsCounterId id = dtv->counter_defrag_memcap_eps.eps_id[policy];
|
||||
if (likely(id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -1287,11 +1287,11 @@ typedef struct DetectEngineThreadCtx_ {
|
||||
uint16_t filestore_cnt;
|
||||
|
||||
/** id for alert counter */
|
||||
uint16_t counter_alerts;
|
||||
StatsCounterId counter_alerts;
|
||||
/** id for discarded alerts counter */
|
||||
uint16_t counter_alerts_overflow;
|
||||
StatsCounterId counter_alerts_overflow;
|
||||
/** id for suppressed alerts counter */
|
||||
uint16_t counter_alerts_suppressed;
|
||||
StatsCounterId counter_alerts_suppressed;
|
||||
#ifdef PROFILING
|
||||
StatsCounterAvgId counter_mpm_list;
|
||||
StatsCounterAvgId counter_match_list;
|
||||
@@ -1372,16 +1372,16 @@ typedef struct DetectEngineThreadCtx_ {
|
||||
uint16_t events;
|
||||
|
||||
/** stats id for lua rule errors */
|
||||
uint16_t lua_rule_errors;
|
||||
StatsCounterId lua_rule_errors;
|
||||
|
||||
/** stats id for lua blocked function counts */
|
||||
uint16_t lua_blocked_function_errors;
|
||||
StatsCounterId lua_blocked_function_errors;
|
||||
|
||||
/** stats if for lua instruction limit errors */
|
||||
uint16_t lua_instruction_limit_errors;
|
||||
StatsCounterId lua_instruction_limit_errors;
|
||||
|
||||
/** stat of lua memory limit errors. */
|
||||
uint16_t lua_memory_limit_errors;
|
||||
StatsCounterId lua_memory_limit_errors;
|
||||
|
||||
#ifdef DEBUG
|
||||
uint64_t pkt_stream_add_cnt;
|
||||
|
||||
+3
-3
@@ -41,9 +41,9 @@
|
||||
#endif
|
||||
|
||||
typedef struct BypassedFlowManagerThreadData_ {
|
||||
uint16_t flow_bypassed_cnt_clo;
|
||||
uint16_t flow_bypassed_pkts;
|
||||
uint16_t flow_bypassed_bytes;
|
||||
StatsCounterId flow_bypassed_cnt_clo;
|
||||
StatsCounterId flow_bypassed_pkts;
|
||||
StatsCounterId flow_bypassed_bytes;
|
||||
} BypassedFlowManagerThreadData;
|
||||
|
||||
#define BYPASSFUNCMAX 4
|
||||
|
||||
+2
-2
@@ -667,8 +667,8 @@ static void FlowExceptionPolicyStatsIncr(
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
uint16_t id = fls->dtv->counter_flow_memcap_eps.eps_id[policy];
|
||||
if (likely(id > 0)) {
|
||||
StatsCounterId id = fls->dtv->counter_flow_memcap_eps.eps_id[policy];
|
||||
if (likely(id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
+19
-19
@@ -642,26 +642,26 @@ static uint32_t FlowCleanupHash(void)
|
||||
}
|
||||
|
||||
typedef struct FlowCounters_ {
|
||||
uint16_t flow_mgr_full_pass;
|
||||
uint16_t flow_mgr_rows_sec;
|
||||
StatsCounterId flow_mgr_full_pass;
|
||||
StatsCounterId flow_mgr_rows_sec;
|
||||
|
||||
uint16_t flow_mgr_spare;
|
||||
uint16_t flow_emerg_mode_enter;
|
||||
uint16_t flow_emerg_mode_over;
|
||||
StatsCounterId flow_mgr_spare;
|
||||
StatsCounterId flow_emerg_mode_enter;
|
||||
StatsCounterId flow_emerg_mode_over;
|
||||
|
||||
uint16_t flow_mgr_flows_checked;
|
||||
uint16_t flow_mgr_flows_notimeout;
|
||||
uint16_t flow_mgr_flows_timeout;
|
||||
uint16_t flow_mgr_flows_aside;
|
||||
uint16_t flow_mgr_flows_aside_needs_work;
|
||||
StatsCounterId flow_mgr_flows_checked;
|
||||
StatsCounterId flow_mgr_flows_notimeout;
|
||||
StatsCounterId flow_mgr_flows_timeout;
|
||||
StatsCounterId flow_mgr_flows_aside;
|
||||
StatsCounterId flow_mgr_flows_aside_needs_work;
|
||||
|
||||
StatsCounterMaxId flow_mgr_rows_maxlen;
|
||||
|
||||
uint16_t flow_bypassed_cnt_clo;
|
||||
uint16_t flow_bypassed_pkts;
|
||||
uint16_t flow_bypassed_bytes;
|
||||
StatsCounterId flow_bypassed_cnt_clo;
|
||||
StatsCounterId flow_bypassed_pkts;
|
||||
StatsCounterId flow_bypassed_bytes;
|
||||
|
||||
uint16_t memcap_pressure;
|
||||
StatsCounterId memcap_pressure;
|
||||
StatsCounterMaxId memcap_pressure_max;
|
||||
} FlowCounters;
|
||||
|
||||
@@ -673,8 +673,8 @@ typedef struct FlowManagerThreadData_ {
|
||||
FlowCounters cnt;
|
||||
|
||||
FlowManagerTimeoutThread timeout;
|
||||
uint16_t counter_defrag_timeout;
|
||||
uint16_t counter_defrag_memuse;
|
||||
StatsCounterId counter_defrag_timeout;
|
||||
StatsCounterId counter_defrag_memuse;
|
||||
} FlowManagerThreadData;
|
||||
|
||||
static void FlowCountersInit(ThreadVars *t, FlowCounters *fc)
|
||||
@@ -1031,12 +1031,12 @@ void FlowManagerThreadSpawn(void)
|
||||
typedef struct FlowRecyclerThreadData_ {
|
||||
void *output_thread_data;
|
||||
|
||||
uint16_t counter_flows;
|
||||
StatsCounterId counter_flows;
|
||||
StatsCounterAvgId counter_queue_avg;
|
||||
StatsCounterMaxId counter_queue_max;
|
||||
|
||||
uint16_t counter_flow_active;
|
||||
uint16_t counter_tcp_active_sessions;
|
||||
StatsCounterId counter_flow_active;
|
||||
StatsCounterId counter_tcp_active_sessions;
|
||||
FlowEndCounters fec;
|
||||
} FlowRecyclerThreadData;
|
||||
|
||||
|
||||
+3
-3
@@ -144,9 +144,9 @@ uint8_t FlowGetReverseProtoMapping(uint8_t rproto);
|
||||
/* flow end counter logic */
|
||||
|
||||
typedef struct FlowEndCounters_ {
|
||||
uint16_t flow_state[FLOW_STATE_SIZE];
|
||||
uint16_t flow_tcp_state[TCP_CLOSED + 1];
|
||||
uint16_t flow_tcp_liberal;
|
||||
StatsCounterId flow_state[FLOW_STATE_SIZE];
|
||||
StatsCounterId flow_tcp_state[TCP_CLOSED + 1];
|
||||
StatsCounterId flow_tcp_liberal;
|
||||
} FlowEndCounters;
|
||||
|
||||
static inline void FlowEndCountersUpdate(ThreadVars *tv, FlowEndCounters *fec, Flow *f)
|
||||
|
||||
+8
-8
@@ -78,21 +78,21 @@ typedef struct FlowWorkerThreadData_ {
|
||||
void *output_thread; /* Output thread data. */
|
||||
void *output_thread_flow; /* Output thread data. */
|
||||
|
||||
uint16_t local_bypass_pkts;
|
||||
uint16_t local_bypass_bytes;
|
||||
uint16_t both_bypass_pkts;
|
||||
uint16_t both_bypass_bytes;
|
||||
StatsCounterId local_bypass_pkts;
|
||||
StatsCounterId local_bypass_bytes;
|
||||
StatsCounterId both_bypass_pkts;
|
||||
StatsCounterId both_bypass_bytes;
|
||||
/** Queue to put pseudo packets that have been created by the stream (RST response) and by the
|
||||
* flush logic following a protocol change. */
|
||||
PacketQueueNoLock pq;
|
||||
FlowLookupStruct fls;
|
||||
|
||||
struct {
|
||||
uint16_t flows_injected;
|
||||
StatsCounterId flows_injected;
|
||||
StatsCounterMaxId flows_injected_max;
|
||||
uint16_t flows_removed;
|
||||
uint16_t flows_aside_needs_work;
|
||||
uint16_t flows_aside_pkt_inject;
|
||||
StatsCounterId flows_removed;
|
||||
StatsCounterId flows_aside_needs_work;
|
||||
StatsCounterId flows_aside_pkt_inject;
|
||||
} cnt;
|
||||
FlowEndCounters fec;
|
||||
|
||||
|
||||
+3
-2
@@ -194,8 +194,9 @@ typedef struct PcapLogData_ {
|
||||
typedef struct PcapLogThreadData_ {
|
||||
PcapLogData *pcap_log;
|
||||
MemBuffer *buf;
|
||||
uint16_t counter_written; /**< Counter for number of packets written */
|
||||
uint16_t counter_filtered_bpf; /**< Counter for number of packets filtered out and not writen */
|
||||
StatsCounterId counter_written; /**< Counter for number of packets written */
|
||||
StatsCounterId
|
||||
counter_filtered_bpf; /**< Counter for number of packets filtered out and not writen */
|
||||
} PcapLogThreadData;
|
||||
|
||||
/* Pattern for extracting timestamp from pcap log files. */
|
||||
|
||||
@@ -54,8 +54,8 @@ typedef struct OutputFilestoreCtx_ {
|
||||
|
||||
typedef struct OutputFilestoreLogThread_ {
|
||||
OutputFilestoreCtx *ctx;
|
||||
uint16_t counter_max_hits;
|
||||
uint16_t fs_error_counter;
|
||||
StatsCounterId counter_max_hits;
|
||||
StatsCounterId fs_error_counter;
|
||||
} OutputFilestoreLogThread;
|
||||
|
||||
enum WarnOnceTypes {
|
||||
|
||||
@@ -286,16 +286,16 @@ typedef struct AFPThreadVars_
|
||||
ChecksumValidationMode checksum_mode;
|
||||
|
||||
/* references to packet and drop counters */
|
||||
uint16_t capture_kernel_packets;
|
||||
uint16_t capture_kernel_drops;
|
||||
uint16_t capture_errors;
|
||||
StatsCounterId capture_kernel_packets;
|
||||
StatsCounterId capture_kernel_drops;
|
||||
StatsCounterId capture_errors;
|
||||
StatsCounterAvgId afpacket_spin;
|
||||
uint16_t capture_afp_poll;
|
||||
uint16_t capture_afp_poll_signal;
|
||||
uint16_t capture_afp_poll_timeout;
|
||||
uint16_t capture_afp_poll_data;
|
||||
uint16_t capture_afp_poll_err;
|
||||
uint16_t capture_afp_send_err;
|
||||
StatsCounterId capture_afp_poll;
|
||||
StatsCounterId capture_afp_poll_signal;
|
||||
StatsCounterId capture_afp_poll_timeout;
|
||||
StatsCounterId capture_afp_poll_data;
|
||||
StatsCounterId capture_afp_poll_err;
|
||||
StatsCounterId capture_afp_send_err;
|
||||
|
||||
uint64_t send_errors_logged; /**< snapshot of send errors logged. */
|
||||
|
||||
|
||||
+8
-8
@@ -188,14 +188,14 @@ typedef struct AFXDPThreadVars_ {
|
||||
/* Stats parameters */
|
||||
uint64_t pkts;
|
||||
uint64_t bytes;
|
||||
uint16_t capture_afxdp_packets;
|
||||
uint16_t capture_kernel_drops;
|
||||
uint16_t capture_afxdp_poll;
|
||||
uint16_t capture_afxdp_poll_timeout;
|
||||
uint16_t capture_afxdp_poll_failed;
|
||||
uint16_t capture_afxdp_empty_reads;
|
||||
uint16_t capture_afxdp_failed_reads;
|
||||
uint16_t capture_afxdp_acquire_pkt_failed;
|
||||
StatsCounterId capture_afxdp_packets;
|
||||
StatsCounterId capture_kernel_drops;
|
||||
StatsCounterId capture_afxdp_poll;
|
||||
StatsCounterId capture_afxdp_poll_timeout;
|
||||
StatsCounterId capture_afxdp_poll_failed;
|
||||
StatsCounterId capture_afxdp_empty_reads;
|
||||
StatsCounterId capture_afxdp_failed_reads;
|
||||
StatsCounterId capture_afxdp_acquire_pkt_failed;
|
||||
} AFXDPThreadVars;
|
||||
|
||||
static TmEcode ReceiveAFXDPThreadInit(ThreadVars *, const void *, void **);
|
||||
|
||||
+6
-6
@@ -116,12 +116,12 @@ typedef struct DPDKThreadVars_ {
|
||||
ChecksumValidationMode checksum_mode;
|
||||
bool intr_enabled;
|
||||
/* references to packet and drop counters */
|
||||
uint16_t capture_dpdk_packets;
|
||||
uint16_t capture_dpdk_rx_errs;
|
||||
uint16_t capture_dpdk_imissed;
|
||||
uint16_t capture_dpdk_rx_no_mbufs;
|
||||
uint16_t capture_dpdk_ierrors;
|
||||
uint16_t capture_dpdk_tx_errs;
|
||||
StatsCounterId capture_dpdk_packets;
|
||||
StatsCounterId capture_dpdk_rx_errs;
|
||||
StatsCounterId capture_dpdk_imissed;
|
||||
StatsCounterId capture_dpdk_rx_no_mbufs;
|
||||
StatsCounterId capture_dpdk_ierrors;
|
||||
StatsCounterId capture_dpdk_tx_errs;
|
||||
unsigned int flags;
|
||||
uint16_t threads;
|
||||
/* for IPS */
|
||||
|
||||
+2
-2
@@ -154,8 +154,8 @@ typedef struct NetmapThreadVars_
|
||||
uint64_t pkts;
|
||||
uint64_t bytes;
|
||||
uint64_t drops;
|
||||
uint16_t capture_kernel_packets;
|
||||
uint16_t capture_kernel_drops;
|
||||
StatsCounterId capture_kernel_packets;
|
||||
StatsCounterId capture_kernel_drops;
|
||||
} NetmapThreadVars;
|
||||
|
||||
typedef TAILQ_HEAD(NetmapDeviceList_, NetmapDevice_) NetmapDeviceList;
|
||||
|
||||
+2
-2
@@ -106,8 +106,8 @@ typedef struct NFLOGThreadVars_ {
|
||||
uint64_t bytes;
|
||||
uint32_t errs;
|
||||
|
||||
uint16_t capture_kernel_packets;
|
||||
uint16_t capture_kernel_drops;
|
||||
StatsCounterId capture_kernel_packets;
|
||||
StatsCounterId capture_kernel_drops;
|
||||
} NFLOGThreadVars;
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -89,9 +89,9 @@ typedef struct PcapThreadVars_
|
||||
uint64_t pkts;
|
||||
uint64_t bytes;
|
||||
|
||||
uint16_t capture_kernel_packets;
|
||||
uint16_t capture_kernel_drops;
|
||||
uint16_t capture_kernel_ifdrops;
|
||||
StatsCounterId capture_kernel_packets;
|
||||
StatsCounterId capture_kernel_drops;
|
||||
StatsCounterId capture_kernel_ifdrops;
|
||||
|
||||
ThreadVars *tv;
|
||||
TmSlot *slot;
|
||||
|
||||
@@ -608,8 +608,8 @@ void StreamTcpReassembleFreeThreadCtx(TcpReassemblyThreadCtx *ra_ctx)
|
||||
static void StreamTcpReassembleExceptionPolicyStatsIncr(
|
||||
ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, enum ExceptionPolicy policy)
|
||||
{
|
||||
uint16_t id = ra_ctx->counter_tcp_reas_eps.eps_id[policy];
|
||||
if (likely(tv && id > 0)) {
|
||||
StatsCounterId id = ra_ctx->counter_tcp_reas_eps.eps_id[policy];
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -64,28 +64,28 @@ typedef struct TcpReassemblyThreadCtx_ {
|
||||
int segment_thread_pool_id;
|
||||
|
||||
/** TCP segments which are not being reassembled due to memcap was reached */
|
||||
uint16_t counter_tcp_segment_memcap;
|
||||
StatsCounterId counter_tcp_segment_memcap;
|
||||
/** times exception policy for stream reassembly memcap was applied **/
|
||||
ExceptionPolicyCounters counter_tcp_reas_eps;
|
||||
|
||||
uint16_t counter_tcp_segment_from_cache;
|
||||
uint16_t counter_tcp_segment_from_pool;
|
||||
StatsCounterId counter_tcp_segment_from_cache;
|
||||
StatsCounterId counter_tcp_segment_from_pool;
|
||||
|
||||
/** number of streams that stop reassembly because their depth is reached */
|
||||
uint16_t counter_tcp_stream_depth;
|
||||
StatsCounterId counter_tcp_stream_depth;
|
||||
/** count number of streams with a unrecoverable stream gap (missing pkts) */
|
||||
uint16_t counter_tcp_reass_gap;
|
||||
StatsCounterId counter_tcp_reass_gap;
|
||||
|
||||
/** count packet data overlaps */
|
||||
uint16_t counter_tcp_reass_overlap;
|
||||
StatsCounterId counter_tcp_reass_overlap;
|
||||
/** count overlaps with different data */
|
||||
uint16_t counter_tcp_reass_overlap_diff_data;
|
||||
StatsCounterId counter_tcp_reass_overlap_diff_data;
|
||||
|
||||
uint16_t counter_tcp_reass_data_normal_fail;
|
||||
uint16_t counter_tcp_reass_data_overlap_fail;
|
||||
StatsCounterId counter_tcp_reass_data_normal_fail;
|
||||
StatsCounterId counter_tcp_reass_data_overlap_fail;
|
||||
|
||||
/** count OOB bytes */
|
||||
uint16_t counter_tcp_urgent_oob;
|
||||
StatsCounterId counter_tcp_urgent_oob;
|
||||
} TcpReassemblyThreadCtx;
|
||||
|
||||
#define OS_POLICY_DEFAULT OS_POLICY_BSD
|
||||
|
||||
+4
-4
@@ -898,8 +898,8 @@ static bool IsStreamTcpSessionMemcapExceptionPolicyStatsValid(enum ExceptionPoli
|
||||
static void StreamTcpSsnMemcapExceptionPolicyStatsIncr(
|
||||
ThreadVars *tv, StreamTcpThread *stt, enum ExceptionPolicy policy)
|
||||
{
|
||||
const uint16_t id = stt->counter_tcp_ssn_memcap_eps.eps_id[policy];
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = stt->counter_tcp_ssn_memcap_eps.eps_id[policy];
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
@@ -1139,8 +1139,8 @@ static bool IsMidstreamExceptionPolicyStatsValid(enum ExceptionPolicy policy)
|
||||
static void StreamTcpMidstreamExceptionPolicyStatsIncr(
|
||||
ThreadVars *tv, StreamTcpThread *stt, enum ExceptionPolicy policy)
|
||||
{
|
||||
const uint16_t id = stt->counter_tcp_midstream_eps.eps_id[policy];
|
||||
if (likely(tv && id > 0)) {
|
||||
const StatsCounterId id = stt->counter_tcp_midstream_eps.eps_id[policy];
|
||||
if (likely(tv && id.id > 0)) {
|
||||
StatsIncr(tv, id);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -92,26 +92,26 @@ typedef struct TcpStreamCnf_ {
|
||||
typedef struct StreamTcpThread_ {
|
||||
int ssn_pool_id;
|
||||
|
||||
uint16_t counter_tcp_active_sessions;
|
||||
uint16_t counter_tcp_sessions;
|
||||
StatsCounterId counter_tcp_active_sessions;
|
||||
StatsCounterId counter_tcp_sessions;
|
||||
/** sessions not picked up because memcap was reached */
|
||||
uint16_t counter_tcp_ssn_memcap;
|
||||
uint16_t counter_tcp_ssn_from_cache;
|
||||
uint16_t counter_tcp_ssn_from_pool;
|
||||
StatsCounterId counter_tcp_ssn_memcap;
|
||||
StatsCounterId counter_tcp_ssn_from_cache;
|
||||
StatsCounterId counter_tcp_ssn_from_pool;
|
||||
/** exception policy */
|
||||
ExceptionPolicyCounters counter_tcp_ssn_memcap_eps;
|
||||
/** pseudo packets processed */
|
||||
uint16_t counter_tcp_pseudo;
|
||||
StatsCounterId counter_tcp_pseudo;
|
||||
/** packets rejected because their csum is invalid */
|
||||
uint16_t counter_tcp_invalid_checksum;
|
||||
StatsCounterId counter_tcp_invalid_checksum;
|
||||
/** midstream pickups */
|
||||
uint16_t counter_tcp_midstream_pickups;
|
||||
StatsCounterId counter_tcp_midstream_pickups;
|
||||
/** exception policy stats */
|
||||
ExceptionPolicyCounters counter_tcp_midstream_eps;
|
||||
/** wrong thread */
|
||||
uint16_t counter_tcp_wrong_thread;
|
||||
StatsCounterId counter_tcp_wrong_thread;
|
||||
/** ack for unseen data */
|
||||
uint16_t counter_tcp_ack_unseen_data;
|
||||
StatsCounterId counter_tcp_ack_unseen_data;
|
||||
|
||||
/** tcp reassembly thread data */
|
||||
TcpReassemblyThreadCtx *ra_ctx;
|
||||
|
||||
@@ -51,7 +51,7 @@ enum ExceptionPolicy {
|
||||
|
||||
typedef struct ExceptionPolicyCounters_ {
|
||||
/* Follows enum order */
|
||||
uint16_t eps_id[EXCEPTION_POLICY_MAX];
|
||||
StatsCounterId eps_id[EXCEPTION_POLICY_MAX];
|
||||
} ExceptionPolicyCounters;
|
||||
|
||||
typedef struct ExceptionPolicyStatsSetts_ {
|
||||
|
||||
Reference in New Issue
Block a user