Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(userspace/libsinsp): remove unused check_id from events #376

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions userspace/libsinsp/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,6 @@ sinsp_filter_compiler::sinsp_filter_compiler(
m_flt_ast = NULL;
m_ttable_only = ttable_only;
m_internal_parsing = true;
m_check_id = 0;
}

sinsp_filter_compiler::sinsp_filter_compiler(
Expand All @@ -1504,7 +1503,6 @@ sinsp_filter_compiler::sinsp_filter_compiler(
m_flt_ast = NULL;
m_ttable_only = ttable_only;
m_internal_parsing = true;
m_check_id = 0;
}

sinsp_filter_compiler::sinsp_filter_compiler(
Expand All @@ -1517,7 +1515,6 @@ sinsp_filter_compiler::sinsp_filter_compiler(
m_flt_ast = fltast;
m_ttable_only = ttable_only;
m_internal_parsing = false;
m_check_id = 0;
}

sinsp_filter_compiler::~sinsp_filter_compiler()
Expand All @@ -1529,11 +1526,6 @@ sinsp_filter_compiler::~sinsp_filter_compiler()
}
}

void sinsp_filter_compiler::set_check_id(int32_t id)
{
m_check_id = id;
}

sinsp_filter* sinsp_filter_compiler::compile()
{
// parse filter string on-the-fly if not pre-parsed AST is provided
Expand Down Expand Up @@ -1637,7 +1629,6 @@ void sinsp_filter_compiler::visit(libsinsp::filter::ast::unary_check_expr* e)
check->m_cmpop = str_to_cmpop(e->op);
check->m_boolop = m_last_boolop;
check->parse_field_name(field.c_str(), true, true);
check->set_check_id(m_check_id);
}

static void add_filtercheck_value(gen_event_filter_check *chk, size_t idx, const std::string& value)
Expand Down Expand Up @@ -1668,7 +1659,6 @@ void sinsp_filter_compiler::visit(libsinsp::filter::ast::binary_check_expr* e)
check->m_cmpop = str_to_cmpop(e->op);
check->m_boolop = m_last_boolop;
check->parse_field_name(field.c_str(), true, true);
check->set_check_id(m_check_id);

// Read the the the right-hand values of the filtercheck.
// For list-related operators ('in', 'intersects', 'pmatch'), the vector
Expand Down
3 changes: 0 additions & 3 deletions userspace/libsinsp/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ class SINSP_PUBLIC sinsp_filter_compiler:
*/
sinsp_filter* compile();

void set_check_id(int32_t id);

private:
void visit(libsinsp::filter::ast::and_expr*) override;
void visit(libsinsp::filter::ast::or_expr*) override;
Expand All @@ -122,7 +120,6 @@ class SINSP_PUBLIC sinsp_filter_compiler:
std::string create_filtercheck_name(std::string& name, std::string& arg);
gen_event_filter_check* create_filtercheck(std::string& field);

int32_t m_check_id;
bool m_ttable_only;
bool m_internal_parsing;
bool m_expect_values;
Expand Down
37 changes: 0 additions & 37 deletions userspace/libsinsp/gen_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ gen_event::~gen_event()
{
}

void gen_event::set_check_id(int32_t id)
{
if (id) {
m_check_id = id;
}
}

int32_t gen_event::get_check_id() const
{
return m_check_id;
}

gen_event_filter_check::gen_event_filter_check()
{
}
Expand All @@ -51,16 +39,6 @@ gen_event_filter_check::~gen_event_filter_check()
{
}

void gen_event_filter_check::set_check_id(int32_t id)
{
m_check_id = id;
}

int32_t gen_event_filter_check::get_check_id()
{
return m_check_id;
}

///////////////////////////////////////////////////////////////////////////////
// gen_event_filter_expression implementation
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -102,9 +80,6 @@ bool gen_event_filter_expression::compare(gen_event *evt)
{
case BO_NONE:
res = chk->compare(evt);
if (res) {
evt->set_check_id(chk->get_check_id());
}
break;
case BO_NOT:
res = !chk->compare(evt);
Expand All @@ -124,39 +99,27 @@ bool gen_event_filter_expression::compare(gen_event *evt)
goto done;
}
res = chk->compare(evt);
if (res) {
evt->set_check_id(chk->get_check_id());
}
break;
case BO_AND:
if(!res)
{
goto done;
}
res = chk->compare(evt);
if (res) {
evt->set_check_id(chk->get_check_id());
}
break;
case BO_ORNOT:
if(res)
{
goto done;
}
res = !chk->compare(evt);
if (res) {
evt->set_check_id(chk->get_check_id());
}
break;
case BO_ANDNOT:
if(!res)
{
goto done;
}
res = !chk->compare(evt);
if (res) {
evt->set_check_id(chk->get_check_id());
}
break;
default:
ASSERT(false);
Expand Down
23 changes: 0 additions & 23 deletions userspace/libsinsp/gen_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@ class gen_event
gen_event();
virtual ~gen_event();

/*!
\brief Set an opaque "check id", corresponding to the id of the last filtercheck that matched this event.
*/
void set_check_id(int32_t id);

/*!
\brief Get the opaque "check id" (-1 if not set).
*/
int32_t get_check_id() const;

// Every event must expose a timestamp
virtual uint64_t get_ts() const = 0;

Expand All @@ -96,9 +86,6 @@ class gen_event
*/
virtual uint16_t get_type() const = 0;

private:
int32_t m_check_id = 0;

};

typedef struct extract_value {
Expand All @@ -119,16 +106,6 @@ class gen_event_filter_check
virtual void add_filter_value(const char* str, uint32_t len, uint32_t i = 0 ) = 0;
virtual bool compare(gen_event *evt) = 0;
virtual bool extract(gen_event *evt, std::vector<extract_value_t>& values, bool sanitize_strings = true) = 0;

//
// Configure numeric id to be set on events that match this filter
//
void set_check_id(int32_t id);
virtual int32_t get_check_id();

private:
int32_t m_check_id = 0;

};

///////////////////////////////////////////////////////////////////////////////
Expand Down