Squashed commit of the following:
commit
cc4a642b171b30b844f78f3c50ea5bccb6fb42ea
Author: Sreeja Athirkandathil Narayanan <sathirka@cisco.com>
Date: Tue May 12 15:08:28 2020 -0400
appid: Do not allocate DNS session for non-DNS flows and update memory tracker for HTTP sessions
#include "appid_http_session.h"
+#include "memory/memory_cap.h"
#include "profiler/profiler.h"
#include "app_info_table.h"
meta_offset[i].first = 0;
meta_offset[i].second = 0;
}
+ memory::MemoryCap::update_allocations(sizeof(AppIdHttpSession));
}
AppIdHttpSession::~AppIdHttpSession()
delete meta_data[i];
if (tun_dest)
delete tun_dest;
+ memory::MemoryCap::update_deallocations(sizeof(AppIdHttpSession));
}
void AppIdHttpSession::free_chp_matches(ChpMatchDescriptor& cmd, unsigned num_matches)
return nullptr;
}
+AppIdDnsSession* AppIdSession::create_dns_session()
+{
+ if (dsession)
+ delete dsession;
+ dsession = new AppIdDnsSession();
+ return dsession;
+}
+
AppIdDnsSession* AppIdSession::get_dns_session()
{
- if (!dsession)
- dsession = new AppIdDnsSession();
return dsession;
}
hsessions.clear();
}
+ AppIdDnsSession* create_dns_session();
AppIdDnsSession* get_dns_session();
bool is_tp_appid_done() const;
const uint8_t* host, uint8_t host_len, uint16_t host_offset, uint16_t record_type)
{
AppIdDnsSession* dsession = asd.get_dns_session();
+ if (!dsession)
+ dsession = asd.create_dns_session();
if ( ( dsession->get_state() != 0 ) && ( dsession->get_id() != id ) )
dsession->reset();
const uint8_t* host, uint8_t host_len, uint16_t host_offset, uint8_t response_type, uint32_t ttl)
{
AppIdDnsSession* dsession = asd.get_dns_session();
+ if (!dsession)
+ dsession = asd.create_dns_session();
if ( ( dsession->get_state() != 0 ) && ( dsession->get_id() != id ) )
dsession->reset();
else if (!hdr->QR) // Query.
{
if (host_reporting)
- asd.get_dns_session()->reset();
+ {
+ AppIdDnsSession* dsession = asd.get_dns_session();
+ if (dsession)
+ dsession->reset();
+ }
return dir == APP_ID_FROM_INITIATOR ? APPID_SUCCESS : APPID_REVERSED;
}
else // Response.
}
AppIdDnsSession* dsession = asd.get_dns_session();
- if (asd.service.get_id() == APP_ID_DNS && asd.ctxt.get_odp_ctxt().dns_host_reporting
- && dsession->get_host())
+ if (dsession and asd.service.get_id() == APP_ID_DNS
+ and asd.ctxt.get_odp_ctxt().dns_host_reporting and dsession->get_host())
{
AppId client_id = APP_ID_NONE;
AppId payload_id = APP_ID_NONE;
#include <string>
#include "framework/data_bus.h"
+#include "memory/memory_cap.h"
#include "protocols/protocol_ids.h"
#include "service_inspectors/http_inspect/http_msg_header.h"
#include "tp_appid_module_api.h"
MemoryContext::MemoryContext(MemoryTracker&) { }
MemoryContext::~MemoryContext() { }
+void memory::MemoryCap::update_allocations(unsigned long) { }
+void memory::MemoryCap::update_deallocations(unsigned long) { }
OdpContext::OdpContext(AppIdConfig&, snort::SnortConfig*) { }
AppIdConfig::~AppIdConfig() { }
return nullptr;
}
-AppIdDnsSession* AppIdSession::get_dns_session()
+AppIdDnsSession* AppIdSession::create_dns_session()
{
if ( !dsession )
dsession = new MockAppIdDnsSession();
return dsession;
}
+AppIdDnsSession* AppIdSession::get_dns_session()
+{
+ return dsession;
+}
+
bool AppIdSession::is_tp_appid_done() const
{
return true;