From: Russ Combs Date: Fri, 26 Feb 2016 20:34:41 +0000 (-0500) Subject: reverse e71421e748f660021b9af7bb6a25d4f3828dafd7 since it broke regressions X-Git-Tag: 3.0.0-233~574 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=805385ebfedd3f3cf352d8abe3edcdccf3940005;p=thirdparty%2Fsnort3.git reverse e71421e748f660021b9af7bb6a25d4f3828dafd7 since it broke regressions --- diff --git a/src/main/modules.cc b/src/main/modules.cc index ab6fd6902..5693ecdfe 100644 --- a/src/main/modules.cc +++ b/src/main/modules.cc @@ -97,7 +97,6 @@ public: DetectionModule() : Module("detection", detection_help, detection_params) { } bool set(const char*, Value&, SnortConfig*) override; const PegInfo* get_pegs() const override { return pc_names; } - PegCount* get_counts() const override { return (PegCount*) &pc; } }; bool DetectionModule::set(const char*, Value& v, SnortConfig* sc) @@ -946,7 +945,6 @@ public: DaqModule() : Module("daq", daq_help, daq_params) { } bool set(const char*, Value&, SnortConfig*) override; const PegInfo* get_pegs() const override { return daq_names; } - PegCount* get_counts() const override; }; bool DaqModule::set(const char*, Value& v, SnortConfig* sc) @@ -985,14 +983,6 @@ bool DaqModule::set(const char*, Value& v, SnortConfig* sc) return true; } -PegCount* DaqModule::get_counts() const -{ - static THREAD_LOCAL DAQStats ds; - - get_daq_stats(ds); - return (PegCount*) &ds; -} - //------------------------------------------------------------------------- // attribute_table module //------------------------------------------------------------------------- diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index 1a9775f66..6809de720 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -516,7 +516,6 @@ public: bool set(const char*, Value&, SnortConfig*) override; const PegInfo* get_pegs() const override { return proc_names; } - PegCount* get_counts() const override { return (PegCount*) &proc_stats; } }; bool SnortModule::set(const char*, Value& v, SnortConfig* sc) diff --git a/src/managers/module_manager.cc b/src/managers/module_manager.cc index 9b971a307..0581d501b 100644 --- a/src/managers/module_manager.cc +++ b/src/managers/module_manager.cc @@ -57,7 +57,7 @@ struct ModHook void init(); }; -typedef std::list ModuleList; +typedef list ModuleList; static ModuleList s_modules; static unsigned s_errors = 0; @@ -811,16 +811,6 @@ Module* ModuleManager::get_default_module(const char* s, SnortConfig* sc) const char* ModuleManager::get_current_module() { return s_current.c_str(); } -list ModuleManager::get_all_modules() -{ - list ret; - - for ( auto& m : s_modules ) - ret.push_back(m->mod); - - return ret; -} - void ModuleManager::set_config(SnortConfig* sc) { s_config = sc; } diff --git a/src/managers/module_manager.h b/src/managers/module_manager.h index 2b5c2142f..ff6fc6840 100644 --- a/src/managers/module_manager.h +++ b/src/managers/module_manager.h @@ -23,7 +23,6 @@ // Factory for Modules, including all builtin and plugin modules. // Modules are strictly used during parse time. -#include #include //------------------------------------------------------------------------- @@ -40,7 +39,6 @@ public: static Module* get_module(const char*); static Module* get_default_module(const char*, SnortConfig*); static const char* get_current_module(); - static std::list get_all_modules(); static void list_modules(const char* = nullptr); static void dump_modules(); diff --git a/src/managers/plugin_manager.cc b/src/managers/plugin_manager.cc index 0ac613577..1fee8e4c5 100644 --- a/src/managers/plugin_manager.cc +++ b/src/managers/plugin_manager.cc @@ -573,3 +573,17 @@ const char* PluginManager::get_available_plugins(PlugType t) return s.c_str(); } +std::vector PluginManager::get_all_available_plugins() +{ + std::vector ret; + + for ( auto it = plug_map.begin(); it != plug_map.end(); ++it ) + { + const auto* api = it->second.api; + + ret.push_back(api->name); + } + + return ret; +} + diff --git a/src/managers/plugin_manager.h b/src/managers/plugin_manager.h index 6cbb0b7df..6c7b4f71e 100644 --- a/src/managers/plugin_manager.h +++ b/src/managers/plugin_manager.h @@ -63,6 +63,7 @@ public: static void instantiate(const BaseApi*, Module*, SnortConfig*, const char* name); static const char* get_available_plugins(PlugType); + static std::vector get_all_available_plugins(); }; #endif diff --git a/src/network_inspectors/perf_monitor/perf_module.cc b/src/network_inspectors/perf_monitor/perf_module.cc index 73044a531..c257bf26d 100644 --- a/src/network_inspectors/perf_monitor/perf_module.cc +++ b/src/network_inspectors/perf_monitor/perf_module.cc @@ -24,6 +24,9 @@ #include "managers/plugin_manager.h" #include "utils/util.h" +static std::string mod_pegs; +static std::string mod_name; + //------------------------------------------------------------------------- // perf attributes //------------------------------------------------------------------------- @@ -248,10 +251,11 @@ bool PerfMonModule::end(const char* fqn, int idx, SnortConfig*) { if ( !config.modules.size() ) { - auto modules = ModuleManager::get_all_modules(); - for ( auto& mod : modules ) + auto modules = PluginManager::get_all_available_plugins(); + for ( auto& mod_name : modules ) { - if ( !add_module(config, mod, std::string()) ) + Module* mod = ModuleManager::get_module(mod_name.c_str()); + if ( mod && !add_module(config, mod, std::string()) ) return false; } } diff --git a/src/network_inspectors/perf_monitor/perf_module.h b/src/network_inspectors/perf_monitor/perf_module.h index a0f3248ad..c4ba01d30 100644 --- a/src/network_inspectors/perf_monitor/perf_module.h +++ b/src/network_inspectors/perf_monitor/perf_module.h @@ -48,9 +48,6 @@ public: private: SFPERF config; - - std::string mod_pegs; - std::string mod_name; }; #define BASE_FILE "perf_monitor.csv" diff --git a/src/utils/stats.cc b/src/utils/stats.cc index a3541b456..e76b74a1d 100644 --- a/src/utils/stats.cc +++ b/src/utils/stats.cc @@ -157,6 +157,31 @@ static void timing_stats() LogMessage("%25.25s: " STDu64 "\n", "pkts/sec", pps); } +//------------------------------------------------------------------------- +// FIXIT-L 2.0.4 introduces the retry verdict +// no way to reliably optionally leverage this with dynamic loaded daqs + +// FIXIT-L daq stats should be moved to sfdaq + +#define MAX_SFDAQ_VERDICT 6 + +struct DAQStats +{ + PegCount pcaps; + PegCount received; + PegCount analyzed; + PegCount dropped; + PegCount filtered; + PegCount outstanding; + PegCount injected; + PegCount verdicts[MAX_SFDAQ_VERDICT]; + PegCount internal_blacklist; + PegCount internal_whitelist; + PegCount skipped; + PegCount fail_open; + PegCount idle; +}; + //------------------------------------------------------------------------- // FIXIT-L need better encapsulation of these counts by their modules @@ -245,7 +270,7 @@ void pc_sum() //------------------------------------------------------------------------- -void get_daq_stats(DAQStats& daq_stats) +static void get_daq_stats(DAQStats& daq_stats) { uint64_t pkts_recv = g_daq_stats.hw_packets_received; uint64_t pkts_drop = g_daq_stats.hw_packets_dropped; diff --git a/src/utils/stats.h b/src/utils/stats.h index 71c1da267..8d39c02c4 100644 --- a/src/utils/stats.h +++ b/src/utils/stats.h @@ -79,31 +79,6 @@ struct AuxCount PegCount idle; }; -//------------------------------------------------------------------------- -// FIXIT-L 2.0.4 introduces the retry verdict -// no way to reliably optionally leverage this with dynamic loaded daqs - -// FIXIT-L daq stats should be moved to sfdaq - -#define MAX_SFDAQ_VERDICT 6 - -struct DAQStats -{ - PegCount pcaps; - PegCount received; - PegCount analyzed; - PegCount dropped; - PegCount filtered; - PegCount outstanding; - PegCount injected; - PegCount verdicts[MAX_SFDAQ_VERDICT]; - PegCount internal_blacklist; - PegCount internal_whitelist; - PegCount skipped; - PegCount fail_open; - PegCount idle; -}; - extern ProcessCount proc_stats; extern THREAD_LOCAL AuxCount aux_counts; extern SO_PUBLIC THREAD_LOCAL PacketCount pc; @@ -121,8 +96,6 @@ SO_PUBLIC void LogCount(const char*, uint64_t); SO_PUBLIC void LogStat(const char*, uint64_t n, uint64_t tot); SO_PUBLIC void LogStat(const char*, double); -void get_daq_stats(DAQStats& daq_stats); - void sum_stats(PegCount* sums, PegCount* counts, unsigned n); void show_stats(PegCount*, const PegInfo*, unsigned n, const char* module_name = nullptr);