int TagFlowAdd(Packet *p, DetectTagDataEntry *tde)
{
uint8_t updated = 0;
- uint16_t num_tags = 0;
+ uint16_t tag_cnt = 0;
DetectTagDataEntry *iter = NULL;
if (p->flow == NULL)
if (iter != NULL) {
/* First iterate installed entries searching a duplicated sid/gid */
for (; iter != NULL; iter = iter->next) {
- num_tags++;
+ tag_cnt++;
if (iter->sid == tde->sid && iter->gid == tde->gid) {
iter->cnt_match++;
}
/* If there was no entry of this rule, prepend the new tde */
- if (updated == 0 && num_tags < DETECT_TAG_MAX_TAGS) {
+ if (updated == 0 && tag_cnt < DETECT_TAG_MAX_TAGS) {
DetectTagDataEntry *new_tde = DetectTagDataCopy(tde);
if (new_tde != NULL) {
new_tde->next = FlowGetStorageById(p->flow, flow_tag_id);
FlowSetStorageById(p->flow, flow_tag_id, new_tde);
+ SCLogDebug("adding tag with first_ts %u", new_tde->first_ts);
(void) SC_ATOMIC_ADD(num_tags, 1);
}
- } else if (num_tags == DETECT_TAG_MAX_TAGS) {
- SCLogDebug("Max tags for sessions reached (%"PRIu16")", num_tags);
+ } else if (tag_cnt == DETECT_TAG_MAX_TAGS) {
+ SCLogDebug("Max tags for sessions reached (%"PRIu16")", tag_cnt);
}
FLOWLOCK_UNLOCK(p->flow);
/* last_ts handles this metric, but also a generic time based
* expiration to prevent dead sessions/hosts */
if (iter->last_ts - iter->first_ts > iter->count) {
+ SCLogDebug("flow tag expired: %u - %u = %u > %u",
+ iter->last_ts, iter->first_ts,
+ (iter->last_ts - iter->first_ts), iter->count);
/* tag expired */
if (prev != NULL) {
tde = iter;
void TagHandlePacket(DetectEngineCtx *de_ctx,
DetectEngineThreadCtx *det_ctx, Packet *p)
{
+ SCEnter();
+
/* If there's no tag, get out of here */
unsigned int current_tags = SC_ATOMIC_GET(num_tags);
if (current_tags == 0)
- return;
+ SCReturn;
/* First update and get session tags */
if (p->flow != NULL) {
}
HostRelease(dst);
}
+ SCReturn;
}
/**
break;
case DETECT_TAG_TYPE_SESSION:
if (p->flow != NULL) {
+ SCLogDebug("Setting up tag for flow");
/* If it already exists it will be updated */
tde.sid = s->id;
tde.gid = s->gid;
tde.metric = td->metric;
tde.count = td->count;
+ SCLogDebug("Adding to or updating flow; first_ts %u count %u",
+ tde.first_ts, tde.count);
TagFlowAdd(p, &tde);
} else {
SCLogDebug("No flow to append the session tag");