mirror of
https://github.com/OISF/suricata.git
synced 2026-10-12 02:07:10 +00:00
ndpi: minor optimization
Check protocol before doing more expensive work.
This commit is contained in:
+9
-9
@@ -92,21 +92,21 @@ static void OnFlowInit(ThreadVars *tv, Flow *f, const Packet *p, void *_data)
|
||||
|
||||
static void OnFlowUpdate(ThreadVars *tv, Flow *f, Packet *p, void *_data)
|
||||
{
|
||||
struct NdpiThreadContext *threadctx = ThreadGetStorageById(tv, thread_storage_id);
|
||||
struct NdpiFlowContext *flowctx = FlowGetStorageById(f, flow_storage_id);
|
||||
uint16_t ip_len = 0;
|
||||
void *ip_ptr = NULL;
|
||||
|
||||
if (!threadctx->ndpi || !flowctx->ndpi_flow) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ignore packets that have a different protocol than the
|
||||
* flow. This can happen with ICMP unreachable packets. */
|
||||
if (p->proto != f->proto) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t ip_len = 0;
|
||||
void *ip_ptr = NULL;
|
||||
struct NdpiThreadContext *threadctx = ThreadGetStorageById(tv, thread_storage_id);
|
||||
struct NdpiFlowContext *flowctx = FlowGetStorageById(f, flow_storage_id);
|
||||
|
||||
if (!threadctx->ndpi || !flowctx->ndpi_flow) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PacketIsIPv4(p)) {
|
||||
const IPV4Hdr *ip4h = PacketGetIPv4(p);
|
||||
ip_len = IPV4_GET_RAW_IPLEN(ip4h);
|
||||
|
||||
Reference in New Issue
Block a user