We’re seeing some odd behaviour with suricata and smb (and maybe other TCP based app protocols in general). Basically, if an existing flow times out, and a new flow is created, the new flow would never enter established state.
In this case, the ssn->state never advances, as there are no more tcp handshakes going on. But obviously the tcp connection is active with packets from both ends. This seems to bypass some rules that checks for the established state. Can someone please advise if this is working as expected or a bug?
if (f->flow_state == FLOW_STATE_ESTABLISHED) {
SCLogDebug("pkt %p FLOW_PKT_ESTABLISHED", p);
p->flowflags |= FLOW_PKT_ESTABLISHED;
} else if (f->proto == IPPROTO_TCP) {
TcpSession *ssn = (TcpSession *)f->protoctx;
if (ssn != NULL && ssn->state >= TCP_ESTABLISHED) {
p->flowflags |= FLOW_PKT_ESTABLISHED;
}
} else if ((f->flags & (FLOW_TO_DST_SEEN|FLOW_TO_SRC_SEEN)) ==
(FLOW_TO_DST_SEEN|FLOW_TO_SRC_SEEN)) {
SCLogDebug("pkt %p FLOW_PKT_ESTABLISHED", p);
p->flowflags |= FLOW_PKT_ESTABLISHED;
FlowUpdateState(f, FLOW_STATE_ESTABLISHED);
}