counters: SCPerfGetLocalCounterValue cleanup

Return u64, update arguments.
pull/1508/head
Victor Julien 10 years ago
parent b34c6dc93a
commit 55cfab89e4

@ -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));

@ -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);

@ -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:

@ -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);

@ -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));
}
/**

@ -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);
}

@ -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);
}

Loading…
Cancel
Save