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

flow: Add cfg for optional flow reuse during low memory #10232

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/flow-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ static Flow *FlowGetNew(ThreadVars *tv, FlowLookupStruct *fls, Packet *p)
FlowWakeupFlowManagerThread();
}

if (!flow_config.force_reuse) {
Copy link
Member

Choose a reason for hiding this comment

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

how should this behave in IPS mode? We don't call NoFlowHandleIPS() here

Copy link
Member

Choose a reason for hiding this comment

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

I think we could also enforce this option at the start of FlowGetUsedFlow

StatsIncr(tv, fls->dtv->counter_flow_memcap);
return NULL;
}
f = FlowGetUsedFlow(tv, fls->dtv, p->ts);
if (f == NULL) {
NoFlowHandleIPS(p);
Expand Down
8 changes: 6 additions & 2 deletions src/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,16 @@ void FlowInitConfig(bool quiet)
flow_config.prealloc = configval;
}
}
if (ConfGetBool("flow.force-reuse", &flow_config.force_reuse) != 1) {
flow_config.force_reuse = 1;
}

flow_config.memcap_policy = ExceptionPolicyParse("flow.memcap-policy", false);

SCLogDebug("Flow config from suricata.yaml: memcap: %"PRIu64", hash-size: "
"%"PRIu32", prealloc: %"PRIu32, SC_ATOMIC_GET(flow_config.memcap),
flow_config.hash_size, flow_config.prealloc);
"%"PRIu32", prealloc: %"PRIu32 ", reuse: %s", SC_ATOMIC_GET(flow_config.memcap),
flow_config.hash_size, flow_config.prealloc,
flow_config.force_reuse ? "force" : "disabled");

/* alloc hash memory */
uint64_t hash_size = flow_config.hash_size * sizeof(FlowBucket);
Expand Down
1 change: 1 addition & 0 deletions src/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ typedef struct FlowCnf_
uint32_t hash_rand;
uint32_t hash_size;
uint32_t prealloc;
int force_reuse;
Copy link
Member

Choose a reason for hiding this comment

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

bool

Copy link
Member

Choose a reason for hiding this comment

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

also, please add a line to document the field


uint32_t timeout_new;
uint32_t timeout_est;
Expand Down
1 change: 1 addition & 0 deletions suricata.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ flow:
emergency-recovery: 30
#managers: 1 # default to one flow manager
#recyclers: 1 # default to one flow recycler thread
force-reuse: 1 # Default to forcing flow reuse in low memory conditions
Copy link
Member

Choose a reason for hiding this comment

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

we can enable it by default in the code, and leave it commented out here

additionally, it should use true/false instead of suggesting it is a numeric value


# This option controls the use of VLAN ids in the flow (and defrag)
# hashing. Normally this should be enabled, but in some (broken)
Expand Down
Loading