-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor optimizations/v1 #12398
base: master
Are you sure you want to change the base?
Minor optimizations/v1 #12398
Changes from all commits
ce9ed71
6ca33f6
6529365
8cec882
35afa8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1955,6 +1955,10 @@ static int DetectEngineInspectRulePayloadMatches( | |
SCLogDebug("SIG_FLAG_REQUIRE_STREAM_ONLY, so no match"); | ||
return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; | ||
} | ||
if (s->flags & SIG_FLAG_REQUIRE_STREAM_ONLY) { | ||
SCLogDebug("SIG_FLAG_REQUIRE_STREAM_ONLY, so no match"); | ||
return false; | ||
} | ||
Comment on lines
+1958
to
+1961
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference b/w this and the branch right above this? |
||
if (DetectEngineInspectPacketPayload(de_ctx, det_ctx, s, p->flow, p) != 1) { | ||
return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,25 +61,24 @@ int PrefilterAddSidsResize(PrefilterRuleStore *pmq, uint32_t new_size); | |
static inline void PrefilterAddSids( | ||
PrefilterRuleStore *pmq, const SigIntId *sids, uint32_t sids_size) | ||
{ | ||
if (sids_size == 0) | ||
return; | ||
|
||
uint32_t new_size = pmq->rule_id_array_cnt + sids_size; | ||
if (new_size > pmq->rule_id_array_size) { | ||
if (PrefilterAddSidsResize(pmq, new_size) == 0) { | ||
// Failed to allocate larger memory for all the SIDS, but | ||
// keep as many as we can. | ||
sids_size = pmq->rule_id_array_size - pmq->rule_id_array_cnt; | ||
if (sids_size > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not following why is an extra indentation preferable over return if base condition doesn't match. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic I think is that it assumes the first branch (so sids_size == 0 leading to return) to be the most likely. |
||
uint32_t new_size = pmq->rule_id_array_cnt + sids_size; | ||
if (new_size > pmq->rule_id_array_size) { | ||
if (PrefilterAddSidsResize(pmq, new_size) == 0) { | ||
// Failed to allocate larger memory for all the SIDS, but | ||
// keep as many as we can. | ||
sids_size = pmq->rule_id_array_size - pmq->rule_id_array_cnt; | ||
} | ||
} | ||
SCLogDebug("Adding %u sids", sids_size); | ||
// Add SIDs for this pattern to the end of the array | ||
SigIntId *ptr = pmq->rule_id_array + pmq->rule_id_array_cnt; | ||
SigIntId *end = ptr + sids_size; | ||
do { | ||
*ptr++ = *sids++; | ||
} while (ptr != end); | ||
pmq->rule_id_array_cnt += sids_size; | ||
} | ||
SCLogDebug("Adding %u sids", sids_size); | ||
// Add SIDs for this pattern to the end of the array | ||
SigIntId *ptr = pmq->rule_id_array + pmq->rule_id_array_cnt; | ||
SigIntId *end = ptr + sids_size; | ||
do { | ||
*ptr++ = *sids++; | ||
} while (ptr != end); | ||
pmq->rule_id_array_cnt += sids_size; | ||
} | ||
|
||
int PmqSetup(PrefilterRuleStore *); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return DETECT_ENGINE_INSPECT_SIG_NO_MATCH
for consistency?as