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

fix(userspace/libsinsp): solve issues with negate comparisons on ip and ipnet checks #1953

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

jasondellaluce
Copy link
Contributor

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area libsinsp

Does this PR require a change in the driver versions?

What this PR does / why we need it:

Our comparison logic in the filters introduced a regression that misinterprets checks such as fd.ip != "0:0:0:0:0:0:0:1" and not fd.ip = "0:0:0:0:0:0:0:1". Those are supposed to be functionally equal, however when the underlying comparison involves ip addresses of different sizes (ipv4, ipv6) the two expressions diverge.

Which issue(s) this PR fixes:

Special notes for your reviewer:

/milestone 0.18.0

Does this PR introduce a user-facing change?:

fix(userspace/libsinsp): solve issues with negate comparisons on ip and ipnet checks

…nd ipnet checks

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Copy link
Contributor

@LucaGuerra LucaGuerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please also add later a PR to add a test for this because it's not intuitive and we need to avoid regressions there

@poiana
Copy link
Contributor

poiana commented Jul 11, 2024

LGTM label has been added.

Git tree hash: 51229c542c81daae0cbb58be131a1626116d5410

Copy link

Perf diff from master - unit tests

     5.07%     -1.02%  [.] sinsp_parser::process_event
     4.97%     +0.91%  [.] next
     7.86%     -0.88%  [.] sinsp::next
     3.16%     +0.81%  [.] sinsp_evt::load_params
     4.56%     +0.81%  [.] sinsp_thread_manager::find_thread
     3.56%     +0.63%  [.] gzfile_read
     1.19%     -0.58%  [.] sinsp_evt::get_direction
     0.98%     -0.53%  [.] scap_event_has_large_payload
     0.51%     +0.43%  [.] sinsp_threadinfo::~sinsp_threadinfo
     2.96%     -0.37%  [.] sinsp_thread_manager::get_thread_ref

Perf diff from master - scap file

     3.07%     +4.71%  [.] sinsp_filter_check::rawval_to_string
    11.98%     -4.33%  [.] sinsp_filter_check::tostring
    11.75%     -4.22%  [.] std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>
     3.08%     +2.58%  [.] sinsp::next
    12.25%     -2.48%  [.] sinsp_thread_manager::find_thread
    12.27%     +1.88%  [.] sinsp_evt_formatter::tostring_withformat
     6.07%     -1.36%  [.] sinsp_threadinfo::~sinsp_threadinfo
     6.15%     -1.19%  [.] rawstring_check::extract_single
     6.14%     -1.18%  [.] std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<sinsp_container_info const> >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<sinsp_container_info const> > >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_find_before_node
     6.11%     +0.84%  [.] sinsp_filter_check::extract_nocache

Heap diff from master - unit tests

total runtime: -0.06s.
calls to allocation functions: -76 (1357/s)
temporary memory allocations: 57 (-1017/s)
peak heap memory consumption: -661B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

total runtime: -0.03s.
calls to allocation functions: 0 (0/s)
temporary memory allocations: 1 (-35/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana
Copy link
Contributor

poiana commented Jul 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, jasondellaluce, LucaGuerra

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Andreagit97,LucaGuerra,jasondellaluce]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit ad46fd6 into master Jul 11, 2024
37 of 38 checks passed
@poiana poiana deleted the fix/ip-comparisons branch July 11, 2024 12:33
@LucaGuerra LucaGuerra mentioned this pull request Jul 23, 2024
@FedeDP
Copy link
Contributor

FedeDP commented Jul 31, 2024

/milestone 0.17.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants