diff --git a/src/decode.c b/src/decode.c index 7980e20195..209a55080c 100644 --- a/src/decode.c +++ b/src/decode.c @@ -384,8 +384,18 @@ void PacketDefragPktSetupParent(Packet *parent) void PacketBypassCallback(Packet *p) { - if (p->BypassPacketsFlow) { - p->BypassPacketsFlow(p); + /* Don't try to bypass if flow is already out or + * if we have failed to do it once */ + int state = SC_ATOMIC_GET(p->flow->flow_state); + if ((state == FLOW_STATE_LOCAL_BYPASSED) || + (state == FLOW_STATE_CAPTURE_BYPASSED)) { + return; + } + + if (p->BypassPacketsFlow && p->BypassPacketsFlow(p)) { + FlowUpdateState(p->flow, FLOW_STATE_CAPTURE_BYPASSED); + } else { + FlowUpdateState(p->flow, FLOW_STATE_LOCAL_BYPASSED); } }