Repository navigation
lib: matcher: make set ownership explicit - #627
Merged
Merged
Conversation
Separate group insertion from set discovery so generation can collect sets from more than one owner.
Set matchers currently copy only the set name. Adding a rule to a chain can therefore make it use a different set with the same name. Store a borrowed set pointer in each matcher. Reject rules that refer to sets the chain does not own. When loading a chain, look up each set name to get its pointer. When copying a chain, point the copied matchers at the copied sets.
qdeslandes
force-pushed
the
sets-ownership
branch
from
October 30, 2026 16:04
5cfaf81 to
624e959
Compare
Let each matcher own its anonymous set and reserve chain collections for named declarations. Construct anonymous sets inside matchers so callers never transfer raw anonymous set pointers. Serialize anonymous sets inside their matchers and deep-copy them when copying a matcher. Collect named and anonymous sets during generation.
qdeslandes
force-pushed
the
sets-ownership
branch
from
October 30, 2026 16:20
624e959 to
0fd2b53
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Give named and anonymous sets distinct owners. Chains own their rules, and rules own their matchers.
chain->setsNamed-set references must point to the actual set object owned by the destination chain.
Anonymous sets have no generated names and are never inserted into
chain->sets. A matcher frees its anonymous set when destroyed. The chain destroys its rules and matchers before freeing named sets, keeping borrowed pointers valid during cleanup.Copying a matcher or rule deep-copies anonymous sets and preserves borrowed pointers to named sets. The named sets' owner must outlive those copies. Copying a complete chain also copies its named sets and rebinds the copied matchers to them.
Serialization stores named sets in the chain and their names in matchers. Loading resolves those names to pointers into the chain's set collection. Anonymous sets are serialized inside their matchers. Program generation collects sets from both owners when building BPF maps.
Related issue
N/A.
Testing
Full test suite passed.
Notes for the reviewer
Revert the anonymous-set naming change for a more consistent approach with a clear ownership model.
AI disclosure
AI assisted change, reviewed and owned by me.
Checklist
make -C $BUILD test_bin testpasses and the code follows the style guidecomponent: subcomponent: short description