http.memcap as well.
return;
}
-void HTPMemuseCounter(ThreadVars *tv, TcpReassemblyThreadCtx *trt)
+uint64_t HTPMemuseGlobalCounter(void)
{
uint64_t tmpval = SC_ATOMIC_GET(htp_memuse);
- StatsSetUI64(tv, trt->counter_htp_memuse, tmpval);
- tmpval = SC_ATOMIC_GET(htp_memcap);
- StatsSetUI64(tv, trt->counter_htp_memcap, tmpval);
- return;
+ return tmpval;
}
+
+uint64_t HTPMemcapGlobalCounter(void)
+{
+ uint64_t tmpval = SC_ATOMIC_GET(htp_memcap);
+ return tmpval;
+}
+
/**
* \brief Check if alloc'ing "size" would mean we're over memcap
*
void *HTPRealloc(void *ptr, size_t orig_size, size_t size);
void HTPFree(void *ptr, size_t size);
-
-void HTPMemuseCounter(ThreadVars *tv, TcpReassemblyThreadCtx *trt);
+uint64_t HTPMemuseGlobalCounter(void);
+uint64_t HTPMemcapGlobalCounter(void);
#include "debug.h"
#include "decode.h"
#include "threads.h"
+#include "counters.h"
#include "util-print.h"
#include "util-pool.h"
HTPConfigSetDefaultsPhase2(s->name, htprec);
}
+ StatsRegisterGlobalCounter("http.memuse", HTPMemuseGlobalCounter);
+ StatsRegisterGlobalCounter("http.memcap", HTPMemcapGlobalCounter);
+
SCReturn;
}
}
/** \fixme a bit hacky but will be improved in 2.1 */
- if (*alproto == ALPROTO_HTTP)
- HTPMemuseCounter(tv, ra_ctx);
- else if (*alproto == ALPROTO_DNS)
+ if (*alproto == ALPROTO_DNS)
DNSUpdateCounters(tv, app_tctx);
goto end;
failure:
uint16_t counter_tcp_stream_depth;
/** count number of streams with a unrecoverable stream gap (missing pkts) */
uint16_t counter_tcp_reass_gap;
- /** account memory usage by suricata to handle HTTP protocol (not counting
- * libhtp memory usage)*/
- uint16_t counter_htp_memuse;
- /* number of allocation failed due to memcap when handling HTTP protocol */
- uint16_t counter_htp_memcap;
#ifdef DEBUG
uint64_t fp1;
uint64_t fp2;
#include "app-layer.h"
#include "app-layer-parser.h"
#include "app-layer-protos.h"
+#include "app-layer-htp-mem.h"
#include "util-host-os-info.h"
#include "util-privs.h"
stt->ra_ctx->counter_tcp_segment_memcap = StatsRegisterCounter("tcp.segment_memcap_drop", tv);
stt->ra_ctx->counter_tcp_stream_depth = StatsRegisterCounter("tcp.stream_depth_reached", tv);
stt->ra_ctx->counter_tcp_reass_gap = StatsRegisterCounter("tcp.reassembly_gap", tv);
- /** \fixme Find a better place in 2.1 as it is linked with app layer */
- stt->ra_ctx->counter_htp_memuse = StatsRegisterCounter("http.memuse", tv);
- stt->ra_ctx->counter_htp_memcap = StatsRegisterCounter("http.memcap", tv);
SCLogDebug("StreamTcp thread specific ctx online at %p, reassembly ctx %p",
stt, stt->ra_ctx);