Skip to content

Commit

Permalink
DPI: use USE_NDPI flag
Browse files Browse the repository at this point in the history
Add USE_NDPI flag to initialise ‘engines’ and 'engines_len'
before calling dpi_session_first_packet() function in order
to avoid error due to missing dpi_engine_procs for nDPI engine
when dataplane compilation is done without USE_NDPI flag.

Co-authored-by: Subhajit Chatterjee <[email protected]>
Signed-off-by: Shubham Shrivastava <[email protected]>
  • Loading branch information
shubham-cdot and subhajit-cdot committed Jan 13, 2021
1 parent b56fa43 commit 42d292f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/npf/rproc/npf_ext_appfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
#endif /* USER_NDPI */
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);
Expand Down
8 changes: 7 additions & 1 deletion src/npf/rproc/npf_ext_dpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
#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);
Expand Down
11 changes: 9 additions & 2 deletions src/pipeline/nodes/l3_dpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
#endif /* USER_NDPI */

(void)dpi_session_first_packet(se, npc, m, dir, engines_len, engines);

done:
if (dir == PFIL_IN)
Expand Down

0 comments on commit 42d292f

Please sign in to comment.