Skip to content

Conversation

Dimi1010
Copy link
Collaborator

@Dimi1010 Dimi1010 commented Sep 10, 2025

This PR updates BpfFilterWrapper to allow matching with a packet while the filter is marked as const.

It also extends the wrapper with C++11 move constructors and a new constructor to create an instance with a set filter.

Copy link

codecov bot commented Sep 10, 2025

Codecov Report

❌ Patch coverage is 71.87500% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.51%. Comparing base (07f33c0) to head (44dc6e2).

Files with missing lines Patch % Lines
Pcap++/src/PcapFilter.cpp 70.96% 11 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1957      +/-   ##
==========================================
- Coverage   83.52%   83.51%   -0.02%     
==========================================
  Files         310      310              
  Lines       54917    54956      +39     
  Branches    12223    12241      +18     
==========================================
+ Hits        45871    45894      +23     
- Misses       7780     7805      +25     
+ Partials     1266     1257       -9     
Flag Coverage Δ
alpine320 75.94% <51.16%> (-0.04%) ⬇️
fedora42 76.09% <50.00%> (-0.05%) ⬇️
macos-13 81.64% <57.89%> (-0.03%) ⬇️
macos-14 81.64% <57.89%> (-0.03%) ⬇️
macos-15 81.64% <57.89%> (-0.03%) ⬇️
mingw32 70.32% <46.80%> (-0.07%) ⬇️
mingw64 70.32% <46.80%> (-0.07%) ⬇️
rhel94 75.78% <51.16%> (-0.04%) ⬇️
ubuntu2004 60.24% <52.38%> (-0.05%) ⬇️
ubuntu2004-zstd 60.34% <52.38%> (-0.05%) ⬇️
ubuntu2204 75.74% <51.16%> (-0.03%) ⬇️
ubuntu2204-icpx 60.78% <50.87%> (-0.03%) ⬇️
ubuntu2404 75.97% <51.16%> (-0.04%) ⬇️
ubuntu2404-arm64 75.61% <51.16%> (-0.02%) ⬇️
unittest 83.51% <71.87%> (-0.02%) ⬇️
windows-2022 85.50% <70.90%> (-0.04%) ⬇️
windows-2025 85.52% <69.64%> (-0.04%) ⬇️
winpcap 85.52% <69.64%> (-0.04%) ⬇️
xdp 53.47% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +158 to +159
bool matches(const uint8_t* packetData, uint32_t packetDataLength, timespec timestamp, uint16_t linkType,
LinkMismatchBehaviour onLinkmismatch = LinkMismatchBehaviour::RecompileFilter) const;
Copy link
Collaborator Author

@Dimi1010 Dimi1010 Sep 12, 2025

Choose a reason for hiding this comment

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

@seladb I would like a second opinion on if the onLinkMismatch is a good addition.

I can see it going two ways:

  1. The filter is considered filter string + compiled BPF program. Then it would make sense to control if a recompile is desired. In that case, having a flag to control it is a potential improvement.

  2. The filter is considered only filter string and the compiled program is considered part of the match procedure. If that is the case, then the program being cached in the object is an optimization. Recompiling it as needed is fine, as the program is expected to be compiled every time anyway. In this case, the user does not need an ability to affect the recompilation, as that is internal implementation.

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.

1 participant