diff --git a/src/counters.c b/src/counters.c index 184852f78b..adf5660a69 100644 --- a/src/counters.c +++ b/src/counters.c @@ -1265,17 +1265,18 @@ int SCPerfUpdateCounterArray(SCPerfPrivateContext *pca, SCPerfPublicContext *pct return 1; } -/* +/** * \brief Get the value of the local copy of the counter that hold this id. * - * \param id The counter id. - * \param pca Pointer to the SCPerfPrivateContext. + * \param tv threadvars + * \param id The counter id. * * \retval 0 on success. * \retval -1 on error. */ -double SCPerfGetLocalCounterValue(uint16_t id, SCPerfPrivateContext *pca) +uint64_t SCPerfGetLocalCounterValue(ThreadVars *tv, uint16_t id) { + SCPerfPrivateContext *pca = tv->perf_private_ctx; #ifdef DEBUG BUG_ON (pca == NULL); BUG_ON ((id < 1) || (id > pca->size)); diff --git a/src/counters.h b/src/counters.h index 8c0f628684..de8780b4d7 100644 --- a/src/counters.h +++ b/src/counters.h @@ -164,7 +164,7 @@ SCPerfPrivateContext *SCPerfGetCounterArrayRange(uint16_t, uint16_t, SCPerfPubli SCPerfPrivateContext * SCPerfGetAllCountersArray(SCPerfPublicContext *); int SCPerfUpdateCounterArray(SCPerfPrivateContext *, SCPerfPublicContext *); -double SCPerfGetLocalCounterValue(uint16_t, SCPerfPrivateContext *); +uint64_t SCPerfGetLocalCounterValue(struct ThreadVars_ *, uint16_t); /* functions used to free the resources alloted by the Perf counter API */ void SCPerfReleaseResources(void); diff --git a/src/detect.c b/src/detect.c index bca51a25c9..3d51866e07 100644 --- a/src/detect.c +++ b/src/detect.c @@ -11269,20 +11269,20 @@ static int SigTestDetectAlertCounter(void) p = UTHBuildPacket((uint8_t *)"boo", strlen("boo"), IPPROTO_TCP); Detect(&tv, p, det_ctx, NULL, NULL); - result = (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 1); + result = (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 1); Detect(&tv, p, det_ctx, NULL, NULL); - result &= (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 2); + result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2); UTHFreePackets(&p, 1); p = UTHBuildPacket((uint8_t *)"roo", strlen("roo"), IPPROTO_TCP); Detect(&tv, p, det_ctx, NULL, NULL); - result &= (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 2); + result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2); UTHFreePackets(&p, 1); p = UTHBuildPacket((uint8_t *)"laboosa", strlen("laboosa"), IPPROTO_TCP); Detect(&tv, p, det_ctx, NULL, NULL); - result &= (SCPerfGetLocalCounterValue(det_ctx->counter_alerts, tv.perf_private_ctx) == 3); + result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 3); UTHFreePackets(&p, 1); end: diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 6482ee759f..d49898dfcf 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -1805,8 +1805,8 @@ void ReceiveAFPThreadExitStats(ThreadVars *tv, void *data) AFPDumpCounters(ptv); SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "", tv->name, - (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_packets, tv->perf_private_ctx), - (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_drops, tv->perf_private_ctx)); + SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_packets), + SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_drops)); #endif SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes); diff --git a/src/source-erf-dag.c b/src/source-erf-dag.c index 910729b936..fbe21fe855 100644 --- a/src/source-erf-dag.c +++ b/src/source-erf-dag.c @@ -560,16 +560,16 @@ ReceiveErfDagThreadExitStats(ThreadVars *tv, void *data) ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data; (void)SC_ATOMIC_SET(ewtn->livedev->pkts, - (uint64_t)SCPerfGetLocalCounterValue(ewtn->packets, tv->perf_private_ctx)); + SCPerfGetLocalCounterValue(tv, ewtn->packets)); (void)SC_ATOMIC_SET(ewtn->livedev->drop, - (uint64_t)SCPerfGetLocalCounterValue(ewtn->drops, tv->perf_private_ctx)); + SCPerfGetLocalCounterValue(tv, ewtn->drops)); SCLogInfo("Stream: %d; Bytes: %"PRIu64"; Packets: %"PRIu64 "; Drops: %"PRIu64, ewtn->dagstream, ewtn->bytes, - (uint64_t)SCPerfGetLocalCounterValue(ewtn->packets, tv->perf_private_ctx), - (uint64_t)SCPerfGetLocalCounterValue(ewtn->drops, tv->perf_private_ctx)); + SCPerfGetLocalCounterValue(tv, ewtn->packets), + SCPerfGetLocalCounterValue(tv, ewtn->drops)); } /** diff --git a/src/source-netmap.c b/src/source-netmap.c index 1b6b332988..db853e1919 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -851,8 +851,8 @@ static void ReceiveNetmapThreadExitStats(ThreadVars *tv, void *data) NetmapDumpCounters(ntv); SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 ", bytes %" PRIu64 "", tv->name, - (uint64_t) SCPerfGetLocalCounterValue(ntv->capture_kernel_packets, tv->perf_private_ctx), - (uint64_t) SCPerfGetLocalCounterValue(ntv->capture_kernel_drops, tv->perf_private_ctx), + SCPerfGetLocalCounterValue(tv, ntv->capture_kernel_packets), + SCPerfGetLocalCounterValue(tv, ntv->capture_kernel_drops), ntv->bytes); } diff --git a/src/source-pfring.c b/src/source-pfring.c index a6149e2af4..e0e9001960 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -198,10 +198,8 @@ static inline void PfringDumpCounters(PfringThreadVars *ptv) * So to get the number of packet on the interface we can add * the newly seen packets and drops for this thread and add it * to the interface counter */ - uint64_t th_pkts = SCPerfGetLocalCounterValue(ptv->capture_kernel_packets, - ptv->tv->perf_private_ctx); - uint64_t th_drops = SCPerfGetLocalCounterValue(ptv->capture_kernel_drops, - ptv->tv->perf_private_ctx); + uint64_t th_pkts = SCPerfGetLocalCounterValue(ptv->tv, ptv->capture_kernel_packets); + uint64_t th_drops = SCPerfGetLocalCounterValue(ptv->tv, ptv->capture_kernel_drops); SC_ATOMIC_ADD(ptv->livedev->pkts, pfring_s.recv - th_pkts); SC_ATOMIC_ADD(ptv->livedev->drop, pfring_s.drop - th_drops); SCPerfCounterSetUI64(ptv->tv, ptv->capture_kernel_packets, pfring_s.recv); @@ -554,8 +552,8 @@ void ReceivePfringThreadExitStats(ThreadVars *tv, void *data) PfringDumpCounters(ptv); SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "", tv->name, - (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_packets, tv->perf_private_ctx), - (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_drops, tv->perf_private_ctx)); + SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_packets), + SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_drops)); SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes); }