Skip to content
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

Dataset string memcap 3910/v3 #11058

Closed
wants to merge 3 commits into from

Conversation

inashivb
Copy link
Member

Link to redmine ticket: https://redmine.openinfosecfoundation.org/issues/3910

Previous PR: #11056

Changes since v2:

  • get rid of all the unnecessary code, use getter logic within the THash API

In order to have access to the length of datatypes with variable lengths
to correctly update memuse to calculate memcaps.

Bug 3910
So far, when the data size was passed to the THash API, it was sent as
a sizeof(Struct) which works fine for the other data types as they have
a fixed length but not for the StringType.
However, because of the sizeof construct, the length of a string type
dataset was always taken to be 16 Bytes which is only the size of the struct
itself. It did not accomodate the actual size of the string that the
StringType holds. Fix this so that the memuse that is used to determine
whether memcap was reached also takes into consideration the size of the
actual string.

Bug 3910
Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.63%. Comparing base (abb7424) to head (46d78b2).
Report is 32 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11058      +/-   ##
==========================================
+ Coverage   80.63%   83.63%   +3.00%     
==========================================
  Files         922      922              
  Lines      250137   250332     +195     
==========================================
+ Hits       201699   209374    +7675     
+ Misses      48438    40958    -7480     
Flag Coverage Δ
fuzzcorpus 64.22% <100.00%> (-0.05%) ⬇️
livemode 18.42% <33.33%> (-0.14%) ⬇️
suricata-verify 62.76% <100.00%> (?)
unittests 62.26% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

src/util-thash.h Show resolved Hide resolved
src/util-thash.c Show resolved Hide resolved
@@ -517,6 +524,10 @@ static THashData *THashDataGetNew(THashTableContext *ctx, void *data)
// setup the data
BUG_ON(ctx->config.DataSet(h->data, data) != 0);

if (ctx->config.DataLength) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this move into THashDataAlloc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I tried that but found that alloc happens before the data is set (values filled in the respective data types) and it leads to incorrect results. We only have a length after the DataSet callback is done.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 20585

@inashivb inashivb added the needs rebase Needs rebase to master label May 17, 2024
@inashivb inashivb closed this May 21, 2024
@inashivb inashivb deleted the dataset-string-memcap-3910/v3 branch May 21, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase Needs rebase to master
3 participants