allow counters clubbing for detect TM

remotes/origin/master-1.0.x
Anoop Saldanha 16 years ago committed by Victor Julien
parent cb94748dab
commit bbb5bf5c51

@ -1142,7 +1142,9 @@ void SCPerfSpawnThreads(void)
uint16_t SCPerfTVRegisterCounter(char *cname, struct ThreadVars_ *tv, int type,
char *desc)
{
uint16_t id = SCPerfRegisterQualifiedCounter(cname, tv->name, type, desc,
uint16_t id = SCPerfRegisterQualifiedCounter(cname,
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
type, desc,
&tv->sc_perf_pctx,
SC_PERF_TYPE_Q_NORMAL, NULL);
@ -1165,7 +1167,9 @@ uint16_t SCPerfTVRegisterCounter(char *cname, struct ThreadVars_ *tv, int type,
uint16_t SCPerfTVRegisterAvgCounter(char *cname, struct ThreadVars_ *tv,
int type, char *desc)
{
uint16_t id = SCPerfRegisterQualifiedCounter(cname, tv->name, type, desc,
uint16_t id = SCPerfRegisterQualifiedCounter(cname,
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
type, desc,
&tv->sc_perf_pctx,
SC_PERF_TYPE_Q_AVERAGE, NULL);
@ -1188,7 +1192,9 @@ uint16_t SCPerfTVRegisterAvgCounter(char *cname, struct ThreadVars_ *tv,
uint16_t SCPerfTVRegisterMaxCounter(char *cname, struct ThreadVars_ *tv,
int type, char *desc)
{
uint16_t id = SCPerfRegisterQualifiedCounter(cname, tv->name, type, desc,
uint16_t id = SCPerfRegisterQualifiedCounter(cname,
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
type, desc,
&tv->sc_perf_pctx,
SC_PERF_TYPE_Q_MAXIMUM, NULL);
@ -1216,7 +1222,9 @@ uint16_t SCPerfTVRegisterIntervalCounter(char *cname, struct ThreadVars_ *tv,
int type, char *desc,
char *time_interval)
{
uint16_t id = SCPerfRegisterQualifiedCounter(cname, tv->name, type, desc,
uint16_t id = SCPerfRegisterQualifiedCounter(cname,
(tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
type, desc,
&tv->sc_perf_pctx,
SC_PERF_TYPE_Q_TIMEBASED |
SC_PERF_TYPE_Q_NORMAL,

@ -367,7 +367,8 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data) {
det_ctx->counter_alerts = SCPerfTVRegisterCounter("detect.alert", tv,
SC_PERF_TYPE_UINT64, "NULL");
tv->sc_perf_pca = SCPerfGetAllCountersArray(&tv->sc_perf_pctx);
SCPerfAddToClubbedTMTable(tv->name, &tv->sc_perf_pctx);
SCPerfAddToClubbedTMTable((tv->thread_group_name != NULL) ? tv->thread_group_name : tv->name,
&tv->sc_perf_pctx);
/* this detection engine context belongs to this thread instance */
det_ctx->tv = tv;

@ -166,6 +166,8 @@ static void RunModeInitialize(void)
int RunModeIdsPcap(DetectEngineCtx *de_ctx, char *iface) {
TimeModeSetLive();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout");
if (tv_receivepcap == NULL) {
@ -230,6 +232,13 @@ int RunModeIdsPcap(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -247,6 +256,13 @@ int RunModeIdsPcap(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -284,6 +300,8 @@ int RunModeIdsPcap(DetectEngineCtx *de_ctx, char *iface) {
int RunModeIdsPcap2(DetectEngineCtx *de_ctx, char *iface) {
TimeModeSetLive();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout");
if (tv_receivepcap == NULL) {
@ -399,6 +417,13 @@ int RunModeIdsPcap2(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -416,6 +441,13 @@ int RunModeIdsPcap2(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -653,6 +685,8 @@ int RunModeIdsPcap3(DetectEngineCtx *de_ctx, char *iface) {
int RunModeIpsNFQ(DetectEngineCtx *de_ctx, char *nfq_id) {
TimeModeSetLive();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receivenfq = TmThreadCreatePacketHandler("ReceiveNFQ","packetpool","packetpool","pickup-queue","simple","1slot_noinout");
if (tv_receivenfq == NULL) {
@ -717,6 +751,13 @@ int RunModeIpsNFQ(DetectEngineCtx *de_ctx, char *nfq_id) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -734,6 +775,13 @@ int RunModeIpsNFQ(DetectEngineCtx *de_ctx, char *nfq_id) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -788,6 +836,8 @@ int RunModeFilePcap(DetectEngineCtx *de_ctx, char *file) {
SCLogDebug("file %s", file);
TimeModeSetOffline();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcapFile","packetpool","packetpool","pickup-queue","simple","1slot");
if (tv_receivepcap == NULL) {
@ -854,6 +904,13 @@ int RunModeFilePcap(DetectEngineCtx *de_ctx, char *file) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -871,6 +928,13 @@ int RunModeFilePcap(DetectEngineCtx *de_ctx, char *file) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -942,6 +1006,8 @@ int RunModeFilePcap2(DetectEngineCtx *de_ctx, char *file) {
int RunModeIdsPfring(DetectEngineCtx *de_ctx, char *iface) {
TimeModeSetLive();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receivepfring = TmThreadCreatePacketHandler("ReceivePfring","packetpool","packetpool","pickup-queue1","simple","1slot");
if (tv_receivepfring == NULL) {
@ -1057,6 +1123,13 @@ int RunModeIdsPfring(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1074,6 +1147,13 @@ int RunModeIdsPfring(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1111,6 +1191,8 @@ int RunModeIdsPfring(DetectEngineCtx *de_ctx, char *iface) {
int RunModeIdsPfring2(DetectEngineCtx *de_ctx, char *iface) {
TimeModeSetLive();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receivepfring = TmThreadCreatePacketHandler("ReceivePfring","packetpool","packetpool","pickup-queue","simple","1slot");
if (tv_receivepfring == NULL) {
@ -1226,6 +1308,13 @@ int RunModeIdsPfring2(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1243,6 +1332,13 @@ int RunModeIdsPfring2(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1469,6 +1565,8 @@ int RunModeIpsIPFW(DetectEngineCtx *de_ctx) {
TimeModeSetLive();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receiveipfw = TmThreadCreatePacketHandler("ReceiveIPFW","packetpool","packetpool","pickup-queue","simple","1slot_noinout");
@ -1534,6 +1632,13 @@ int RunModeIpsIPFW(DetectEngineCtx *de_ctx) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1551,6 +1656,13 @@ int RunModeIpsIPFW(DetectEngineCtx *de_ctx) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1605,6 +1717,8 @@ int RunModeIpsIPFW(DetectEngineCtx *de_ctx) {
int RunModeIdsPfring4(DetectEngineCtx *de_ctx, char *iface) {
TimeModeSetLive();
char *thread_group_name = NULL;
/* create the threads */
ThreadVars *tv_receivepfring = TmThreadCreatePacketHandler("ReceivePfring","packetpool","packetpool","pickup-queue1","simple","1slot");
if (tv_receivepfring == NULL) {
@ -1821,6 +1935,13 @@ int RunModeIdsPfring4(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect1->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect1) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1837,6 +1958,13 @@ int RunModeIdsPfring4(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect2->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect2) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1854,6 +1982,13 @@ int RunModeIdsPfring4(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect3,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect3->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect3) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -1871,6 +2006,13 @@ int RunModeIdsPfring4(DetectEngineCtx *de_ctx, char *iface) {
}
Tm1SlotSetFunc(tv_detect4,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect4->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect4) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -2049,6 +2191,13 @@ int RunModeIdsPcapAuto(DetectEngineCtx *de_ctx, char *iface) {
}
}
char *thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect_ncpu->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -2230,6 +2379,13 @@ int RunModeFilePcapAuto(DetectEngineCtx *de_ctx, char *file) {
}
}
char *thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect_ncpu->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -2354,6 +2510,14 @@ int RunModeFilePcapAuto2(DetectEngineCtx *de_ctx, char *file) {
}
}
char *thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect_ncpu->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -2523,6 +2687,13 @@ int RunModeIpsIPFWAuto(DetectEngineCtx *de_ctx) {
}
}
char *thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect_ncpu->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -2742,6 +2913,13 @@ int RunModeIpsNFQAuto(DetectEngineCtx *de_ctx, char *nfq_id) {
}
}
char *thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect_ncpu->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);
@ -2958,8 +3136,14 @@ int RunModeIdsPfringAuto(DetectEngineCtx *de_ctx, char *iface) {
} else if (ncpus > 1) {
TmThreadSetThreadPriority(tv_detect_ncpu, PRIO_MEDIUM);
}
}
}
char *thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect_ncpu->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
@ -3127,6 +3311,13 @@ int RunModeErfFileAuto(DetectEngineCtx *de_ctx, char *file)
}
}
char *thread_group_name = SCStrdup("Detect");
if (thread_group_name == NULL) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
tv_detect_ncpu->thread_group_name = thread_group_name;
if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
printf("ERROR: TmThreadSpawn failed\n");
exit(EXIT_FAILURE);

@ -49,6 +49,7 @@
typedef struct ThreadVars_ {
pthread_t t;
char *name;
char *thread_group_name;
uint8_t flags;
SCSpinlock flags_spinlock;

Loading…
Cancel
Save