Applayer plugin 5053 v3.4#11795
Conversation
instead of a global variable. For easier initialization with dynamic number of protocols
for expectation_proto Ticket: 5053
for alproto_names Ticket: 5053
Ticket: 5053
so that we can use safely EXCEPTION_POLICY_MAX*sizeof(x)
Ticket: 5053 delay after initialization so that StringToAppProto works
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11795 +/- ##
==========================================
- Coverage 82.53% 82.36% -0.18%
==========================================
Files 919 919
Lines 248979 248987 +8
==========================================
- Hits 205506 205087 -419
- Misses 43473 43900 +427
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
Information: ERROR: QA failed on SURI_TLPR1_alerts_cmp.
Pipeline 22740 |
|
WARNING:
Pipeline 22778 |
|
I will do the commit autosquash after some review ;-) |
|
Commits are very light on explanation, please expand them a bit. |
victorjulien
left a comment
There was a problem hiding this comment.
See inline comments / questions.
This PR still uses the hardcoded ALPROTO_MAX from the enum declaration, right? Is a next step to turn that into a variable?
| const char **alproto_names; | ||
|
|
||
| /* Protocol expectations, like ftp-data on tcp */ | ||
| uint8_t *expectation_proto; |
There was a problem hiding this comment.
I don't understand the type here. What does it point to?
There was a problem hiding this comment.
This is an array of ALPROTO_MAX "iptypes" : IPPROTO_TCP, IPPROTO_UDP or something else like 0
see AppLayerRegisterExpectationProto
| { | ||
| SCEnter(); | ||
|
|
||
| // should have just been realloced when dynamic protos is added |
There was a problem hiding this comment.
It is more a TODO note for me for the next PR that alpd_ctx.alproto_names should get reallocated when a new protocol registers itself
|
|
||
| struct AppLayerParserThreadCtx_ { | ||
| void *alproto_local_storage[FLOW_PROTO_MAX][ALPROTO_MAX]; | ||
| void *(*alproto_local_storage)[FLOW_PROTO_MAX]; |
There was a problem hiding this comment.
this notation confuses me... what does it mean?
There was a problem hiding this comment.
We had a fixed-size 2-dimensional array of pointers (void *)
Now we have a fixed-size 1-dimensional array of pointers-as-pointer-to-an-array of pointers (void *)
This allows to keep notation alproto_local_storage[alproto][flow_proto] (as we know one dimension)
Alternative would be to use void **alproto_local_storage and index/access it like alproto_local_storage[alproto*FLOW_PROTO_MAX+flow_proto] (or have many allocations instead of just one contiguous SCCalloc(ALPROTO_MAX*FLOW_PROTO_MAX, sizeof(void *)))
| { | ||
| SCEnter(); | ||
| memset(&alp_ctx, 0, sizeof(alp_ctx)); | ||
| // to realloc when dynamic protos are added |
There was a problem hiding this comment.
comment confused me, do you mean something like "initial allocation that will later be grown using realloc" or something?
| */ | ||
| static int AppLayerParserTest01(void) | ||
| { | ||
| AppLayerParserBackupParserTable(); |
There was a problem hiding this comment.
do we just not need this anymore?
There was a problem hiding this comment.
By the way, I am not sure what these AppLayerParserTest01 really test : they check that AppLayerParserParse returns failure for this newly registered ALPROTO_TEST as TestProtocolParser returns error but it would also return failure without the registration...
There was a problem hiding this comment.
So, could we remove this ALPROTO_TEST ?
Right, a bit like 61ae154 |
|
Next in #11910 |
Link to ticket: https://redmine.openinfosecfoundation.org/issues/
Preliminary work for https://redmine.openinfosecfoundation.org/issues/5053
Describe changes:
#11572 next round
#11701 with comments taken into account
Still more work to do after :
Only
AppProtoStringsis to be handled, but it is the big one.And then take remaining commits out of #11321
And supply an example of an app-layer plugin