mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
tag_cache
This commit is contained in:
parent
7fb65bbb33
commit
68bfe54ea8
2 changed files with 18 additions and 2 deletions
|
@ -51,7 +51,8 @@ bool Manager::ConnIndex::operator<(const ConnIndex& other) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::Manager() : plugin::ComponentManager<analyzer::Component>("Analyzer", "Tag", "AllAnalyzers") {}
|
Manager::Manager()
|
||||||
|
: plugin::ComponentManager<analyzer::Component>("Analyzer", "Tag", "AllAnalyzers"), tag_cache(2048, nullptr) {}
|
||||||
|
|
||||||
Manager::~Manager() {
|
Manager::~Manager() {
|
||||||
// Clean up expected-connection table.
|
// Clean up expected-connection table.
|
||||||
|
@ -259,7 +260,20 @@ bool Manager::UnregisterAnalyzerForPort(const zeek::Tag& tag, TransportProto pro
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer* Manager::InstantiateAnalyzer(const zeek::Tag& tag, Connection* conn) {
|
Analyzer* Manager::InstantiateAnalyzer(const zeek::Tag& tag, Connection* conn) {
|
||||||
Component* c = Lookup(tag);
|
// std::fprintf(stderr, "Instantiate %d %d\n", tag.Type(), tag.Subtype());
|
||||||
|
|
||||||
|
Component* c = nullptr;
|
||||||
|
|
||||||
|
// Check for the tag in the tag cache
|
||||||
|
if ( c = tag_cache[tag.Type()]; c ) {
|
||||||
|
if ( c->Tag().Subtype() != tag.Subtype() )
|
||||||
|
reporter->InternalWarning("tag caching problem");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Slow lookup path
|
||||||
|
c = Lookup(tag);
|
||||||
|
tag_cache[tag.Type()] = c;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! c ) {
|
if ( ! c ) {
|
||||||
reporter->InternalWarning("request to instantiate unknown analyzer");
|
reporter->InternalWarning("request to instantiate unknown analyzer");
|
||||||
|
|
|
@ -376,6 +376,8 @@ private:
|
||||||
conns_map conns;
|
conns_map conns;
|
||||||
conns_queue conns_by_timeout;
|
conns_queue conns_by_timeout;
|
||||||
std::vector<uint16_t> vxlan_ports;
|
std::vector<uint16_t> vxlan_ports;
|
||||||
|
|
||||||
|
std::vector<Component*> tag_cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace analyzer
|
} // namespace analyzer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue