-
Notifications
You must be signed in to change notification settings - Fork 458
policy counters #4074
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
Merged
Merged
policy counters #4074
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b6cedea
bpf: policy stats
kkourt b142ad7
pkg/policystats: package for policy stats
kkourt 0f9ab87
policyhandler: use policyconf.PolicyConfMapName
kkourt 7b71834
policyhandler: initialize policy stats map
kkourt 9b488e0
api: add TracingPolicyStats
kkourt 1e64efb
sensors: log errors on retrieving the policy mode
kkourt a5de1c4
sensors: add policy stats
kkourt 5fc9372
tetra: print tracingpolicy stats
kkourt 3a911a8
alignchecker: support types with the same name
kkourt b85186e
alignchecker: add policy_stats
kkourt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | ||
/* Copyright Authors of Tetragon */ | ||
|
||
#ifndef BPF_POLICYSTATS_H__ | ||
#define BPF_POLICYSTATS_H__ | ||
|
||
#include "policy_conf.h" | ||
|
||
enum policy_actions { | ||
POLICY_INVALID_ACT_ = 0, | ||
POLICY_POST = 1, /* policy posted an event */ | ||
POLICY_SIGNAL = 2, /* policy sent a signal */ | ||
POLICY_MONITOR_SIGNAL = 3, /* policy did not sent a signal because it was in monitor mode */ | ||
POLICY_OVERRIDE = 4, /* policy overrode a return value */ | ||
POLICY_MONITOR_OVERRIDE = 5, /* policy did not overrode a return value because it was in monitor mode */ | ||
POLICY_NOTIFY_ENFORCER = 6, /* policy notified the enforcer */ | ||
POLICY_MONITOR_NOTIFY_ENFORCER = 7, /* policy did not notify the enforcer because it was in monitor mode */ | ||
POLICY_NACTIONS_, | ||
}; | ||
|
||
struct policy_stats { | ||
u64 act_cnt[POLICY_NACTIONS_]; | ||
}; | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_ARRAY); | ||
__uint(max_entries, 1); | ||
__type(key, __u32); | ||
__type(value, struct policy_stats); | ||
} policy_stats SEC(".maps"); | ||
|
||
#endif /* BPF_POLICYSTATS_H__ */ |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking out loud: Could it make sense to user a per-cpu array instead to avoid contention with
lock_add
? Possibly not as generating events is not the common path?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but then user-space ends up being more complicated. I would leave it as a potential future optimization.