From: Steve Chew (stechew) Date: Mon, 11 Apr 2022 18:56:33 +0000 (+0000) Subject: Pull request #3332: stream: add can_set_no_ack_mode() api to check if policy allows... X-Git-Tag: 3.1.28.0~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0daf99e36ef635f2b04d2c5615e380597bbbdb9;p=thirdparty%2Fsnort3.git Pull request #3332: stream: add can_set_no_ack_mode() api to check if policy allows no-ack mode Merge in SNORT/snort3 from ~SBAIGAL/snort3:ok2noack to master Squashed commit of the following: commit f0de602d7c910b796ec11da3e1ffd7d42356960c Author: Steven Baigal (sbaigal) Date: Wed Mar 30 21:49:46 2022 -0400 stream: add can_set_no_ack() api to check if policy allows no-ack mode --- diff --git a/src/stream/stream.cc b/src/stream/stream.cc index 1799d927f..45abb8bfb 100644 --- a/src/stream/stream.cc +++ b/src/stream/stream.cc @@ -813,12 +813,20 @@ bool Stream::set_packet_action_to_hold(Packet* p) return p->flow->session->set_packet_action_to_hold(p); } -void Stream::set_no_ack_mode(Flow* flow, bool on_off) +bool Stream::can_set_no_ack_mode(Flow* flow) { assert(flow and flow->session and flow->pkt_type == PktType::TCP); TcpStreamSession* tcp_session = (TcpStreamSession*)flow->session; - tcp_session->set_no_ack(on_off); + return tcp_session->can_set_no_ack(); +} + +bool Stream::set_no_ack_mode(Flow* flow, bool on_off) +{ + assert(flow and flow->session and flow->pkt_type == PktType::TCP); + + TcpStreamSession* tcp_session = (TcpStreamSession*)flow->session; + return tcp_session->set_no_ack(on_off); } void Stream::partial_flush(Flow* flow, bool to_server) diff --git a/src/stream/stream.h b/src/stream/stream.h index 543d61c71..064f369f8 100644 --- a/src/stream/stream.h +++ b/src/stream/stream.h @@ -240,7 +240,8 @@ public: static uint8_t get_tcp_options_len(Flow*, bool to_server); static bool set_packet_action_to_hold(Packet*); - static void set_no_ack_mode(Flow*, bool); + static bool can_set_no_ack_mode(Flow*); + static bool set_no_ack_mode(Flow*, bool); static void partial_flush(Flow*, bool to_server); static bool get_held_pkt_seq(Flow*, uint32_t&); diff --git a/src/stream/tcp/tcp_stream_session.cc b/src/stream/tcp/tcp_stream_session.cc index fe60df949..da6c6f3e6 100644 --- a/src/stream/tcp/tcp_stream_session.cc +++ b/src/stream/tcp/tcp_stream_session.cc @@ -130,13 +130,21 @@ void TcpStreamSession::update_session_on_client_packet(TcpSegmentDescriptor& tsd flow->set_ttl(tsd.get_pkt(), true); } -void TcpStreamSession::set_no_ack(bool b) +bool TcpStreamSession::can_set_no_ack() { - if ( server.get_flush_policy() == STREAM_FLPOLICY_ON_DATA and - client.get_flush_policy() == STREAM_FLPOLICY_ON_DATA ) + return ( server.get_flush_policy() == STREAM_FLPOLICY_ON_DATA and + client.get_flush_policy() == STREAM_FLPOLICY_ON_DATA ); +} + +bool TcpStreamSession::set_no_ack(bool b) +{ + if ( can_set_no_ack() ) { no_ack = b; + return true; } + else + return false; } void TcpStreamSession::disable_reassembly(Flow* f) diff --git a/src/stream/tcp/tcp_stream_session.h b/src/stream/tcp/tcp_stream_session.h index 96c0be974..d65ccd12b 100644 --- a/src/stream/tcp/tcp_stream_session.h +++ b/src/stream/tcp/tcp_stream_session.h @@ -66,7 +66,8 @@ public: void set_packet_header_foo(const TcpSegmentDescriptor&); void get_packet_header_foo(DAQ_PktHdr_t*, uint32_t dir); - void set_no_ack(bool); + bool can_set_no_ack(); + bool set_no_ack(bool); bool no_ack_mode_enabled() { return no_ack; } virtual void update_perf_base_state(char) = 0; virtual void clear_session(