-
Notifications
You must be signed in to change notification settings - Fork 26
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
DPI related bug-fixes #5
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -389,10 +389,15 @@ appfw_action(npf_cache_t *npc, struct rte_mbuf **nbuf, void *arg, | |
*/ | ||
dpi_flow = npf_session_get_dpi(se); | ||
if (!dpi_flow) { | ||
#ifdef USE_NDPI | ||
uint8_t engines[] = { IANA_USER, IANA_NDPI }; | ||
|
||
size_t engines_len = 2; | ||
#else | ||
uint8_t engines[] = { IANA_USER }; | ||
size_t engines_len = 1; | ||
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 second line would be better outwith of the conditional and written as:
Which raises another question, each other call to dpi_session_first_packet() passes an final pair or parameters, being 'engines_length' and 'engines', however 'engines_length' was a constant '2' in each case. This change implies that something related to that pair should be altered - somehow. |
||
#endif /* USER_NDPI */ | ||
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 directly related, but possibly important. I believe that when the app-fw was created, 0 data-length packets were not fed through it, and so did not count towards the number of initial packets it had to see before converging on an answer. So TCP flags only updates would not count. The context of this PR implies that this is no longer the case, and it may inform upon why we had issues with the initial count behaviour in the post Qosmos world. So there may be something to be updated in the app-fw now as to which packets it counts towards that initial set - possibly 0-data length TCP packet should not be counted? 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. Possibly copied to the wrong place, this makes more sense in relation to the prior commit. |
||
rc = dpi_session_first_packet(se, npc, *nbuf, | ||
ah->ah_initial_dir, 2, engines); | ||
ah->ah_initial_dir, engines_len, engines); | ||
if (rc != 0) | ||
goto drop; | ||
dpi_flow = npf_session_get_dpi(se); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,9 +178,15 @@ dpi_match(npf_cache_t *npc, struct rte_mbuf *mbuf, const struct ifnet *ifp, | |
/* Find or attach the DPI flow info. Do first packet inspection */ | ||
struct dpi_flow *dpi_flow = npf_session_get_dpi(se); | ||
if (!dpi_flow) { | ||
#ifdef USE_NDPI | ||
uint8_t engines[] = {IANA_USER, IANA_NDPI}; | ||
size_t engines_len = 2; | ||
#else | ||
uint8_t engines[] = {IANA_USER}; | ||
size_t engines_len = 1; | ||
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. ARRAY_SIZE, as earlier. 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. I think this repeated code should be in a little helper function so USE_NDPI is kept to a minimum, and there's only one place to add additional DPI engines in future. |
||
#endif /* USER_NDPI */ | ||
int error = dpi_session_first_packet(se, npc, mbuf, | ||
dir, 2, engines); | ||
dir, engines_len, engines); | ||
if (error) | ||
goto drop; | ||
dpi_flow = npf_session_get_dpi(se); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,8 +75,15 @@ ip_dpi_process_common(struct pl_packet *pkt, bool v4, int dir) | |
} | ||
|
||
/* Attach the DPI flow info, do first packet inspection */ | ||
uint8_t engines[] = {IANA_USER, IANA_NDPI}; | ||
(void)dpi_session_first_packet(se, npc, m, dir, 2, engines); | ||
#ifdef USE_NDPI | ||
uint8_t engines[] = {IANA_USER, IANA_NDPI}; | ||
size_t engines_len = 2; | ||
#else | ||
uint8_t engines[] = {IANA_USER}; | ||
size_t engines_len = 1; | ||
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. ARRAY_SIZE, as earlier. |
||
#endif /* USER_NDPI */ | ||
|
||
(void)dpi_session_first_packet(se, npc, m, dir, engines_len, engines); | ||
|
||
done: | ||
if (dir == PFIL_IN) | ||
|
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.
@dfawcus
In dpi.c:dpi_get_data_len() there is a comment around where the UDP length is validated, intended to simply cause packets to be dropped if the length is invalid.
The above change would seem to make the call graph to here broken, in that such packets now will not be dropped, so there would need to be another way of dealing with that case.
It is also worth keeping in mind that (eventually) UDP packets will have the possibility of having 0 traditional data, while actually carrying elsewhere because of the UDP-Options draft which is in progress.
It strikes me that the data_length field should maybe be removed from the prototype for this function, as it arose when the mbuf was not passed in, and we passed instead a data+length tuple. It is rather superfluous at the moment, as it can be extracted from the mbuf - see dpi_get_data_length().