output/flush: Remove flush functions/registration

Remove log flush functions and update registration logic as
context-based flushing doesn't require it.

Issue: 8286
(cherry picked from commit 1923ca1aa0)
pull/15343/head
Jeff Lucovsky 5 months ago committed by Victor Julien
parent e1e43fd8f7
commit 9376742dc8

@ -482,7 +482,6 @@ void AlertDebugLogRegister(void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = AlertDebugLogLogger,
.FlushFunc = NULL,
.ConditionFunc = AlertDebugLogCondition,
.ThreadInitFunc = AlertDebugLogThreadInit,
.ThreadDeinitFunc = AlertDebugLogThreadDeinit,

@ -78,7 +78,6 @@ void AlertFastLogRegister(void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = AlertFastLogger,
.FlushFunc = NULL,
.ConditionFunc = AlertFastLogCondition,
.ThreadInitFunc = AlertFastLogThreadInit,
.ThreadDeinitFunc = AlertFastLogThreadDeinit,

@ -386,7 +386,6 @@ void AlertSyslogRegister (void)
#ifndef OS_WIN32
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = AlertSyslogLogger,
.FlushFunc = NULL,
.ConditionFunc = AlertSyslogCondition,
.ThreadInitFunc = AlertSyslogThreadInit,
.ThreadDeinitFunc = AlertSyslogThreadDeinit,

@ -31,18 +31,6 @@
#include "util-privs.h"
#include "util-logopenfile.h"
/**
* \brief Trigger flush of all registered log files
*
* This function is intended to be called at regular intervals to force
* buffered log data to be persisted. With the new design, this simply calls
* LogFileFlushAll() which directly flushes all registered file contexts.
*/
static void WorkerFlushLogs(void)
{
LogFileFlushAll();
}
int OutputFlushInterval(void)
{
intmax_t output_flush_interval = 0;

@ -220,7 +220,6 @@ void PcapLogRegister(void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = PcapLog,
.FlushFunc = NULL,
.ConditionFunc = PcapLogCondition,
.ThreadInitFunc = PcapLogDataInit,
.ThreadDeinitFunc = PcapLogDataDeinit,

@ -454,7 +454,6 @@ void EveStreamLogRegister(void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = EveStreamLogger,
.FlushFunc = OutputJsonLogFlush,
.ConditionFunc = EveStreamLogCondition,
.ThreadInitFunc = EveStreamLogThreadInit,
.ThreadDeinitFunc = EveStreamLogThreadDeinit,

@ -854,14 +854,6 @@ static int AlertJsonDecoderEvent(ThreadVars *tv, JsonAlertLogThread *aft, const
return TM_ECODE_OK;
}
static int JsonAlertFlush(ThreadVars *tv, void *thread_data, const Packet *p)
{
JsonAlertLogThread *aft = thread_data;
SCLogDebug("%s flushing %s", tv->name, ((LogFileCtx *)(aft->ctx->file_ctx))->filename);
OutputJsonFlush(aft->ctx);
return 0;
}
static int JsonAlertLogger(ThreadVars *tv, void *thread_data, const Packet *p)
{
JsonAlertLogThread *aft = thread_data;
@ -1109,7 +1101,6 @@ void JsonAlertLogRegister (void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = JsonAlertLogger,
.FlushFunc = JsonAlertFlush,
.ConditionFunc = JsonAlertLogCondition,
.ThreadInitFunc = JsonAlertLogThreadInit,
.ThreadDeinitFunc = JsonAlertLogThreadDeinit,

@ -271,14 +271,6 @@ static int AnomalyJson(ThreadVars *tv, JsonAnomalyLogThread *aft, const Packet *
return rc;
}
static int JsonAnomalyFlush(ThreadVars *tv, void *thread_data, const Packet *p)
{
JsonAnomalyLogThread *aft = thread_data;
SCLogDebug("%s flushing %s", tv->name, ((LogFileCtx *)(aft->ctx->file_ctx))->filename);
OutputJsonFlush(aft->ctx);
return 0;
}
static int JsonAnomalyLogger(ThreadVars *tv, void *thread_data, const Packet *p)
{
JsonAnomalyLogThread *aft = thread_data;
@ -457,7 +449,6 @@ void JsonAnomalyLogRegister (void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = JsonAnomalyLogger,
.FlushFunc = JsonAnomalyFlush,
.ConditionFunc = JsonAnomalyLogCondition,
.ThreadInitFunc = JsonAnomalyLogThreadInit,
.ThreadDeinitFunc = JsonAnomalyLogThreadDeinit,

@ -105,7 +105,6 @@ void JsonArpLogRegister(void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = JsonArpLogger,
.FlushFunc = NULL,
.ConditionFunc = JsonArpLogCondition,
.ThreadInitFunc = JsonLogThreadInit,
.ThreadDeinitFunc = JsonLogThreadDeinit,

@ -70,15 +70,6 @@ static void OutputJsonLogDeInitCtxSub(OutputCtx *output_ctx)
SCFree(output_ctx);
}
int OutputJsonLogFlush(ThreadVars *tv, void *thread_data, const Packet *p)
{
OutputJsonThreadCtx *aft = thread_data;
LogFileCtx *file_ctx = aft->ctx->file_ctx;
SCLogDebug("%s flushing %s", tv->name, file_ctx->filename);
LogFileFlush(file_ctx);
return 0;
}
OutputInitResult OutputJsonLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };

@ -396,7 +396,6 @@ void JsonDropLogRegister (void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = JsonDropLogger,
.FlushFunc = OutputJsonLogFlush,
.ConditionFunc = JsonDropLogCondition,
.ThreadInitFunc = JsonDropLogThreadInit,
.ThreadDeinitFunc = JsonDropLogThreadDeinit,

@ -558,7 +558,6 @@ void JsonFrameLogRegister(void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = JsonFrameLogger,
.FlushFunc = OutputJsonLogFlush,
.ConditionFunc = JsonFrameLogCondition,
.ThreadInitFunc = JsonFrameLogThreadInit,
.ThreadDeinitFunc = JsonFrameLogThreadDeinit,

@ -96,7 +96,6 @@ void JsonMetadataLogRegister (void)
{
OutputPacketLoggerFunctions output_logger_functions = {
.LogFunc = JsonMetadataLogger,
.FlushFunc = OutputJsonLogFlush,
.ConditionFunc = JsonMetadataLogCondition,
.ThreadInitFunc = JsonLogThreadInit,
.ThreadDeinitFunc = JsonLogThreadDeinit,

@ -988,12 +988,6 @@ int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer)
return 0;
}
void OutputJsonFlush(OutputJsonThreadCtx *ctx)
{
LogFileCtx *file_ctx = ctx->file_ctx;
LogFileFlush(file_ctx);
}
void OutputJsonBuilderBuffer(
ThreadVars *tv, const Packet *p, Flow *f, SCJsonBuilder *js, OutputJsonThreadCtx *ctx)
{

@ -108,7 +108,6 @@ TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data);
void EveAddCommonOptions(const OutputJsonCommonSettings *cfg, const Packet *p, const Flow *f,
SCJsonBuilder *js, enum SCOutputJsonLogDirection dir);
int OutputJsonLogFlush(ThreadVars *tv, void *thread_data, const Packet *p);
void EveAddMetadata(const Packet *p, const Flow *f, SCJsonBuilder *js);
int OutputJSONMemBufferCallback(const char *str, size_t size, void *data);
@ -116,6 +115,5 @@ int OutputJSONMemBufferCallback(const char *str, size_t size, void *data);
OutputJsonThreadCtx *CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx);
void FreeEveThreadCtx(OutputJsonThreadCtx *ctx);
void JSONFormatAndAddMACAddr(SCJsonBuilder *js, const char *key, const uint8_t *val, bool is_array);
void OutputJsonFlush(OutputJsonThreadCtx *ctx);
#endif /* SURICATA_OUTPUT_JSON_H */

@ -87,7 +87,6 @@
typedef struct RootLogger_ {
OutputLogFunc LogFunc;
OutputFlushFunc FlushFunc;
ThreadInitFunc ThreadInit;
ThreadDeinitFunc ThreadDeinit;
OutputGetActiveCountFunc ActiveCntFunc;
@ -211,7 +210,6 @@ void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_
module->conf_name = conf_name;
module->InitFunc = InitFunc;
module->PacketLogFunc = output_module_functions->LogFunc;
module->PacketFlushFunc = output_module_functions->FlushFunc;
module->PacketConditionFunc = output_module_functions->ConditionFunc;
module->ThreadInit = output_module_functions->ThreadInitFunc;
module->ThreadDeinit = output_module_functions->ThreadDeinitFunc;
@ -251,7 +249,6 @@ void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const c
module->parent_name = parent_name;
module->InitSubFunc = InitFunc;
module->PacketLogFunc = output_logger_functions->LogFunc;
module->PacketFlushFunc = output_logger_functions->FlushFunc;
module->PacketConditionFunc = output_logger_functions->ConditionFunc;
module->ThreadInit = output_logger_functions->ThreadInitFunc;
module->ThreadDeinit = output_logger_functions->ThreadDeinitFunc;
@ -785,21 +782,6 @@ void SCOnLoggingReady(void)
}
}
TmEcode OutputLoggerFlush(ThreadVars *tv, Packet *p, void *thread_data)
{
LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
RootLogger *logger = TAILQ_FIRST(&active_loggers);
LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
while (logger && thread_store_node) {
if (logger->FlushFunc)
logger->FlushFunc(tv, p, thread_store_node->thread_data);
logger = TAILQ_NEXT(logger, entries);
thread_store_node = TAILQ_NEXT(thread_store_node, entries);
}
return TM_ECODE_OK;
}
TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
{
LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;

@ -51,7 +51,6 @@ typedef struct OutputInitResult_ {
typedef OutputInitResult (*OutputInitFunc)(SCConfNode *);
typedef OutputInitResult (*OutputInitSubFunc)(SCConfNode *, OutputCtx *);
typedef TmEcode (*OutputLogFunc)(ThreadVars *, Packet *, void *);
typedef TmEcode (*OutputFlushFunc)(ThreadVars *, Packet *, void *);
typedef uint32_t (*OutputGetActiveCountFunc)(void);
typedef struct OutputModule_ {
@ -66,7 +65,6 @@ typedef struct OutputModule_ {
ThreadDeinitFunc ThreadDeinit;
PacketLogger PacketLogFunc;
PacketLogger PacketFlushFunc;
PacketLogCondition PacketConditionFunc;
TxLogger TxLogFunc;
TxLoggerCondition TxLogCondition;
@ -86,7 +84,6 @@ typedef struct OutputModule_ {
/* struct for packet module and packet sub-module registration */
typedef struct OutputPacketLoggerFunctions_ {
PacketLogger LogFunc;
PacketLogger FlushFunc;
PacketLogCondition ConditionFunc;
ThreadInitFunc ThreadInitFunc;
ThreadDeinitFunc ThreadDeinitFunc;
@ -168,7 +165,6 @@ void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc Thread
void TmModuleLoggerRegister(void);
TmEcode OutputLoggerLog(ThreadVars *, Packet *, void *);
TmEcode OutputLoggerFlush(ThreadVars *, Packet *, void *);
TmEcode OutputLoggerThreadInit(ThreadVars *, const void *, void **);
TmEcode OutputLoggerThreadDeinit(ThreadVars *, void *);
void OutputLoggerExitPrintStats(ThreadVars *, void *);

Loading…
Cancel
Save