]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Fix two memory leaks, a few build warnings, and removed a remnant #include.
authorEd Borgoyn <eborgoyn@cisco.com>
Fri, 22 Apr 2016 18:01:15 +0000 (14:01 -0400)
committerEd Borgoyn <eborgoyn@cisco.com>
Fri, 22 Apr 2016 18:02:48 +0000 (14:02 -0400)
src/flow/ha.cc
src/flow/ha.h
src/flow/ha_module.cc
src/side_channel/side_channel_module.h
src/side_channel/test/side_channel_test.cc
src/stream/base/stream_base.cc
src/stream/base/stream_ha.cc
src/stream/base/stream_ha.h
src/stream/udp/stream_udp.cc
src/stream/udp/udp_ha.cc
src/stream/udp/udp_ha.h

index a0f8745592bdf2fdde838a7f29e89b6ad07b191d..8bd639f2a9d9d140279dce33a0d0843715c779de 100644 (file)
@@ -205,6 +205,7 @@ static uint8_t write_flow_key(Flow* flow, HAMessage* msg)
     }
 }
 
+#ifdef FUTURE
 // Regardless of the message cursor, extract the key and
 // return the key length.  Position the cursor just after the key.
 static uint8_t read_flow_key(FlowKey* key, HAMessage* msg)
@@ -239,6 +240,7 @@ static uint8_t read_flow_key(FlowKey* key, HAMessage* msg)
     else
         return 0;
 }
+#endif
 
 static inline uint8_t key_size(Flow* flow)
 {
@@ -357,6 +359,7 @@ void HighAvailability::process_update(Flow* flow, const DAQ_PktHdr_t* pkthdr)
     DebugMessage(DEBUG_HA,"HighAvailability::process_update()\n");
 
     // Only looking for side channel processing - FIXIT-H
+    UNUSED(pkthdr); // until we add DAQ communications channel
     if ( !sc || !flow )
         return;
 
index f7088299a4ddd35b041f028daa649d0679ee3938..286b806cad54e7478aa0522598dae377874f3f1f 100644 (file)
@@ -20,8 +20,6 @@
 #ifndef HA_H
 #define HA_H
 
-#include <values.h>
-
 #include "main/snort_types.h"
 #include "packet_io/sfdaq.h"
 #include "side_channel/side_channel.h"
@@ -150,7 +148,6 @@ public:
 private:
     void receive_handler(SCMessage*);
     SideChannel* sc = nullptr;
-    bool enabled = false;
 };
 
 // Top level management of HighAvailability components.
index 0d363c7c7eef7ae8faeccb0570236a4585bae301..d9ce42c0990702f97ff1c2083b19b062992233a2 100644 (file)
@@ -113,6 +113,7 @@ bool HighAvailabilityModule::end(const char* fqn, int idx, SnortConfig*)
     DebugFormat(DEBUG_HA,"HighAvailabilityModule::end(): %s %d\n", fqn, idx);
 #else
     UNUSED(fqn);
+    UNUSED(idx);
 #endif
 
     if ( config.enabled && !HighAvailabilityManager::instantiate(config.ports,config.daq_channel) )
index 4ff161fe06bb41ff6ee8505a4de002e8884ba8b9..c0f468f1819e03206acbe840c44e50c30994390f 100644 (file)
@@ -34,7 +34,6 @@
 struct SideChannelConfig
 {
     PortBitSet* ports = nullptr;
-    Connector::Direction direction = Connector::CONN_UNDEFINED;
     SCConnectors connectors;
 };
 
index 69d4d03e6408873c5a3f2fb85dcbfa8cf459a517..455b71b1503c8c9dfb5d12305ed30ab4e1d8a500 100644 (file)
@@ -39,12 +39,41 @@ class TestConnector : public Connector
     Direction get_connector_direction() { return CONN_UNDEFINED; }
 };
 
+class ReceiveConnector : public Connector
+{
+    ConnectorMsgHandle* alloc_message(const uint32_t, const uint8_t**) { return nullptr; }
+    void discard_message(ConnectorMsgHandle*) { }
+    bool transmit_message(ConnectorMsgHandle*) { return true; }
+    ConnectorMsgHandle* receive_message(bool) { return nullptr; }
+    ConnectorMsg* get_connector_msg(ConnectorMsgHandle*) { return nullptr; }
+    Direction get_connector_direction() { return CONN_RECEIVE; }
+};
+
+class TransmitConnector : public Connector
+{
+    ConnectorMsgHandle* alloc_message(const uint32_t, const uint8_t**) { return nullptr; }
+    void discard_message(ConnectorMsgHandle*) { }
+    bool transmit_message(ConnectorMsgHandle*) { return true; }
+    ConnectorMsgHandle* receive_message(bool) { return nullptr; }
+    ConnectorMsg* get_connector_msg(ConnectorMsgHandle*) { return nullptr; }
+    Direction get_connector_direction() { return CONN_TRANSMIT; }
+};
+
 void ConnectorManager::thread_init() { }
 
 void ConnectorManager::thread_term() { }
 
 Connector* ConnectorManager::get_connector(const std::string connector_name)
-{ UNUSED(connector_name); return new TestConnector(); }
+{
+    if ( connector_name == "U" )
+        return new TestConnector();
+    else if ( connector_name == "R" )
+        return new ReceiveConnector();
+    else if ( connector_name == "T" )
+        return new TransmitConnector();
+    else
+        return nullptr;
+}
 
 void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 
@@ -56,6 +85,13 @@ void Debug::print(const char*, int, uint64_t, const char*, ...) { }
 
 TEST_GROUP(side_channel)
 {
+    void setup()
+    {
+    }
+
+    void teardown()
+    {
+    }
 };
 
 TEST(side_channel, test)
index 32dcee92b645fa78b088e9afbcd846c9ad81d383..cd2bd06e962c3b3db04651f8ddf40c9c414d592a 100644 (file)
@@ -221,6 +221,8 @@ void StreamBase::tterm()
     flow_con->purge_flows(PktType::UDP);
     flow_con->purge_flows(PktType::PDU);
     flow_con->purge_flows(PktType::FILE);
+
+    StreamHAManager::tterm();
 }
 
 void StreamBase::show(SnortConfig*)
index 2ae3d8887fac8c41558b589ff4356e5f610f1688..80691dbf112b37e3d00e318c52e52686ebe3942c 100644 (file)
@@ -57,6 +57,11 @@ void StreamHAManager::tinit()
     ha_client = new StreamHAClient();
 }
 
+void StreamHAManager::tterm()
+{
+    delete ha_client;
+}
+
 void StreamHAManager::process_deletion(Flow*)
 {
 }
index 56a70b0d621f8e12440291169dd5c03f317705b5..3b9845a6432513bee423e60b9c239e573f1134e9 100644 (file)
@@ -42,6 +42,7 @@ class ProtocolHA
 {
 public:
     ProtocolHA();
+    virtual ~ProtocolHA() { }
     virtual void delete_session(Flow*) { }
     virtual void create_session(Flow*) { }
     virtual void deactivate_session(Flow*) { }
@@ -54,6 +55,7 @@ class StreamHAManager
 {
 public:
     static void tinit();
+    static void tterm();
     static void process_deletion(Flow*);
 
     static StreamHAClient* ha_client;
index 6be438a7ed83433eea2f98ef37e9a5c1744acd0e..e2757ff769d828e497c0a2c2fae23a92ef4aaeeb 100644 (file)
@@ -117,6 +117,11 @@ static void udp_tinit()
     UdpHAManager::tinit();
 }
 
+static void udp_tterm()
+{
+    UdpHAManager::tterm();
+}
+
 static Inspector* udp_ctor(Module* m)
 {
     StreamUdpModule* mod = (StreamUdpModule*)m;
@@ -149,7 +154,7 @@ static const InspectApi udp_api =
     nullptr, // init
     nullptr, // term
     udp_tinit, // tinit
-    nullptr, // tterm
+    udp_tterm, // tterm
     udp_ctor,
     udp_dtor,
     udp_ssn,
index db08c051de6a9b8a1515ba7e07b4a2b7f58b40e2..2161a983de48a83b7ca1cb91b64bd96d613eec29 100644 (file)
@@ -38,3 +38,8 @@ void UdpHAManager::tinit()
     udp_ha = new UdpHA();
 }
 
+void UdpHAManager::tterm()
+{
+    delete udp_ha;
+}
+
index 4df688f95bf63228e770b1066d1d1f312f52c7e4..4e31b62d5b79b357868c589562ca3d837b6b0038 100644 (file)
@@ -43,6 +43,7 @@ public:
     static void process_deletion(Flow* flow)
     { udp_ha->process_deletion(flow); }
     static void tinit();
+    static void tterm();
     static UdpHA* udp_ha;
 };
 #endif