From: Michael Altizer (mialtize) Date: Thu, 8 Sep 2016 19:33:14 +0000 (-0400) Subject: Merge pull request #615 in SNORT/snort3 from ha-tcp-stream to master X-Git-Tag: 3.0.0-233~267 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0947bbdf1a9f739d92f6ea9bd9ebe725edf445af;p=thirdparty%2Fsnort3.git Merge pull request #615 in SNORT/snort3 from ha-tcp-stream to master Squashed commit of the following: commit 8ed6a1c5d87cafdf9fd3319a8ae41b65378207d5 Author: Ed Borgoyn Date: Wed Sep 7 13:10:29 2016 -0400 Needed additional calls to *HAManager::process_deletion() commit 8d921b570018695ce9db9b308c8d730d18133afe Author: Ed Borgoyn Date: Fri Sep 2 12:58:05 2016 -0400 Updates got TCP flow HA. --- diff --git a/src/stream/ip/ip_session.cc b/src/stream/ip/ip_session.cc index 68fa2ff1e..34390a12b 100644 --- a/src/stream/ip/ip_session.cc +++ b/src/stream/ip/ip_session.cc @@ -177,6 +177,7 @@ int IpSession::process(Packet* p) if ( flow_con->expected_session(flow, p)) return 0; #endif + IpHAManager::process_deletion(flow); } if ( stream.blocked_session(flow, p) || stream.ignored_session(flow, p) ) diff --git a/src/stream/libtcp/tcp_stream_session.cc b/src/stream/libtcp/tcp_stream_session.cc index e7d4c883a..2a56fa616 100644 --- a/src/stream/libtcp/tcp_stream_session.cc +++ b/src/stream/libtcp/tcp_stream_session.cc @@ -22,6 +22,7 @@ #include "log/messages.h" #include "main/snort_debug.h" #include "sfip/sf_ip.h" +#include "stream/tcp/tcp_ha.h" #include "tcp_stream_session.h" @@ -437,6 +438,7 @@ void TcpStreamSession::clear() if ( tcp_init ) // this does NOT flush data clear_session( true, false, false ); + TcpHAManager::process_deletion(flow); } void TcpStreamSession::set_splitter(bool to_server, StreamSplitter* ss) diff --git a/src/stream/tcp/tcp_ha.cc b/src/stream/tcp/tcp_ha.cc index ad2c394a6..85b9ac231 100644 --- a/src/stream/tcp/tcp_ha.cc +++ b/src/stream/tcp/tcp_ha.cc @@ -41,9 +41,18 @@ Flow* TcpHA::create_session(FlowKey* key) } -void TcpHA::deactivate_session(Flow*) +void TcpHA::deactivate_session(Flow* flow) { DebugMessage(DEBUG_HA,"TcpHA::deactivate_session)\n"); + assert( flow ); + if ( flow->session ) + ((TcpSession*)(flow->session))->clear_session(true, true, false); + + flow->session_state &= ~( STREAM_STATE_SYN | STREAM_STATE_SYN_ACK | + STREAM_STATE_ACK | STREAM_STATE_ESTABLISHED ); + + assert( flow->ha_state ); + flow->clear_session_flags( SSNFLAG_SEEN_CLIENT | SSNFLAG_SEEN_SERVER ); } THREAD_LOCAL TcpHA* TcpHAManager::tcp_ha = nullptr; diff --git a/src/stream/tcp/tcp_session.cc b/src/stream/tcp/tcp_session.cc index 06197f662..b77d971fa 100644 --- a/src/stream/tcp/tcp_session.cc +++ b/src/stream/tcp/tcp_session.cc @@ -1043,6 +1043,7 @@ void TcpSession::cleanup_session_if_expired(Packet* p) clear_session(true, true, false, p); tcpStats.timeouts++; + TcpHAManager::process_deletion(flow); } } diff --git a/src/stream/udp/udp_session.cc b/src/stream/udp/udp_session.cc index 0b091ea81..87d6fd396 100644 --- a/src/stream/udp/udp_session.cc +++ b/src/stream/udp/udp_session.cc @@ -200,6 +200,7 @@ int UdpSession::process(Packet* p) flow->ssn_state.session_flags |= SSNFLAG_SEEN_SENDER; udpStats.created++; // FIXIT-M is this correct? will mess with calc of current sessions udpStats.timeouts++; + UdpHAManager::process_deletion(flow); } ProcessUdp(flow, p, pc, nullptr);