ndpi: minor optimization

Check protocol before doing more expensive work.

(cherry picked from commit 28ba93e60c)
pull/14993/head
Victor Julien 2 months ago
parent 7c24721f72
commit 6e6e12e42b

@ -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);

Loading…
Cancel
Save