diff --git a/plugins/ndpi/ndpi.c b/plugins/ndpi/ndpi.c index ad6cd78b7d..814661c1e5 100644 --- a/plugins/ndpi/ndpi.c +++ b/plugins/ndpi/ndpi.c @@ -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); + /* 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; } - /* Ignore packets that have a different protocol than the - * flow. This can happen with ICMP unreachable packets. */ - if (p->proto != f->proto) { - return; - } - if (PacketIsIPv4(p)) { const IPV4Hdr *ip4h = PacketGetIPv4(p); ip_len = IPV4_GET_RAW_IPLEN(ip4h);