http: make http.memuse a global counter

http.memcap as well.
pull/1508/head
Victor Julien 11 years ago
parent f05d0692ef
commit cddbb0f606

@ -78,14 +78,18 @@ void HTPDecrMemuse(uint64_t size)
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
*

@ -22,5 +22,5 @@ void *HTPMalloc(size_t size);
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);

@ -38,6 +38,7 @@
#include "debug.h"
#include "decode.h"
#include "threads.h"
#include "counters.h"
#include "util-print.h"
#include "util-pool.h"
@ -2546,6 +2547,9 @@ void HTPConfigure(void)
HTPConfigSetDefaultsPhase2(s->name, htprec);
}
StatsRegisterGlobalCounter("http.memuse", HTPMemuseGlobalCounter);
StatsRegisterGlobalCounter("http.memcap", HTPMemcapGlobalCounter);
SCReturn;
}

@ -435,9 +435,7 @@ int AppLayerHandleTCPData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
}
/** \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:

@ -59,11 +59,6 @@ typedef struct TcpReassemblyThreadCtx_ {
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;

@ -65,6 +65,7 @@
#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"
@ -5092,9 +5093,6 @@ TmEcode StreamTcpThreadInit(ThreadVars *tv, void *initdata, void **data)
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);

Loading…
Cancel
Save