]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3332: stream: add can_set_no_ack_mode() api to check if policy allows...
authorSteve Chew (stechew) <stechew@cisco.com>
Mon, 11 Apr 2022 18:56:33 +0000 (18:56 +0000)
committerSteve Chew (stechew) <stechew@cisco.com>
Mon, 11 Apr 2022 18:56:33 +0000 (18:56 +0000)
Merge in SNORT/snort3 from ~SBAIGAL/snort3:ok2noack to master

Squashed commit of the following:

commit f0de602d7c910b796ec11da3e1ffd7d42356960c
Author: Steven Baigal (sbaigal) <sbaigal@cisco.com>
Date:   Wed Mar 30 21:49:46 2022 -0400

    stream: add can_set_no_ack() api to check if policy allows no-ack mode

src/stream/stream.cc
src/stream/stream.h
src/stream/tcp/tcp_stream_session.cc
src/stream/tcp/tcp_stream_session.h

index 1799d927f6dc47dd769b49095625857cb9a196fa..45abb8bfbe5d72e744e9d92a0a0c8e511c24017e 100644 (file)
@@ -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)
index 543d61c71f941cc91e3913c6bc93f7b5af22790a..064f369f877966780896cdd1d41c9cea78a0fb3b 100644 (file)
@@ -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&);
index fe60df949eef233f1b513a4179dfd247db7c6592..da6c6f3e6b8dceab9d0210d3ca4f6fa86b5bb825 100644 (file)
@@ -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)
index 96c0be97402dda267bfe7c2d9cd0448a0dc7e3f6..d65ccd12bec9a3a7b0a0cb99be8bd1c6840f75a7 100644 (file)
@@ -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(