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

Mark flow elephant/v4 #12325

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

inashivb
Copy link
Member

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

Previous PR: #12237

Changes since v3:

  • rebased on top of latest master
  • added smaller time units parser to have a more fine grained control

TODO: Tests

Add a parser for different units of time. Acceptable values for defining
time are:
us: microseconds
ms: milliseconds
s:  seconds
m:  minutes
h:  hours

This is in order to have a more fine grained control over time which may
be required for certain keywords and operations.
1. Add user defined elephant flow definition based on rate of bytes
easily configurable in suricata.yaml.
2. Add an elephant flow counter.

Feature 5647
This brings us down from 2 holes of 2 bytes and 4 bytes to one hole of 5
bytes.
There may be more room for improvement.
if (ef_interval.usecs > 0) {
ef_bytes *= 1000000;
}
flow_config.elephant_flow_rate =
Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking this value should be floating point for a more accurate calculation

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should avoid floats if possible

if flow bytes > conf bytes && flow age < conf interval should be good for now, right ?


if (ef_interval.usecs > 0) {
ef_bytes *= 1000000;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

else if secs == 0 && usecs ==0, FatalError

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

Attention: Patch coverage is 80.09950% with 40 lines in your changes missing coverage. Please review.

Project coverage is 83.19%. Comparing base (6f937c7) to head (12082f7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12325      +/-   ##
==========================================
- Coverage   83.26%   83.19%   -0.07%     
==========================================
  Files         912      912              
  Lines      257643   257844     +201     
==========================================
- Hits       214521   214520       -1     
- Misses      43122    43324     +202     
Flag Coverage Δ
fuzzcorpus 61.10% <20.18%> (-0.05%) ⬇️
livemode 19.40% <23.85%> (+<0.01%) ⬆️
pcap 44.39% <23.85%> (-0.03%) ⬇️
suricata-verify 62.84% <23.85%> (-0.02%) ⬇️
unittests 59.19% <73.13%> (+<0.01%) ⬆️

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

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24057

return; /* Flow is a known elephant flow, no need to calculate again */
uint32_t age = SCTIME_SECS(f->lastts) - SCTIME_SECS(f->startts);
if (age == 0)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use milliseconds, not just seconds ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

Copy link
Member Author

Choose a reason for hiding this comment

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

micro actually as that's the smallest supported unit.

# the time a flow has been alive.
#elephant-flow-rate:
# bytes: 10KiB
# interval: 10ms # allowed units: us, ms, s, m, h
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand this parameter should be used in FlowIsElephant

as if flow bytes > conf bytes && flow age < conf interval then flow is elephant

Copy link
Member Author

Choose a reason for hiding this comment

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

and that is better than calculating the rate and matching against it?

Well, it does save some floating point calculations indeed. ok. I'll take this route instead. Thank you! 🙇🏽‍♀️

Copy link
Member Author

Choose a reason for hiding this comment

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

JFYI, a rate param was calculated as of now when reading these values and that rate was matched against the flow.bytes/flow.age result.

Copy link
Contributor

Choose a reason for hiding this comment

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

JFYI, a rate param was calculated as of now when reading these values and that rate was matched against the flow.bytes/flow.age result.

Indeed, I saw that.

But I think it is better to keep the 2 params coming from config instead of merging them in a single floating point value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants