Skip to content

Commit

Permalink
util/profiling: remove assertion
Browse files Browse the repository at this point in the history
Now a flow alproto can be changed by a call to AppLayerParserParse
when HTTP2 forces the flow to turn into DOH2.
  • Loading branch information
catenacyber committed Jan 16, 2024
1 parent 8df8746 commit b43b2cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/app-layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ static int TCPProtoDetect(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
PACKET_PROFILING_APP_START(app_tctx, f->alproto);
int r = AppLayerParserParse(tv, app_tctx->alp_tctx, f, f->alproto,
flags, data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
PACKET_PROFILING_APP_END(app_tctx);
p->app_update_direction = (uint8_t)dir;
if (r != 1) {
StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
Expand Down Expand Up @@ -593,7 +593,7 @@ static int TCPProtoDetect(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
int r = AppLayerParserParse(tv, app_tctx->alp_tctx, f,
f->alproto, flags,
data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
PACKET_PROFILING_APP_END(app_tctx);
p->app_update_direction = (uint8_t)dir;
if (r != 1) {
StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
Expand Down Expand Up @@ -701,7 +701,7 @@ int AppLayerHandleTCPData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, Packet
PACKET_PROFILING_APP_START(app_tctx, f->alproto);
r = AppLayerParserParse(tv, app_tctx->alp_tctx, f, f->alproto,
flags, data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
PACKET_PROFILING_APP_END(app_tctx);
p->app_update_direction = (uint8_t)dir;
/* ignore parser result for gap */
StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
Expand Down Expand Up @@ -786,7 +786,7 @@ int AppLayerHandleTCPData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, Packet
PACKET_PROFILING_APP_START(app_tctx, f->alproto);
r = AppLayerParserParse(tv, app_tctx->alp_tctx, f, f->alproto,
flags, data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
PACKET_PROFILING_APP_END(app_tctx);
p->app_update_direction = (uint8_t)dir;
if (r != 1) {
StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
Expand Down Expand Up @@ -911,7 +911,7 @@ int AppLayerHandleUdp(ThreadVars *tv, AppLayerThreadCtx *tctx, Packet *p, Flow *
PACKET_PROFILING_APP_START(tctx, f->alproto);
r = AppLayerParserParse(tv, tctx->alp_tctx, f, f->alproto,
flags, p->payload, p->payload_len);
PACKET_PROFILING_APP_END(tctx, f->alproto);
PACKET_PROFILING_APP_END(tctx);
p->app_update_direction = (uint8_t)UPDATE_DIR_PACKET;
}
PACKET_PROFILING_APP_STORE(tctx, p);
Expand All @@ -927,7 +927,7 @@ int AppLayerHandleUdp(ThreadVars *tv, AppLayerThreadCtx *tctx, Packet *p, Flow *
PACKET_PROFILING_APP_START(tctx, f->alproto);
r = AppLayerParserParse(tv, tctx->alp_tctx, f, f->alproto,
flags, p->payload, p->payload_len);
PACKET_PROFILING_APP_END(tctx, f->alproto);
PACKET_PROFILING_APP_END(tctx);
PACKET_PROFILING_APP_STORE(tctx, p);
p->app_update_direction = (uint8_t)UPDATE_DIR_PACKET;
}
Expand Down
15 changes: 7 additions & 8 deletions src/util-profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ PktProfiling *SCProfilePacketStart(void);
(dp)->alproto = (id); \
}

#define PACKET_PROFILING_APP_END(dp, id) \
if (profiling_packets_enabled) { \
BUG_ON((id) != (dp)->alproto); \
(dp)->ticks_end = UtilCpuGetTicks(); \
if ((dp)->ticks_start != 0 && (dp)->ticks_start < ((dp)->ticks_end)) { \
(dp)->ticks_spent = ((dp)->ticks_end - (dp)->ticks_start); \
} \
#define PACKET_PROFILING_APP_END(dp) \
if (profiling_packets_enabled) { \
(dp)->ticks_end = UtilCpuGetTicks(); \
if ((dp)->ticks_start != 0 && (dp)->ticks_start < ((dp)->ticks_end)) { \
(dp)->ticks_spent = ((dp)->ticks_end - (dp)->ticks_start); \
} \
}

#define PACKET_PROFILING_APP_PD_START(dp) \
Expand Down Expand Up @@ -340,7 +339,7 @@ void SCProfilingDump(void);
#define PACKET_PROFILING_RESET(p)

#define PACKET_PROFILING_APP_START(dp, id)
#define PACKET_PROFILING_APP_END(dp, id)
#define PACKET_PROFILING_APP_END(d)
#define PACKET_PROFILING_APP_RESET(dp)
#define PACKET_PROFILING_APP_STORE(dp, p)

Expand Down

0 comments on commit b43b2cd

Please sign in to comment.