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

feat(libebpfdiscoveryskel): Add sending BPF logging events to userspace #42

Closed

Conversation

hparzych
Copy link
Contributor

No description provided.

@hparzych hparzych force-pushed the feat/skel/implement-sending-log-events-to-userspace branch from 89dd83e to a399576 Compare October 31, 2023 08:01
@hparzych hparzych requested review from przsus and jakubrak October 31, 2023 08:11
std::atomic<bool> stopReceived{false};
std::thread workerThread;

struct perf_buffer* logPb;
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DiscoveryBpfLogHandler(DiscoveryBpf discoveryBpf, const DiscoveryConfig config);
DiscoveryBpfLogHandler(DiscoveryBpf& discoveryBpf, const DiscoveryConfig& config);

void wait();

DiscoveryConfig config;
DiscoveryBpf discoveryBpf;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DiscoveryBpf discoveryBpf;
DiscoveryBpf& discoveryBpf;

running = true;

logPb = perf_buffer__new(
bpf_map__fd(discoveryBpf.skel->maps.logEventsPerfMap),
Copy link
Contributor

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?

Copy link
Contributor Author

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());
Copy link
Contributor

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) {
Copy link
Contributor

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?

@hparzych hparzych closed this Nov 22, 2023
@hparzych hparzych deleted the feat/skel/implement-sending-log-events-to-userspace branch April 16, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants