From ae075e24c8c8a4ca8d2685d2f7ddde5adbe98499 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sat, 18 Jan 2020 12:25:28 +0500 Subject: [PATCH] Remove Heartbeat log messages. --- src/common/fortlog.c | 19 ----------- src/driver/fortdrv.c | 54 ------------------------------- src/driver/fortdrv.h | 1 - src/tests/logbuffer/LogBuffer.pro | 2 -- src/tests/logreader/LogReader.pro | 2 -- src/ui/FortFirewall.pro | 2 -- src/ui/fortcommon.cpp | 10 ------ src/ui/fortcommon.h | 4 --- src/ui/log/logbuffer.cpp | 16 --------- src/ui/log/logbuffer.h | 5 --- src/ui/log/logentry.h | 3 +- src/ui/log/logentryheartbeat.cpp | 11 ------- src/ui/log/logentryheartbeat.h | 20 ------------ src/ui/log/logmanager.cpp | 11 ------- src/ui/log/logmanager.h | 2 -- 15 files changed, 1 insertion(+), 161 deletions(-) delete mode 100644 src/ui/log/logentryheartbeat.cpp delete mode 100644 src/ui/log/logentryheartbeat.h diff --git a/src/common/fortlog.c b/src/common/fortlog.c index eb1818db..5bc13626 100644 --- a/src/common/fortlog.c +++ b/src/common/fortlog.c @@ -7,7 +7,6 @@ #define FORT_LOG_FLAG_BLOCKED 0x01000000 #define FORT_LOG_FLAG_PROC_NEW 0x02000000 #define FORT_LOG_FLAG_STAT_TRAF 0x04000000 -#define FORT_LOG_FLAG_HEARTBEAT 0x08000000 #define FORT_LOG_FLAG_BLOCKED_ALLOW 0x10000000 #define FORT_LOG_FLAG_TYPE_MASK 0x0F000000 #define FORT_LOG_FLAG_OPT_MASK 0xF0000000 @@ -38,8 +37,6 @@ #define FORT_LOG_STAT_BUFFER_PROC_COUNT \ ((FORT_BUFFER_SIZE - FORT_LOG_STAT_HEADER_SIZE) / FORT_LOG_STAT_TRAF_SIZE(1)) -#define FORT_LOG_HEARTBEAT_SIZE sizeof(UINT32) - #define FORT_LOG_SIZE_MAX FORT_LOG_BLOCKED_SIZE_MAX #define fort_log_type(p) (*((UINT32 *) (p)) & FORT_LOG_FLAG_TYPE_MASK) @@ -136,19 +133,3 @@ fort_log_stat_traf_header_read (const char *p, INT64 *unix_time, UINT16 *proc_co *proc_count = (UINT16) *up++; *unix_time = *((INT64 *) up); } - -static void -fort_log_heartbeat_write (char *p, UINT16 tick) -{ - UINT32 *up = (UINT32 *) p; - - *up = FORT_LOG_FLAG_HEARTBEAT | tick; -} - -static void -fort_log_heartbeat_read (const char *p, UINT16 *tick) -{ - const UINT32 *up = (const UINT32 *) p; - - *tick = (UINT16) *up; -} diff --git a/src/driver/fortdrv.c b/src/driver/fortdrv.c index 79a78550..f9dcf7ea 100644 --- a/src/driver/fortdrv.c +++ b/src/driver/fortdrv.c @@ -45,10 +45,6 @@ typedef struct fort_device { FORT_DEFER defer; FORT_TIMER log_timer; FORT_TIMER app_timer; -#ifdef LOG_HEARTBEAT - FORT_TIMER heartbeat_timer; - UINT16 volatile heartbeat_tick; -#endif FORT_WORKER worker; } FORT_DEVICE, *PFORT_DEVICE; @@ -879,39 +875,6 @@ fort_app_period_timer (void) } } -#ifdef LOG_HEARTBEAT -static void -fort_heartbeat_timer (void) -{ - PFORT_BUFFER buf = &g_device->buffer; - KLOCK_QUEUE_HANDLE buf_lock_queue; - - /* Lock buffer */ - KeAcquireInStackQueuedSpinLock(&buf->lock, &buf_lock_queue); - - /* Log heartbeat */ - { - const UINT16 tick = InterlockedIncrement16(&g_device->heartbeat_tick); - const UINT32 len = FORT_LOG_HEARTBEAT_SIZE; - PCHAR out; - NTSTATUS status; - - status = fort_buffer_prepare(buf, len, &out, NULL, NULL); - if (!NT_SUCCESS(status)) { - DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, - "FORT: Heartbeat Timer: Error: %x\n", status); - goto end; - } - - fort_log_heartbeat_write(out, tick); - } - - end: - /* Unlock buffer */ - KeReleaseInStackQueuedSpinLock(&buf_lock_queue); -} -#endif - static NTSTATUS fort_device_create (PDEVICE_OBJECT device, PIRP irp) { @@ -928,12 +891,6 @@ fort_device_create (PDEVICE_OBJECT device, PIRP irp) if (NT_SUCCESS(status)) { /* Clear buffer */ fort_buffer_clear(&g_device->buffer); - -#ifdef LOG_HEARTBEAT - InterlockedAnd16(&g_device->heartbeat_tick, 0); - fort_heartbeat_timer(); - fort_timer_update(&g_device->heartbeat_timer, TRUE); -#endif } fort_request_complete(irp, status); @@ -965,11 +922,6 @@ fort_device_cleanup (PDEVICE_OBJECT device, PIRP irp) fort_callout_force_reauth(old_conf_flags, FORT_DEFER_FLUSH_ALL); } -#ifdef LOG_HEARTBEAT - fort_timer_update(&g_device->heartbeat_timer, FALSE); - fort_heartbeat_timer(); -#endif - /* Clear buffer */ fort_buffer_clear(&g_device->buffer); @@ -1227,9 +1179,6 @@ fort_driver_unload (PDRIVER_OBJECT driver) if (g_device != NULL) { fort_callout_defer_flush(); -#ifdef LOG_HEARTBEAT - fort_timer_close(&g_device->heartbeat_timer); -#endif fort_timer_close(&g_device->app_timer); fort_timer_close(&g_device->log_timer); fort_defer_close(&g_device->defer); @@ -1320,9 +1269,6 @@ DriverEntry (PDRIVER_OBJECT driver, PUNICODE_STRING reg_path) fort_defer_open(&g_device->defer); fort_timer_open(&g_device->log_timer, 500, FALSE, &fort_callout_timer); fort_timer_open(&g_device->app_timer, 60000, TRUE, &fort_app_period_timer); -#ifdef LOG_HEARTBEAT - fort_timer_open(&g_device->heartbeat_timer, 1000, TRUE, &fort_heartbeat_timer); -#endif /* Unregister old filters provider */ { diff --git a/src/driver/fortdrv.h b/src/driver/fortdrv.h index 31be3952..1f9650b7 100644 --- a/src/driver/fortdrv.h +++ b/src/driver/fortdrv.h @@ -5,7 +5,6 @@ #define DOS_DEVICE_NAME L"\\DosDevices\\fortfw" #define FORT_DRIVER -//#define LOG_HEARTBEAT #define fort_request_complete_info(irp, status, info) \ do { \ diff --git a/src/tests/logbuffer/LogBuffer.pro b/src/tests/logbuffer/LogBuffer.pro index b0fcf1dd..53ba0bd4 100644 --- a/src/tests/logbuffer/LogBuffer.pro +++ b/src/tests/logbuffer/LogBuffer.pro @@ -5,7 +5,6 @@ SOURCES += \ $$UIPATH/log/logbuffer.cpp \ $$UIPATH/log/logentry.cpp \ $$UIPATH/log/logentryblocked.cpp \ - $$UIPATH/log/logentryheartbeat.cpp \ $$UIPATH/log/logentryprocnew.cpp \ $$UIPATH/log/logentrystattraf.cpp \ $$UIPATH/util/dateutil.cpp \ @@ -19,7 +18,6 @@ HEADERS += \ $$UIPATH/log/logbuffer.h \ $$UIPATH/log/logentry.h \ $$UIPATH/log/logentryblocked.h \ - $$UIPATH/log/logentryheartbeat.h \ $$UIPATH/log/logentryprocnew.h \ $$UIPATH/log/logentrystattraf.h \ $$UIPATH/util/dateutil.h \ diff --git a/src/tests/logreader/LogReader.pro b/src/tests/logreader/LogReader.pro index fa9d6e2d..fbdc21e3 100644 --- a/src/tests/logreader/LogReader.pro +++ b/src/tests/logreader/LogReader.pro @@ -8,7 +8,6 @@ SOURCES += \ $$UIPATH/log/logbuffer.cpp \ $$UIPATH/log/logentry.cpp \ $$UIPATH/log/logentryblocked.cpp \ - $$UIPATH/log/logentryheartbeat.cpp \ $$UIPATH/log/logentryprocnew.cpp \ $$UIPATH/log/logentrystattraf.cpp \ $$UIPATH/util/conf/addressrange.cpp \ @@ -30,7 +29,6 @@ HEADERS += \ $$UIPATH/log/logbuffer.h \ $$UIPATH/log/logentry.h \ $$UIPATH/log/logentryblocked.h \ - $$UIPATH/log/logentryheartbeat.h \ $$UIPATH/log/logentryprocnew.h \ $$UIPATH/log/logentrystattraf.h \ $$UIPATH/util/conf/addressrange.h \ diff --git a/src/ui/FortFirewall.pro b/src/ui/FortFirewall.pro index efbc7f32..c549fd3e 100644 --- a/src/ui/FortFirewall.pro +++ b/src/ui/FortFirewall.pro @@ -53,7 +53,6 @@ SOURCES += \ log/logbuffer.cpp \ log/logentry.cpp \ log/logentryblocked.cpp \ - log/logentryheartbeat.cpp \ log/logentryprocnew.cpp \ log/logentrystattraf.cpp \ log/logmanager.cpp \ @@ -156,7 +155,6 @@ HEADERS += \ log/logbuffer.h \ log/logentry.h \ log/logentryblocked.h \ - log/logentryheartbeat.h \ log/logentryprocnew.h \ log/logentrystattraf.h \ log/logmanager.h \ diff --git a/src/ui/fortcommon.cpp b/src/ui/fortcommon.cpp index 4e6003ec..2ebd855b 100644 --- a/src/ui/fortcommon.cpp +++ b/src/ui/fortcommon.cpp @@ -103,11 +103,6 @@ quint32 FortCommon::logStatSize(quint16 procCount) return FORT_LOG_STAT_SIZE(procCount); } -quint32 FortCommon::logHeartbeatSize() -{ - return FORT_LOG_HEARTBEAT_SIZE; -} - quint32 FortCommon::logType(const char *input) { return fort_log_type(input); @@ -148,11 +143,6 @@ void FortCommon::logStatTrafHeaderRead(const char *input, fort_log_stat_traf_header_read(input, unixTime, procCount); } -void FortCommon::logHeartbeatRead(const char *input, quint16 *tick) -{ - fort_log_heartbeat_read(input, tick); -} - void FortCommon::confAppPermsMaskInit(void *drvConf) { PFORT_CONF conf = (PFORT_CONF) drvConf; diff --git a/src/ui/fortcommon.h b/src/ui/fortcommon.h index 7351046f..de02165f 100644 --- a/src/ui/fortcommon.h +++ b/src/ui/fortcommon.h @@ -36,8 +36,6 @@ public: static quint32 logStatTrafSize(quint16 procCount); static quint32 logStatSize(quint16 procCount); - static quint32 logHeartbeatSize(); - static quint32 logType(const char *input); static void logBlockedHeaderWrite(char *output, bool blocked, @@ -56,8 +54,6 @@ public: qint64 *unixTime, quint16 *procCount); - static void logHeartbeatRead(const char *input, quint16 *tick); - static void confAppPermsMaskInit(void *drvConf); static bool confIpInRange(const void *drvConf, quint32 ip, bool included = false, int addrGroupIndex = 0); diff --git a/src/ui/log/logbuffer.cpp b/src/ui/log/logbuffer.cpp index 9b52a5e3..0b93b7d5 100644 --- a/src/ui/log/logbuffer.cpp +++ b/src/ui/log/logbuffer.cpp @@ -2,7 +2,6 @@ #include "fortcommon.h" #include "logentryblocked.h" -#include "logentryheartbeat.h" #include "logentryprocnew.h" #include "logentrystattraf.h" @@ -168,18 +167,3 @@ void LogBuffer::readEntryStatTraf(LogEntryStatTraf *logEntry) const int entrySize = int(FortCommon::logStatSize(procCount)); m_offset += entrySize; } - -void LogBuffer::readEntryHeartbeat(LogEntryHeartbeat *logEntry) -{ - Q_ASSERT(m_offset < m_top); - - const char *input = this->input(); - - quint16 tick; - FortCommon::logHeartbeatRead(input, &tick); - - logEntry->setTick(tick); - - const int entrySize = int(FortCommon::logHeartbeatSize()); - m_offset += entrySize; -} diff --git a/src/ui/log/logbuffer.h b/src/ui/log/logbuffer.h index a554e240..bb931e5f 100644 --- a/src/ui/log/logbuffer.h +++ b/src/ui/log/logbuffer.h @@ -7,7 +7,6 @@ #include "logentry.h" QT_FORWARD_DECLARE_CLASS(LogEntryBlocked) -QT_FORWARD_DECLARE_CLASS(LogEntryHeartbeat) QT_FORWARD_DECLARE_CLASS(LogEntryProcNew) QT_FORWARD_DECLARE_CLASS(LogEntryStatTraf) @@ -34,10 +33,6 @@ public: void readEntryStatTraf(LogEntryStatTraf *logEntry); - void readEntryHeartbeat(LogEntryHeartbeat *logEntry); - -signals: - public slots: void reset(int top = 0); diff --git a/src/ui/log/logentry.h b/src/ui/log/logentry.h index 8dc74d9e..6da909b7 100644 --- a/src/ui/log/logentry.h +++ b/src/ui/log/logentry.h @@ -13,8 +13,7 @@ public: // synchronize with FORT_LOG_FLAG_* AppBlocked = 0x01000000, ProcNew = 0x02000000, - StatTraf = 0x04000000, - Heartbeat = 0x08000000 + StatTraf = 0x04000000 }; explicit LogEntry() = default; diff --git a/src/ui/log/logentryheartbeat.cpp b/src/ui/log/logentryheartbeat.cpp deleted file mode 100644 index d4a66821..00000000 --- a/src/ui/log/logentryheartbeat.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "logentryheartbeat.h" - -LogEntryHeartbeat::LogEntryHeartbeat(quint16 tick) : - m_tick(tick) -{ -} - -void LogEntryHeartbeat::setTick(quint16 tick) -{ - m_tick = tick; -} diff --git a/src/ui/log/logentryheartbeat.h b/src/ui/log/logentryheartbeat.h deleted file mode 100644 index a99d936b..00000000 --- a/src/ui/log/logentryheartbeat.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LOGENTRYHEARBEAT_H -#define LOGENTRYHEARBEAT_H - -#include "logentry.h" - -class LogEntryHeartbeat : public LogEntry -{ -public: - explicit LogEntryHeartbeat(quint16 tick = 0); - - LogEntry::LogType type() const override { return Heartbeat; } - - quint16 tick() const { return m_tick; } - void setTick(quint16 tick); - -private: - quint16 m_tick = 0; -}; - -#endif // LOGENTRYHEARBEAT_H diff --git a/src/ui/log/logmanager.cpp b/src/ui/log/logmanager.cpp index 1b796fbf..e0cd0477 100644 --- a/src/ui/log/logmanager.cpp +++ b/src/ui/log/logmanager.cpp @@ -7,7 +7,6 @@ #include "../fortcommon.h" #include "logbuffer.h" #include "logentryblocked.h" -#include "logentryheartbeat.h" #include "logentryprocnew.h" #include "logentrystattraf.h" #include "model/applistmodel.h" @@ -130,16 +129,6 @@ void LogManager::readLogEntries(LogBuffer *logBuffer) m_appStatModel->handleStatTraf(statTrafEntry); break; } - case LogEntry::Heartbeat: { - LogEntryHeartbeat heartbeatEntry; - logBuffer->readEntryHeartbeat(&heartbeatEntry); - if (++m_heartbeatTick != heartbeatEntry.tick()) { - qCritical() << "Heartbeat ticks mismatch! Expected:" - << heartbeatEntry.tick() << "Got:" << m_heartbeatTick; - abort(); - } - break; - } default: if (logBuffer->offset() < logBuffer->top()) { qCritical() << "Unknown Log entry!" << logType; diff --git a/src/ui/log/logmanager.h b/src/ui/log/logmanager.h index 065befdc..28b1ec19 100644 --- a/src/ui/log/logmanager.h +++ b/src/ui/log/logmanager.h @@ -58,8 +58,6 @@ private: private: bool m_active = false; - quint16 m_heartbeatTick = 0; - AppListModel *m_appListModel = nullptr; AppStatModel *m_appStatModel = nullptr;