-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(libebpfdiscoveryskel): Add sending BPF logging events to userspace #42
feat(libebpfdiscoveryskel): Add sending BPF logging events to userspace #42
Conversation
89dd83e
to
a399576
Compare
std::atomic<bool> stopReceived{false}; | ||
std::thread workerThread; | ||
|
||
struct perf_buffer* logPb; |
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.
Please move this to run()
function, since it's accessed by another thread
|
||
class DiscoveryBpfLogHandler { | ||
public: | ||
DiscoveryBpfLogHandler(DiscoveryBpf discoveryBpf, const DiscoveryConfig config); |
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.
DiscoveryBpfLogHandler(DiscoveryBpf discoveryBpf, const DiscoveryConfig config); | |
DiscoveryBpfLogHandler(DiscoveryBpf& discoveryBpf, const DiscoveryConfig& config); |
void wait(); | ||
|
||
DiscoveryConfig config; | ||
DiscoveryBpf discoveryBpf; |
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.
DiscoveryBpf discoveryBpf; | |
DiscoveryBpf& discoveryBpf; |
running = true; | ||
|
||
logPb = perf_buffer__new( | ||
bpf_map__fd(discoveryBpf.skel->maps.logEventsPerfMap), |
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.
discoveryBpf is not synchronized across threads. Is it safe?
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.
After discussion we're going to refactor this so that we pass the map itself to BpfLogHandler instead of skel.
LOG_TRACE("Discovery BPF log event handler loop is starting."); | ||
int err{0}; | ||
while (!stopReceived) { | ||
err = perf_buffer__poll(logPb, config.logPerfPollInterval.count()); |
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.
config is not synchronized
@@ -28,3 +28,13 @@ __attribute__((always_inline)) inline static bool dataProbeIsBeginningOfHttpRequ | |||
return len >= DISCOVERY_MIN_HTTP_REQUEST_LENGTH && | |||
(dataProbeEqualToString(ptr, "GET /", 5) == 5 || dataProbeEqualToString(ptr, "POST /", 6) == 6); | |||
} | |||
|
|||
__attribute__((always_inline)) inline static int dataCopyString(const char* src, char* dest, size_t len) { |
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.
wouldn't it be possible to use strcpy?
No description provided.